selfloop_edges¶

Graph.
selfloop_edges
(data=False, default=None)[source]¶ Return a list of selfloop edges.
A selfloop edge has the same node at both ends.
Parameters:  data (string or bool, optional (default=False)) – Return selfloop edges as two tuples (u,v) (data=False) or threetuples (u,v,datadict) (data=True) or threetuples (u,v,datavalue) (data=’attrname’)
 default (value, optional (default=None)) – Value used for edges that dont have the requested attribute. Only relevant if data is not True or False.
Returns: edgelist – A list of all selfloop edges.
Return type: list of edge tuples
See also
Examples
>>> G = nx.Graph() # or DiGraph, MultiGraph, MultiDiGraph, etc >>> G.add_edge(1,1) >>> G.add_edge(1,2) >>> G.selfloop_edges() [(1, 1)] >>> G.selfloop_edges(data=True) [(1, 1, {})]