[英]Access nodes with edges to a certain node of interest in igraph python
I have an igraph
graph object called g
with some edges.我有一个名为
g
的igraph
图对象,带有一些边。 I would like to get all nodes with an edge to a certain node我想让所有节点都具有某个节点的边缘
g = Graph.Tree(10, 2)
print g
IGRAPH U--- 10 9 --
+ edges:
0--1 0--2 1--3 1--4 2--5 2--6 3--7 3--8 4--9
If I select node 1
, then I should get back a list of the other nodes with edges to node 1
(graph is undirected).如果我选择 node
1
,那么我应该返回一个其他节点的列表,这些节点的边到节点1
(图是无向的)。 The output should look like:输出应如下所示:
[0, 3, 4]
That is exactly what the neighbors
method does.这正是
neighbors
方法所做的。
g.neighbors(1)
Out[12]: [0, 3, 4]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.