easygraph.functions.basic package
Submodules
easygraph.functions.basic.avg_degree module
- easygraph.functions.basic.avg_degree.average_degree(G) float [source]
Returns the average degree of the graph.
- Parameters:
G (graph) – A EasyGraph graph
- Returns:
average degree – The average degree of the graph.
- Return type:
float
Notes
Self loops are counted twice in the total degree of a node.
Examples
>>> G = eg.Graph() # or DiGraph, MultiGraph, MultiDiGraph, etc >>> G.add_edge(1, 2) >>> G.add_edge(2, 3) >>> eg.average_degree(G) 1.3333333333333333
easygraph.functions.basic.cluster module
- easygraph.functions.basic.cluster.average_clustering(G, nodes=None, weight=None, count_zeros=True, n_workers=None)[source]
Compute the average clustering coefficient for the graph G.
The clustering coefficient for the graph is the average,
\[C = \frac{1}{n}\sum_{v \in G} c_v,\]where \(n\) is the number of nodes in G.
- Parameters:
G (graph) –
nodes (container of nodes, optional (default=all nodes in G)) – Compute average clustering for nodes in this container.
weight (string or None, optional (default=None)) – The edge attribute that holds the numerical value used as a weight. If None, then each edge has weight 1.
count_zeros (bool) – If False include only the nodes with nonzero clustering in the average.
- Returns:
avg – Average clustering
- Return type:
float
Examples
>>> G = eg.complete_graph(5) >>> print(eg.average_clustering(G)) 1.0
Notes
This is a space saving routine; it might be faster to use the clustering function to get a list and then take the average.
Self loops are ignored.
References
- easygraph.functions.basic.cluster.clustering(*args, **kwargs)
easygraph.functions.basic.localassort module
- easygraph.functions.basic.localassort.localAssort(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)[source]
Calculate the multiscale assortativity. You must ensure that the node index and node attribute index start from 0 :param edgelist: the network represented as an edge list,
i.e., a E x 2 array of node pairs
- Parameters:
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.