Generating nodes and edges

Generate a network with 10,000 nodes with preferential attachment: \(\alpha, \beta, \gamma\) are the probabilities (weights) of adding a new node through an in-degree to one of the existing node, a new edge between two existing nodes, and a new node through an out-degree of an existing node. \(\delta_{\text{in}}\) and \(\delta_{\text{out}}\) are small constants to avoid zero weights in generating the edges.

Setting 1:

load("PA_10000_1.RData")
# g <- PA(10000, alpha =  10, beta = 5, gamma = 1, delta.in = 0.5, delta.out = 0.5) 

Quantiles of in- and out-degrees

quantile(degrees[, "in"], probs = seq(0, 1, 0.05), names = TRUE, na.rm = T)
##   0%   5%  10%  15%  20%  25%  30%  35%  40%  45%  50%  55%  60%  65%  70% 
##    0    0    0    0    0    0    0    0    0    0    0    0    0    0    1 
##  75%  80%  85%  90%  95% 100% 
##    1    1    2    3    5 1446
quantile(degrees[, "out"], probs = seq(0, 1, 0.05), names = TRUE, na.rm = T)
##   0%   5%  10%  15%  20%  25%  30%  35%  40%  45%  50%  55%  60%  65%  70% 
##    0    0    1    1    1    1    1    1    1    1    1    1    1    1    1 
##  75%  80%  85%  90%  95% 100% 
##    2    2    2    3    3   24

Hill plots

Distribution of node types

## 
## both   in none  out 
##   64  234 6345  266
## 
##       both         in       none        out 
## 0.00926328 0.03386887 0.91836735 0.03850051

Plot conditional distributions of neighbors’ types

Step 0: randomly sample 20 nodes and neighbors they follow

## [1] "frequency and distribution of types"
## 
## both   in none  out 
##    1    0   47    2
## 
## both   in none  out 
## 0.02 0.00 0.94 0.04
## [1] "number of edges"
## [1] 69  2
## [1] "number of neighbors they follow"
## [1] 55
## [1] "frequency and distribution of types in neighbors"
## 
## both   in none  out 
##    8   23   22    2
## 
##       both         in       none        out 
## 0.14545455 0.41818182 0.40000000 0.03636364
## [1] "Distribution of types in all nodes"
## 
##       both         in       none        out 
## 0.08910891 0.22772277 0.65346535 0.02970297

Step 1: get all neighbors of the target nodes in step 0

## [1] "no. of initial target nodes that actually have a neighbor"
## [1] 17  3
## [1] "number of neighbors"
## [1] 24
## [1] "frequency and distribution of types of neighbors"
## 
## both   in none  out 
##    7   11    5    1
## 
##       both         in       none        out 
## 0.29166667 0.45833333 0.20833333 0.04166667
## [1] "distribution of types in all nodes involved"
## 
##       both         in       none        out 
## 0.17948718 0.66666667 0.12820513 0.02564103

Step 2: get all neighbors of the target neighbor nodes in step 1

## [1] "number of target neighbors"
## [1] 11
## [1] "number of neighbors"
## [1] 8
## [1] "frequency and distribution of types of neighbors"
## 
## both   in none  out 
##    3    3    2    0
## 
##  both    in  none   out 
## 0.375 0.375 0.250 0.000
## [1] "frequency and distribution of types in all nodes involved (including non-target neighbors reviewed)"
## 
## both   in none  out 
##    7   27    6    1
## 
##       both         in       none        out 
## 0.17073171 0.65853659 0.14634146 0.02439024

## [1] "number of all nodes involved (including step 0)"
## [1] 120   1
## [1] "Frequency and distribution of types"
## 
## both   in none  out 
##   14   32   71    3
## 
##      both        in      none       out 
## 0.1166667 0.2666667 0.5916667 0.0250000

Setting 2:

load("PA_10000_2.RData")
# g <- PA(10000, alpha =  10, beta = 1, gamma = 1, delta.in = 0.5, delta.out = 0.5) 

Quantiles of in- and out-degrees

quantile(degrees[, "in"], probs = seq(0, 1, 0.05), names = TRUE, na.rm = T)
##   0%   5%  10%  15%  20%  25%  30%  35%  40%  45%  50%  55%  60%  65%  70% 
##    0    0    0    0    0    0    0    0    0    0    0    0    0    0    1 
##  75%  80%  85%  90%  95% 100% 
##    1    1    1    2    4  336
quantile(degrees[, "out"], probs = seq(0, 1, 0.05), names = TRUE, na.rm = T)
##   0%   5%  10%  15%  20%  25%  30%  35%  40%  45%  50%  55%  60%  65%  70% 
##    0    0    1    1    1    1    1    1    1    1    1    1    1    1    1 
##  75%  80%  85%  90%  95% 100% 
##    1    1    1    2    2    8

Hill plots

Distribution of node types

## 
## both   in none  out 
##   48  366 8575  211
## 
##        both          in        none         out 
## 0.005217391 0.039782609 0.932065217 0.022934783

Plot conditional distributions of neighbors’ types

Step 0: randomly sample 20 nodes and neighbors they follow

## [1] "frequency and distribution of types"
## 
## both   in none  out 
##    0    0   49    1
## 
## both   in none  out 
## 0.00 0.00 0.98 0.02
## [1] "number of edges"
## [1] 55  2
## [1] "number of neighbors they follow"
## [1] 51
## [1] "frequency and distribution of types in neighbors"
## 
## both   in none  out 
##    4   23   23    1
## 
##       both         in       none        out 
## 0.07843137 0.45098039 0.45098039 0.01960784
## [1] "Distribution of types in all nodes"
## 
##       both         in       none        out 
## 0.04040404 0.23232323 0.70707071 0.02020202

Step 1: get all neighbors of the target nodes in step 0

## [1] "no. of initial target nodes that actually have a neighbor"
## [1] 17  3
## [1] "number of neighbors"
## [1] 14
## [1] "frequency and distribution of types of neighbors"
## 
## both   in none  out 
##    2    8    4    0
## 
##      both        in      none       out 
## 0.1428571 0.5714286 0.2857143 0.0000000
## [1] "distribution of types in all nodes involved"
## 
##       both         in       none        out 
## 0.07142857 0.78571429 0.14285714 0.00000000

Step 2: get all neighbors of the target neighbor nodes in step 1

## [1] "number of target neighbors"
## [1] 8
## [1] "number of neighbors"
## [1] 8
## [1] "frequency and distribution of types of neighbors"
## 
## both   in none  out 
##    0    7    1    0
## 
##  both    in  none   out 
## 0.000 0.875 0.125 0.000
## [1] "frequency and distribution of types in all nodes involved (including non-target neighbors reviewed)"
## 
## both   in none  out 
##    2   25    4    0
## 
##       both         in       none        out 
## 0.06451613 0.80645161 0.12903226 0.00000000

## [1] "number of all nodes involved (including step 0)"
## [1] 112   1
## [1] "Frequency and distribution of types"
## 
## both   in none  out 
##    5   31   74    2
## 
##       both         in       none        out 
## 0.04464286 0.27678571 0.66071429 0.01785714