networkx 2.8.2 Pypi GitHub Homepage
Other Docs
ParametersReturnsBackRef
selfloop_edges(G, data=False, keys=False, default=None)

A selfloop edge has the same node at both ends.

Parameters

G : graph

A NetworkX graph.

data : string or bool, optional (default=False)

Return selfloop edges as two tuples (u, v) (data=False) or three-tuples (u, v, datadict) (data=True) or three-tuples (u, v, datavalue) (data='attrname')

keys : bool, optional (default=False)

If True, return edge keys with each edge.

default : value, optional (default=None)

Value used for edges that don't have the requested attribute. Only relevant if data is not True or False.

Returns

edgeiter : iterator over edge tuples

An iterator over all selfloop edges.

Returns an iterator over selfloop edges.

See Also

nodes_with_selfloops
number_of_selfloops

Examples

>>> G = nx.MultiGraph()  # or Graph, DiGraph, MultiDiGraph, etc
... ekey = G.add_edge(1, 1)
... ekey = G.add_edge(1, 2)
... list(nx.selfloop_edges(G)) [(1, 1)]
>>> list(nx.selfloop_edges(G, data=True))
[(1, 1, {})]
>>> list(nx.selfloop_edges(G, keys=True))
[(1, 1, 0)]
>>> list(nx.selfloop_edges(G, keys=True, data=True))
[(1, 1, 0, {})]
See :

Back References

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

networkx.generators.degree_seq.directed_configuration_model networkx.generators.degree_seq.configuration_model networkx.classes.function.nodes_with_selfloops networkx.classes.function.selfloop_edges networkx.classes.function.number_of_selfloops networkx.generators.random_clustered.random_clustered_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/function.py#1130
type: <class 'function'>
Commit: