R 负度图

R 负度图,r,networking,igraph,R,Networking,Igraph,我正在尝试从我创建的非定向igraph对象获取基本统计信息。 当使用简单的度函数得到负数时,出了什么问题 col_1 <- as.vector(as.character(df$names_1)) col_2 <- as.vector(as.character(df$names_2)) vector <- rbind(col_1,col_2) g <- graph(vector, directed = FALSE) head(sort(desc(degree(g, loo

我正在尝试从我创建的非定向igraph对象获取基本统计信息。 当使用简单的度函数得到负数时,出了什么问题

col_1 <- as.vector(as.character(df$names_1))
col_2 <- as.vector(as.character(df$names_2))
vector <- rbind(col_1,col_2)
g <- graph(vector, directed = FALSE)

head(sort(desc(degree(g, loops = FALSE, normalized = FALSE))))

col_1
不会产生负数<代码>描述执行

由于您没有提供任何数据,我将用任意图形进行说明

library(igraph)
library(plyr)

set.seed(1234)
g = erdos.renyi.game(15, 0.2)

degree(g, loops = FALSE, normalized = FALSE)
 [1] 3 3 5 1 5 4 2 6 4 3 3 5 3 1 6
desc(degree(g, loops = FALSE, normalized = FALSE))
 [1] -3 -3 -5 -1 -5 -4 -2 -6 -4 -3 -3 -5 -3 -1 -6
如果要按降序排列度,请尝试

sort(degree(g, loops = FALSE, normalized = FALSE), decreasing=TRUE)
[1] 6 6 5 5 5 4 4 3 3 3 3 3 2 1 1

度数
不产生负数<代码>描述执行

由于您没有提供任何数据,我将用任意图形进行说明

library(igraph)
library(plyr)

set.seed(1234)
g = erdos.renyi.game(15, 0.2)

degree(g, loops = FALSE, normalized = FALSE)
 [1] 3 3 5 1 5 4 2 6 4 3 3 5 3 1 6
desc(degree(g, loops = FALSE, normalized = FALSE))
 [1] -3 -3 -5 -1 -5 -4 -2 -6 -4 -3 -3 -5 -3 -1 -6
如果要按降序排列度,请尝试

sort(degree(g, loops = FALSE, normalized = FALSE), decreasing=TRUE)
[1] 6 6 5 5 5 4 4 3 3 3 3 3 2 1 1

谢谢,那我怎么按降序排列呢?(除-1*排序外)我将在一分钟内将其添加到答案中。谢谢,那么我如何按降序排序呢?(除-1*排序外)我将在一分钟内将其添加到答案中。