nodes_with_selfloops#

nodes_with_selfloops(G)[source]#

返回一个迭代器,遍历包含自环的节点。

包含自环的节点是指该节点有一条边的两个端点都连接到自身。

返回:
nodelist迭代器

一个迭代器,遍历包含自环的节点。

示例

>>> G = nx.Graph()  # or DiGraph, MultiGraph, MultiDiGraph, etc
>>> G.add_edge(1, 1)
>>> G.add_edge(1, 2)
>>> list(nx.nodes_with_selfloops(G))
[1]