number_of_selfloops# number_of_selfloops(G)[source]# 返回自环边的数量。 自环边连接同一节点。 返回: nloopsint自环的数量。 另请参阅 nodes_with_selfloops, selfloop_edges 示例 >>> G = nx.Graph() # or DiGraph, MultiGraph, MultiDiGraph, etc >>> G.add_edge(1, 1) >>> G.add_edge(1, 2) >>> nx.number_of_selfloops(G) 1