[英]degree of a graph
我使用以下代码并创建了一个图形:
a <- graph.formula(A-D:B:C:E, k-P:J)
然后我使用igraph包的功能计算了所有节点的度
centralization.degree(a)
输出是
$res
[1] 4 1 1 1 1 2 1 1
$centralization
[1] 0.3571429
$theoretical_max
[1] 56
可以看出,4是最高的,因此我输出了该值,但我还希望相应度数值最高的节点。 在上面的示例中是A。我该怎么做?
查看igraph手册中的 degree
。 然后使用which
和max
某种组合。
至于领带:
> a <- graph.formula(Z-D:B:C:E,A-D:B:C:E, k-P:J)
> a
IGRAPH UN-- 9 10 --
+ attr: name (v/c)
> degree(a)
Z D B C E A k P J
4 2 2 2 2 4 2 1 1
> which(degree(a)==max(degree(a)))
Z A
1 6
>
这些值是索引。 在度向量中,Z为1,A为6。
centralization.degree
功能超出了您的需求,因此正如@pbible所说,您可以只使用degree
:
which.max(degree(a))
# A
# 1
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.