igraph.to.gexf具有未连接的节点

时间:2019-05-29 16:00:38

标签: r igraph gephi

我正在尝试使用igraph.to.gexf命令在gephi中查看具有未连接节点的igraph网络,但是由于未连接节点,它会引发错误:

.parseNodesVizAtt(nodesVizAtt,节点)中的错误:   “ nodeVizAtt”行的数量不足:atts颜色(55行),大小(55) 每个att的行数应与节点的行数相同(37)

几年前有人在bitbucket上提出了一个解决方案: https://bitbucket.org/gvegayon/rgexf/pull-requests/3/igraphtorgexf-with-disconnected-nodes/diff

但是它不起作用-正如该帖子的作者所说,存在边缘源和目标未显示的问题,但从未更新过。有人有替代解决方案吗?

下面是一些示例代码

PubID <- c("169759","174843","174843","174843","174843","174843","171051","171051","171051","171719","171719","171719","169759","173847","173847","177427")
Author <- c("ZJ","RA","DJ","JP","GS","Tv","MC","JR","CW","PB","MD","FO","FO","RA","DJ","KS")
dt <- data.frame(Author,PubID)
dt %>%
  mutate(author_id = as.integer(Author)) -> dt
dt %>%
  inner_join(dt, by = "PubID") %>%
  filter(author_id.x < author_id.y) %>%
  count(Author.x, Author.y) %>%
  graph_from_data_frame(directed = FALSE) -> g1

(rest <- setdiff(Author, V(g1)$name))
g1 <- add.vertices(g1, length(rest), attr = list(name = rest))

plot(g1)


g1.gexf <- igraph.to.gexf(g1) 
f <- file("J:/graph.gexf")
writeLines(g1.gexf$graph, con = f)
close(f)

使用标准的igraph.to.gexf会删除此版本中的未连接节点(KS)(或在实际文件中引发错误消息),并且使用经过修改的bitbucket代码会丢失所有边缘的源和目标。 / p>

0 个答案:

没有答案