R 中带有标记节点的图的 Degree() 输出格式是什么?
我正在使用边缘列表来生成具有许多编号节点的图:
library(igraph)
edgelist <- read.table(text="2 3
1 2
1 3
2 4
1 4")
g <- graph.data.frame(edgelist, directed=TRUE)
Degree() 的输出给出两行,其中列遵循引入节点的顺序:
deg <- degree(g)
deg
2 1 3 4
3 3 2 2
此输出的数据结构是什么,如何手动重新创建它?当我尝试创建等效的表格、数据框或矩阵时,我会得到额外的标题行/列。 (typeof(deg)
给出“double”)我的应用程序是图形可视化,用于代替 V(g)$size <- deg< 中的
deg
/code> (保留节点的顺序)。
I am using an edgelist to generate a graph with many numbered nodes:
library(igraph)
edgelist <- read.table(text="2 3
1 2
1 3
2 4
1 4")
g <- graph.data.frame(edgelist, directed=TRUE)
The output of degree() gives two rows, with cols following the order nodes were introduced:
deg <- degree(g)
deg
2 1 3 4
3 3 2 2
What is the data structure of this output, and how can I recreate it manually? When I try to create an equivalent table, dataframe or matrix I get extra header rows/cols. (typeof(deg)
gives "double") My application is graph visualization to use in place of deg
in V(g)$size <- deg
(with order of nodes preserved).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
MrFlick 的评论正确地将格式识别为命名数字向量。虽然我无法让他们的代码像用重音符号编写的那样工作,但通过查找正确的数据结构,我能够重新创建所需的输出:
MrFlick's comment correctly identified the format as a named numeric vector. While I couldn't get their code to work as written with the grave accent symbol, by looking up the correct data structure I was able to recreate the desired output: