这应该很简单,但我还是被困在这个手术里了。我感兴趣的是提取块边缘数据: 23,502,x3,并指出节点的名称。简而言之,我需要知道每一对节点的权重。
代码:
# A tbl_graph: 11539 nodes and 23502 edges
#
# An undirected simple graph with 2493 components
#
# Node Data: 11,539 x 3 (active)
name neighbors groups
<chr> <dbl> <int>
1 CHANSATITPORN N 1 1540
2 POBKEEREE V 1 1540
3 SAINIS G 4 361
4 HARITOS G 4 361
5 KRIEMADIS T 4 361
6 PAPASOLOMOU I 3 361
# … with 11,533 more rows
#
# Edge Data: 23,502 x 3
from to weight
<int> <int> <dbl>
1 1 2 1
2 3 4 2
3 3 5 2
# … with 23,499 more rows发布于 2021-03-30 17:37:41
提取边,然后与节点连接以获得接受的答案中的名称是直观的,但需要很多步骤。
使用igraph::get.edgelist (第二个答案)的方法丢失了存储在边缘(问题:权重)中的附加信息。
这是一个应该有效的解决方案。
your_tbl_graph %>%
activate(edges) %>%
mutate(to_name = .N()$name[to],
from_name = .N()$name[from]) %>%
as_tibble() %>%
select(from = from_name, to = to_name, weight)发布于 2021-01-29 21:23:18
Load package igraph()并将函数get.edgelist()应用于激活的边缘集。为了获得适当的输出,随后还应用data.frame()。你会找到那个叫艾德格尔的医生。
library(igraph)
edge_list <-
tg %>%
activate(edges) %>%
get.edgelist() %>%
data.frame()https://stackoverflow.com/questions/63997659
复制相似问题