networkx 2.8.2 Pypi GitHub Homepage
Other Docs
NotesParameters

The functionality is like dict.items() with (node, degree) pairs. Additional functionality includes read-only lookup of node degree, and calling with optional features nbunch (for only a subset of nodes) and weight (use edge weights to compute degree).

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 : bool or string (default=None)

A View class for degree of nodes in a NetworkX Graph

Examples

>>> G = nx.path_graph(3)
... DV = G.degree()
... assert DV[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 :

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#378
type: <class 'type'>
Commit: