selfloop_edges(G, data=False, keys=False, default=None)
A selfloop edge has the same node at both ends.
A NetworkX graph.
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')
If True, return edge keys with each edge.
Value used for edges that don't have the requested attribute. Only relevant if data is not True or False.
An iterator over all selfloop edges.
Returns an iterator over selfloop edges.
>>> 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 :
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
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