## Random Two-mode Networks

When analysing network and computing measures, it is difficult to gauge whether the outcome is “high” or “low”. For example, is a 0.3 clustering coefficient high or low? Random networks based on an observed network can be used as to create a benchmark value. In other words, an observed value (e.g., a clustering coefficient) can be compared to the distribution of clustering coefficient from corresponding random networks.

There are many procedures or null models for creating random networks in one-mode networks. These procedures vary in how much they randomise an observed network. Traditionally, classical (also known as Bernoulli or Erdos-Reyni) random networks were the commonly used. These networks are constructed by using the same number of nodes, and assigning each dyad a uniform probability of having a tie based on the number of observed ties. In these networks, the degree distribution is uniform or Poisson. However, such a distribution rarely exist in reality. In fact, most real-world distributions are skewed. In response to the lack of comparability between observed networks and classical random networks, a set of randomisation procedures that maintain additional features has been developed. First, by reshuffling ties in an observed network, it is possible to create random networks that maintain each node’s number of ties as well as the overall number of nodes and ties (Molloy and Reed, 1995). Second, for weighted networks, it is also possible to reshuffle only the weights. By maintaining the ties and simply reshuffling tie weights, features based on connectedness are maintained (e.g., the size of the largest interconnected group of nodes; Opsahl et al., 2008).

The procedures for creating random networks in one-mode networks can be ported to two-mode networks. This page describes the counterparts to classical random network, tie reshuffled, and weighted reshuffled networks.

**Classical Random Two-mode Networks**

Classical random networks are created by setting the number of nodes and giving all possible ties a uniform probability of being formed. This probability is often the density of networks (i.e., number of directed ties or 2x undirected ties over Nx(N-1)). This procedure can be ported to two-mode networks by setting the numbers of primary and secondary nodes and giving all possible ties (i.e., ties between nodes in different groups) a uniform probability of being formed. To create corresponding networks, this probability would be using the two-mode density metric instead of the one-mode one: number of ties divided by the product of the numbers of primary and secondary nodes. This procedure is implemented in the function rg_tm in tnet.

**Link Reshuffling**

As nodes’ degree are not uniformely distributed, a second procedure for creating random networks consists in reshuffling the topology, reaching the maximally random network with the same degree distribution as the observed network (Maslov and Sneppen, 2002; Newman, 2003). For two-mode networks, a similar procedure can be conducted that ensures that nodes maintain their number of connections. This null model is implemented in the rg_reshuffling_tm-function with the option parameter set to “links”.

**Weight Reshuffling**

While the link reshuffling procedure can be applied to binary networks, another procedures is possible to use when dealing with weighted two-mode networks. The weight reshuffling procedure consists simply in reshuffling the weights globally in the network (Opsahl et al., 2008). This null model maintains the topology of the observed network. Therefore, the number of ties originating from a node (degree) does not change. Moreover, other features, such as the giant component does not change as well. This null model is also implemented in the rg_reshuffling_tm-function with the option parameter set to “weights”.

**Want to test it with your data?**

The randomisation procedures are implemented in tnet. First, you need to download and install tnet in R. Then, you need to create an edgelist of your network (see data structures in tnet for weighted two-mode networks). The commands below show how corresponding random networks to the Davis’ Southern Women data (Davis et al., 1941) can be created.

# Load tnet and Davis’ Southern Women network library(tnet) data(tnet) net <- Davis.Southern.women.2mode # Bernoulli / Erdos Renyi (find the number of nodes and density first) n1 <- length(unique(net[,1])) n2 <- length(unique(net[,2])) ptie <- nrow(net)/(n1*n2) rg_tm(ni=n1, np=n2,ties=ptie) # Tie reshuffling rg_reshuffling_tm(net, option="links") # Weight reshuffling (add random weights first) netw <- cbind(net, sample(1:4, size=nrow(net), replace=TRUE)) rg_reshuffling_tm(netw, option="weights")

**References**

Davis, A., Gardner, B. B., Gardner, M. R., 1941. Deep South. University of Chicago Press, Chicago, IL.

Molloy, M., Reed, B., 1995. A critical point for random graphs with a given degree sequence. Random Structures and Algorithms 6, 161-180.

Opsahl, T., Colizza, V., Panzarasa, P., Ramasco, J. J., 2008. Prominence and control: The weighted rich-club effect. Physical Review Letters 101 (168702). arXiv:0804.0417.

Opsahl, T., 2013. Triadic closure in two-mode networks: Redefining the global and local clustering coefficients. Social Networks 35, doi:10.1016/j.socnet.2011.07.001.

1.Thomas | August 30, 2013 at 10:18 amHello Tore,

I am using the rg_tm function to create a random network. I would like to know if there is a difference in the resulting degree distribution of the network if (1) I put in the exact number of ties (e.g. ties=300) or (2) if I Put in the probability of having a tie (e.g. ties=0.05).

For example that the degree in the second case is a Poisson distribution while in the first case there is no distribution function but just a single value.

Best regards,

Thomas

2.Tore Opsahl | September 3, 2013 at 1:41 amHi Thomas,

The difference is the method used for creating the network. When you set the probability, each tie has this probability of being created — i.e., whether or not each individual tie exists is completely independent of the other ties. In the resulting network, there approximately -but not exactly be- (probability*n*(n-1)) ties. Conversely, if the number of ties is specified (e.g., ties=300), there will be exactly that amount of ties in the resulting network. In this case, the ties are not completely independent of each other as the number is fixed.

In terms of the degree distribution, both methods will create a classical random network with a Poisson distribution. If you would like to maintain a degree distribution, see the rg_reshuffling_tm-function.

Best,

Tore

3.Matthew E Parker | February 16, 2017 at 6:42 pmI am extremely new to R and tnet, so please bear with me. I have several 2-mode networks and I am trying to compare their reinforcement and clustering measures with that of a random network. For one network I have come up with the following code to create a comparable random network:

randonet <- rg_tm(ni=1125,np=338,ties=1504,weights=1,seed=NULL)

randonet <- as.tnet(randonet, type="binary two-mode tnet")

reinforcement_tm(randonet)

clustering_tm(randonet)

clustering_local_tm(randonet)

As far as I can tell, this has worked fine. However, I would like to stabilize the random measurements by averaging the values from multiple random networks. Is there an easy way to do the above procedure to, for example, 1,000 random networks simultaneously and then output the averages of the resulting measures?

4.Tore Opsahl | February 22, 2017 at 2:02 amHi Matthew,

The easiest way to do this is to create an output vector and then a loop. Below is an example snippet of code.

Best,

Tore