简体   繁体   English

使用节点ID查找图的子集(必须包括提供给ID的所有节点)

[英]Find subset of a graph using node id's (must include all nodes connected to id's supplied)

What im looking for is a quick way to take a set of nodes and find a subset of a graph that has all of those PLUS other vertex that have a edges to those nodes. 我正在寻找的是一种快速的方法来获取一组节点并找到图的子集,该图的子集包含所有这些PLUS其他顶点,这些顶点具有那些节点的边缘。

Im sure it's very simple but i've failed to find a nice way of doing it. 我肯定这很简单,但是我没有找到一种很好的方法。

Thanks in advance! 提前致谢!

You are looking for adjacent edges, or adjacent vertex . 您正在寻找相邻的边或相邻的顶点。

Using igraph package, you can use on of theses functions: 使用igraph包,您可以使用以下功能之一:

 get.adjedgelist
 get.adjlist

Example : 范例:

gg <- ring(10)                  ## create a ring graph
g2 <- induced.subgraph(g, 1:7)  ## indiced grapg by vertex 1:7
get.adjedgelist(g2)             ## get adjacent edges of this sub-graph

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

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