简体   繁体   English

Networkx - 在有向图上获取命运节点

[英]Networkx - Get destiny node on a directed graph

I'm working with networkx. 我正在使用networkx。 At certain time, I want to get the destiny node of another one. 在某些时候,我想得到另一个命运节点。 I will explain it with a graph: 我将用图表解释它:

在此输入图像描述

For example, given the node 'foto' or the node 'spain', I want to receive the node 'madrid'. 例如,给定节点'foto'或节点'spain',我想接收节点'madrid'。 Is there a direct method to achieve this or it would be a bit harder? 有没有直接的方法来实现这一点,或者会有点难?

I just found what I wanted. 我刚刚找到了我想要的东西。

There is a method on Directed Graphs called successors that returns just what I was asking. Directed Graphs上有一种叫做successors的方法可以回复我的要求。 So, in order to achieve that I have only to call it like this: 所以,为了实现这一点,我只需要这样称呼它:

successors = graph.successors(node)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM