user321627
user321627

Reputation: 2564

In igraph, which network specifications allow groups of nodes to have the same distribution?

I am currently trying to generate a network where the degree distribution has a large variance, but with a sufficient number of nodes at each degree. For example, in igraph, if we use the Barabasi-Albert network, we can do:

g <- sample_pa(n=100,power = 1,m = 10)
g_adj <- as.matrix(as_adj(g))
rowSums(g_adj)
  [1]  0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
 [29] 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
 [57] 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
 [85] 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99

The above shows the degree on each of the 100 nodes. The problem for me is that I would like to only have 10-15 unique degree values, so that instead of having 93 94 95 96 97 98 99 at the end, we have instead, for example, 93 for each of the last 7 nodes. In other words, when I call

unique(rowSums(g_adj))

I'd like at most 10-15 values. Is there a way to "cluster" the nodes instead of having so many different unique degree values? thanks.

Upvotes: 1

Views: 51

Answers (1)

Julius Vainora
Julius Vainora

Reputation: 48211

You may use sample_degseq: Generate random graphs with a given degree sequence. For instance,

degrees <- seq(1, 61, length = 10) # Ten different degrees
times <- rep(10, 10) # Giving each of the degrees to ten vertices
g <- sample_degseq(rep(degrees, times = times), method = "vl")
table(degree(g))
#  1  7 14 21 27 34 41 47 54 61 
# 10 10 10 10 10 10 10 10 10 10 

Note that you may need to play with degree and times as ultimately rep(degrees, times = times) needs to be a graphic sequence.

Upvotes: 2

Related Questions