networkx 2.8.2 Pypi GitHub Homepage
Other Docs
NotesParametersBackRef

Typical usage focuses on iteration over :None:None:`(node, degree)` pairs. The degree is by default the number of edges incident to the node. Optional argument :None:None:`weight` enables weighted degree using the edge attribute named in the :None:None:`weight` argument. Reporting and iteration can also be restricted to a subset of nodes using nbunch .

Additional functionality include node lookup so that :None:None:`G.degree[n]` reported the (possibly weighted) degree of node n. Calling the view creates a view with different arguments nbunch or :None:None:`weight`.

Notes

DegreeView can still lookup any node even if nbunch is specified.

Parameters

graph : NetworkX graph-like class
nbunch : node, container of nodes, or None meaning all nodes (default=None)
weight : string or None (default=None)

A DegreeView class to act as G.degree for a NetworkX Graph

Examples

>>> G = nx.path_graph(3)
... DV = G.degree()
... assert DV[2] == 1
... assert G.degree[2] == 1
... assert sum(deg for n, deg in DV) == 4
>>> DVweight = G.degree(weight="span")
... G.add_edge(1, 2, span=34)
... DVweight[2] 34
>>> DVweight[0]  #  default edge weight is 1
1
>>> sum(span for n, span in DVweight)  # sum weighted degrees
70
>>> DVnbunch = G.degree(nbunch=(1, 2))
... assert len(list(DVnbunch)) == 2 # iteration over nbunch only
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

networkx.algorithms.link_prediction.preferential_attachment networkx.algorithms.assortativity.mixing.degree_mixing_matrix networkx.classes.reportviews.DiDegreeView networkx.classes.reportviews.DegreeView

Local connectivity graph

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


GitHub : /networkx/classes/reportviews.py#473
type: <class 'type'>
Commit: