networkx 2.8.2 Pypi GitHub Homepage
Other Docs
ParametersReturnsBackRef
size(self, weight=None)

Parameters

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.

Returns

size : numeric

The number of edges or (if weight keyword is provided) the total weight sum.

If weight is None, returns an int. Otherwise a float (or more general numeric if the weights are more general).

Returns the number of edges or total of all edge weights.

See Also

number_of_edges

Examples

>>> G = nx.path_graph(4)  # or DiGraph, MultiGraph, MultiDiGraph, etc
... G.size() 3
>>> G = nx.Graph()  # or DiGraph, MultiGraph, MultiDiGraph, etc
... G.add_edge("a", "b", weight=2)
... G.add_edge("b", "c", weight=4)
... G.size() 2
>>> G.size(weight="weight")
6.0
See :

Back References

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

networkx.classes.graph.Graph.size networkx.classes.graph.Graph.number_of_edges networkx.classes.multigraph.MultiGraph.number_of_edges networkx.generators.classic.complete_graph

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/graph.py#1765
type: <class 'function'>
Commit: