localassort module¶
Multiscale mixing patterns in networks.
Code to calculate the multiscale assortativity from the accompanying paper: Peel, L., Delvenne, J. C., & Lambiotte, R. (2018). ‘Multiscale mixing patterns in networks.’ PNAS, 115(16), 4057-4062.
-
localassort.
calculateRWRrange
(W, i, alphas, n, maxIter=1000)¶ Calculate the personalised TotalRank and personalised PageRank vectors.
- Parameters
W (array_like) – transition matrix (row normalised adjacency matrix)
i (int) – index of the personalisation node
alphas (array_like) – array of (1 - restart probabilties)
n (int) – number of nodes in the network
maxIter (int, optional) – maximum number of interations (default: 1000)
- Returns
pPageRank_all (array_like) – personalised PageRank for all input alpha values (only calculated if more than one alpha given as input, i.e., len(alphas) > 1)
pTotalRank (array_like) – personalised TotalRank (personalised PageRank with alpha integrated out)
it (int) – number of iterations
References
See 2 and 3 for further details.
- 2
Boldi, P. (2005). “TotalRank: Ranking without damping.” In Special interest tracks and posters of the 14th international conference on World Wide Web (pp. 898-899).
- 3
Boldi, P., Santini, M., & Vigna, S. (2007). “A deeper investigation of PageRank as a function of the damping factor.” In Dagstuhl Seminar Proceedings. Schloss Dagstuhl-Leibniz-Zentrum für Informatik.
-
localassort.
createA
(E, n, m, undir=True)¶ Create adjacency matrix and degree sequence.
-
localassort.
localAssortF
(edgelist, node_attr, pr=array([0., 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9]), undir=True, missingValue=- 1)¶ Calculate the multiscale assortativity.
- Parameters
edgelist (array_like) – the network represented as an edge list, i.e., a E x 2 array of node pairs
node_attr (array_like) – n length array of node attribute values
pr (array, optional) – array of one minus restart probabilities for the random walk in calculating the personalised pagerank. The largest of these values determines the accuracy of the TotalRank vector max(pr) -> 1 is more accurate (default: [0, .1, .2, .3, .4, .5, .6, .7, .8, .9])
undir (bool, optional) – indicate if network is undirected (default: True)
missingValue (int, optional) – token to indicate missing attribute values (default: -1)
- Returns
assortM (array_like) – n x len(pr) array of local assortativities, each column corresponds to a value of the input restart probabilities, pr. Note if only number of restart probabilties is greater than one (i.e., len(pr) > 1).
assortT (array_like) – n length array of multiscale assortativities
Z (array_like) – N length array of per-node confidence scores
References
For full details see 1
- 1
Peel, L., Delvenne, J. C., & Lambiotte, R. (2018). “Multiscale mixing patterns in networks.’ PNAS, 115(16), 4057-4062.