如果您从 R 中使用 igraph,请使用此选项
as_long_data_frame {igraph} | R 文档 |
一个长数据框包含关于图的顶点和边的所有元数据。它包含每条边的一行,并且关于该边及其关联顶点的所有元数据都包含在该行中。包含关联顶点元数据的列的名称以 from_
和 to_
为前缀。前两列总是命名为 from
和 to
,它们包含关联顶点的数字 id。行按照数字顶点 id 的顺序排列。
as_long_data_frame(graph)
图 |
输入图 |
一个长数据框。
g <- make_(ring(10),
with_vertex_(name = letters[1:10], color = "red"),
with_edge_(weight = 1:10, color = "green")
)
as_long_data_frame(g)