返回

r-将Igraph转换为vis网络

发布时间:2022-04-08 20:46:12 256
# edge
我有一张网络图,我用;igraph“;图书馆:
library(tidyverse)
library(igraph)


set.seed(123)
n=15
data = data.frame(tibble(d = paste(1:n)))

relations = data.frame(tibble(
  from = sample(data$d),
  to = lead(from, default=from[1]),
))

data$name = c("new york", "chicago", "los angeles", "orlando", "houston", "seattle", "washington", "baltimore", "atlanta", "las vegas", "oakland", "phoenix", "kansas", "miami", "newark" )

graph = graph_from_data_frame(relations, directed=T, vertices = data) 
(edge_fac <- forcats::as_factor(get.edgelist(graph)[,1]))
n2 <- as.integer(factor(data$name,levels = levels(edge_fac)))


V(graph)$color <- ifelse(data$d == relations$from[1], "red", "orange")
V(graph)$label <- paste0(data$name,"\n\n\n",n2)
plot(graph, layout=layout.circle, edge.arrow.size = 0.2, main = "my_graph")

有没有可能把上面的图表转换成“a”呢;visnetwork“;图表?

我知道有一个函数(visIgraph())用于转换;igraph“;图到;visnetwork“;图:https://www.rdocumentation.org/packages/visNetwork/versions/2.1.0/topics/visNetwork-igraph

但我不确定我是否能改变第一个;igraph“;将图形(带有“数字”和“文本”标签)转换为交互式;visnetwork“;图表

我尝试用以下代码来实现这一点:

visIgraph(graph)

但这会创建一个没有“;数字“;标签:

有可能做到这一点吗?

非常感谢。

特别声明:以上内容(图片及文字)均为互联网收集或者用户上传发布,本站仅提供信息存储服务!如有侵权或有涉及法律问题请联系我们。
举报
评论区(2)
按点赞数排序
用户头像