简体   繁体   中英

Multiple degree distribution on the same plot

I generated 500 random bipartite networks using the code below. I would like to plot the degree distribution (log-log plots with power law line) of atleast 10 of these networks on a single plot to compare them with the log-log plot of my scale free network visually. I know how to plot the degree distribution of a single network at a time but multiple plots on the same graph is getting to be elusive. Also if possible, I could also use an excel sheet with the pearson correlation coefficient and the slope values of all 500 networks. .

set.seed(1)
    gs1 <- list()
    for (x in seq_len(500L)) 
    {
      gs1[[x]] <- sample_bipartite(358, 27, type = "gnm",m = 827, directed = TRUE)
    }

EDIT: I am looking for a power law line with the degree distribution.

Any help is appreciated. Thank you to you all.

I think that I am making the plot that you are looking for. If not please explain how it differs.

You can plot the first distribution and then add to it using lines . Because each distribution has a different number of degrees, I go through all of them once to find the upper limit.

library(igraph)

## Reproduce your data, paramterizing the number of graphs
NumG = 500L
set.seed(1)
gs1 <- list()
for (x in seq_len(NumG)) {
      gs1[[x]] <- sample_bipartite(358, 27, type = "gnm",m = 827, directed = TRUE)
}

## Find upper limit on degrees
MaxDeg = rep(0,NumG)
for(i in 1:NumG) {
    DD = degree_distribution(gs1[[i]])
    MaxDeg[i] = length(DD)
}
MaxMax = max(MaxDeg)

## Plot first distribution
plot(1:MaxDeg[1], degree_distribution(gs1[[1]]), 
    xlim=c(1,MaxMax), log="xy", type="l",
    xlab="Log-Degree", ylab="LogFrequency")

## Plot all the rest
for(i in 2:NumG) {
    lines(1:MaxDeg[i], degree_distribution(gs1[[i]]), col=rainbow(NumG)[i])
}

学位分布

You can see the two pieces for the two types of nodes. Overall, these seem pretty consistent.

Adding a little detail

There are two different types of nodes. From your generating statement

gs1[[x]] <- sample_bipartite(358, 27, type = "gnm",m = 827, directed = TRUE)

there are 358 nodes that only have links leaving them (Sources). There are also 27 nodes that have no links leaving them (Sinks). Here is a plot of the first graph on your list, gs1[ 1 ].

LO = layout_as_bipartite(gs1[[1]])
plot(gs1[[1]], layout=LO, vertex.size=8, 
    edge.arrow.size=0.3, vertex.label=NA)

图1

The sources are on top and the sinks are on the bottom. The two types of nodes have quite distinct degree distributions. By construction, all of your graphs have 827 links. These leave the 358 sources and go to the 27 sinks. On average, each source will have 827/358 = 2.31 links. On average, the sinks will have 858/27 = 30.63 links. It is easy to see these two distinct distribution in the above degree distribution plot.

It does not appear to me that the degree distributions follow a power law, neither with the sources and sinks together nor either one separately. I am not sure what correlation coefficients you want to compute. So I have no help for you on those topics.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM