generalized_degree(G, nodes=None)
For each node, the generalized degree shows how many edges of given triangle multiplicity the node is connected to. The triangle multiplicity of an edge is the number of triangles an edge participates in. The generalized degree of node $i$ can be written as a vector $\mathbf{k}_i=(k_i^{(0)}, \dotsc, k_i^{(N-2)})$ where $k_i^{(j)}$ is the number of edges attached to node $i$ that participate in $j$ triangles.
In a network of N nodes, the highest triangle multiplicty an edge can have is N-2.
The return value does not include a zero
entry if no edges of a particular triangle multiplicity are present.
The number of triangles node $i$ is attached to can be recovered from the generalized degree $\mathbf{k}_i=(k_i^{(0)}, \dotsc, k_i^{(N-2)})$ by $(k_i^{(1)}+2k_i^{(2)}+\dotsc +(N-2)k_i^{(N-2)})/2$ .
Compute the generalized degree for nodes in this container.
Generalized degree of specified nodes. The Counter is keyed by edge triangle multiplicity.
Compute the generalized degree for nodes.
>>> G = nx.complete_graph(5)
... print(nx.generalized_degree(G, 0)) Counter({3: 4})
>>> print(nx.generalized_degree(G)) {0: Counter({3: 4}), 1: Counter({3: 4}), 2: Counter({3: 4}), 3: Counter({3: 4}), 4: Counter({3: 4})}
To recover the number of triangles attached to a node:
>>> k1 = nx.generalized_degree(G, 0)See :
... sum([k * v for k, v in k1.items()]) / 2 == nx.triangles(G, 0) True
The following pages refer to to this document either explicitly or contain code examples using this.
networkx.algorithms.cluster.generalized_degree
Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.
Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)
SVG is more flexible but power hungry; and does not scale well to 50 + nodes.
All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them