简体   繁体   English

创建名称为数字的网络子图-带R的图

[英]Creating a subgraph of network whose names are numbers--igraph with R

I have a large directed network and I'm trying to create a subgraph of a subset of nodes and all nodes that connect to them. 我有一个大型的定向网络,我正在尝试创建节点的子集以及连接到它们的所有节点的子图。 The problem is that the node names are id numbers. 问题在于节点名称是ID号。 When I try and subset with "make_ego_graph" in igraph, I get the following error: Error in as.igraph.vs(graph, nodes) : Invalid vertex names 当我尝试在igraph中使用“ make_ego_graph”作为子集时,出现以下错误: Error in as.igraph.vs(graph, nodes) : Invalid vertex names

The subsetting seems to work fine when I create the network with names rather than numbers, but for precision's sake, I'd rather use the id numbers. 当我使用名称而不是数字创建网络时,该子设置似乎工作正常,但是出于精度考虑,我宁愿使用id数字。

Has anyone come across this error before and could maybe provide a solution. 有没有人遇到过这个错误,也许可以提供解决方案。 Thank you for your help! 谢谢您的帮助!

Vertex IDs in R-igraph have to be in the range [1; R-igraph中的顶点ID必须在[1; |V|] where |V| | V |]其中| V | is the number of vertices. 是顶点数。 When all your node names are numbers, igraph probably expects this condition to hold, and bails out when it realizes that the condition doesn't hold. 当您所有的节点名称均为数字时,igraph可能希望此条件成立,并在意识到该条件不成立时予以救助。 Try converting your original IDs to strings - semantically, they could stay the same but their R type has to be a string. 尝试将原始ID转换为字符串 -从语义上讲,它们可以保持不变,但其R类型必须为字符串。

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

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