networkx中的G.neighbors(1)指的是所有的1指向的节点,不包括被指向的节点
import networkx as nx
G = nx.DiGraph()
G.add_edge(1,3)
G.add_edge(1,2)
G.add_edge(4,1)
print(list(G.neighbors(1)))
"""
输出
[3, 2]
"""
networkx中的G.neighbors(1)指的是所有的1指向的节点,不包括被指向的节点
import networkx as nx
G = nx.DiGraph()
G.add_edge(1,3)
G.add_edge(1,2)
G.add_edge(4,1)
print(list(G.neighbors(1)))
"""
输出
[3, 2]
"""