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
weighted.net using these commands (note that these files are on the web, and hence, the link instead of a filename).
# Read the binarynetwork binary.net <- read.table("http://opsahl.co.uk/tnet/datasets/two-mode-binary-network.txt", sep="\t") # Read the undirected network weighted.net <- read.table("http://opsahl.co.uk/tnet/datasets/two-mode-weighted-network.txt", 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 library(tnet) # Read the weighted network weighted.net <- read.table("http://opsahl.co.uk/tnet/datasets/two-mode-weighted-network.txt", sep="\t") # Check that it confirms to the tnet standard for weighted one-mode networks weighted.net <- as.tnet(weighted.net, 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.