我正在使用带有 networkx 包的 python。我需要找到连接到给定节点外边缘的节点。 我知道有一个函数 networkx.DiGraph.out_edges 但它返回整个图的边。
最佳答案
我不是 networkx 专家,但你试过了吗 networkx.DiGraph.out_edges , 指定源节点?
DiGraph.out_edges(nbunch=None, data=False)
Return a list of edges.
Edges are returned as tuples with optional data in the order (node, neighbor, data).
如果您只想要单个节点的出边,请将该节点传递到 nbunch 中:
graph.out_edges([my_node])
关于python - 是否有返回节点外边的函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2191687/