Two-mode Data Structure

tnet » Software » Two-mode Data Structure

Two-mode networks (also known as affiliation or bipartite networks) are a particular type of networks with two sets of nodes and ties are only established between nodes belonging to different sets. The network diagram illustrates a weighted two-mode network where the colour represent the node set to which a node belongs. One of the first two-mode datasets to be analysed was the Davis Southern Club Women dataset (Davis et al., 1941), which recorded the attendance of a group of women (node set 1) to a series of events (set 2). A woman would be linked to an event if she attended it. Another type of two-mode dataset that has become popular in recent years is scientific collaboration networks. In this type of networks, a tie is established between a scientist (node set 1) and a paper (node set 2) if the scientist authored that paper (e.g., Newman, 2001).

Similarly to one-mode networks, two-mode networks are represented by edgelists. This is due to the fact that most two-mode networks are sparse (i.e., the number of ties is much smaller than the number of nodes squared). There are two formats used in tnet to represent two-mode networks depending on whether they are binary or weighted. This system was adopted to lessen confusion as most two-mode networks are binary and weighted two-mode networks can be confused with weighted one-mode networks.

Binary Two-mode Networks

Binary two-mode networks should be represented as a two-column data frame where the first column contain the primary or top nodes and the second column contains the secondary or bottom nodes. If the blue nodes are the primary nodes in the diagram above, the binary network should be represented as follows in R:

      [,1] [,2]
 [1,]    1    1
 [2,]    1    2
 [3,]    2    1
 [4,]    2    2
 [5,]    2    3
 [6,]    2    4
 [7,]    2    5
 [8,]    3    2
 [9,]    4    3
[10,]    5    4
[11,]    5    5
[12,]    5    6
[13,]    6    6

Weighted Two-mode Networks

Weighted two-mode networks are similar to binary two-mode networks, but have an additional third column containing tie weights.

The weighted network about should be represented as follows in R:

      [,1] [,2] [,3]
 [1,]    1    1    4
 [2,]    1    2    2
 [3,]    2    1    2
 [4,]    2    2    1
 [5,]    2    3    4
 [6,]    2    4    3
 [7,]    2    5    2
 [8,]    3    2    5
 [9,]    4    3    6
[10,]    5    4    2
[11,]    5    5    4
[12,]    5    6    1
[13,]    6    6    1

Note: As weighted two-mode network can be confused with weighted one-mode networks, it is important to run as.tnet(net, type=”weighted two-mode tnet”) before using any analysis functions. See below.

Loading Your Network

The most common way of loading a network is to read a text file with the network. The read.table-function is the standard method for reading text files. This function works by giving it a filename or link, and a character for separating the values into columns (e.g., a tab). It is important to not just read, but also assign the read file to an object. To illustrate this procedure, the binary and weighted versions of the above network can be loaded into the objects and using these commands (note that these files are on the web, and hence, the link instead of a filename).

# Read the binarynetwork <- read.table("", sep="\t")

# Read the undirected network <- read.table("", sep="\t")

Ensure that the network conforms to the tnet standard

To ensure that the network conforms to the tnet standard, the as.tnet-function can be used. This function is run automatically by the functions if it has not been run on the network manually. This function takes two parameters: the network and a character string specifying the type of network. If the type parameter is not set, an object will be assumed to be a binary two-mode edgelist if it has two columns or if it is a non-square matrix with more than 4 nodes and only 0 and 1 values. It will not be assumed to be a weighted two-mode edgelist if it has three columns (however, it will if it is a non-square matrix with more than 4 nodes and not only 0 and 1 values). Below is the code for testing the weighted network above.

# Load tnet

# Read the weighted network <- read.table("", sep="\t")

# Check that it confirms to the tnet standard for weighted one-mode networks <- as.tnet(, type="weighted two-mode tnet")

To allow for a comparison between weighted and binary network measures, the dichotomise_tm-function creates a binary network from a weighted one. It does so by removing the ties in a weighted edgelist that fall below a certain cut-off and sets the weight to 1 for the remaining ones.

If you use tnet, please cite: Opsahl, T., 2009. Structure and Evolution of Weighted Networks. University of London (Queen Mary College), London, UK, pp. 104-122. Available at

2 Comments Add your own

  • 1. simonegabbriellini  |  February 19, 2014 at 9:47 am

    Dear Tore,

    I am trying to use tnet to work on a two-mode weighted dataset, but I am having troubles to load my data… I read the csv and do as.tnet() without problems, but when I call projecting_tm() I get:

    Warning messages:
    1: In cbind(p = as.numeric(row.names(np)), np = np) :
    si è prodotto un NA per coercizione
    2: In Ops.factor(net[, 1], net[, 2]) : not meaningful for factors
    4: In as.tnet(net1, type = “weighted one-mode tnet”) :
    The network might be undirected. If this is the case, each tie should be mention twice. The symmetrise-function can be used to include reverse version of each tie.
    5: In min(c(net[, “i”], net[, “j”])) :
    no non-missing arguments to min; returning Inf

    Is there any hint you can give me to clear this issue I have?

    Best regards,

    • 2. Tore Opsahl  |  February 19, 2014 at 1:10 pm

      Hi Simone,

      The projecting_tm-function works on two-mode networks. Have you run as.tnet(networkObject, type=’binary two-mode tnet’)?

      If you have any issues, email me your code and data. Then I’ll have a look.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Subscribe to the comments via RSS Feed

%d bloggers like this: