Riggraph重命名顶点 [英] R igraph rename vertices

查看:57
本文介绍了Riggraph重命名顶点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以重命名igraph中的顶点.我想在顶点上多次绘制具有不同符号的特定图形.鉴于以下igraph az:

Is there a possibility to rename the vertices in an igraph. I want to plot a certain graph multiple times with different notation on the vertices. Given the following igraph az:

> az
IGRAPH DN-- 24 23 -- 
+ attr: name (v/c), label (v/c), color (v/c), fill (v/c), width (e/n)

使用

> V(az)
Vertex sequence:
 [1] "x1"  "x2"  "x3"  "x4"  "x5"  "x7"  "x8"  "x9"  "x10" "x11" "x12" "x13"
[13] "x14" "x15" "x16" "x19" "x20" "x21" "x22" "x23" "x24" "x25" "x26" "x27"

我想将顶点更改为y1-y27 但是,

I want to change the vertices into, lets say to y1-y27 However,

V(az)$name <- paste("y",1:27,sep="")

不起作用.我怎样才能做到这一点? 预先感谢.

is not working. How can I achieve this? Thanks in advance.

欢呼

作为记录.

V(az)$name <- paste("y",1:27,sep="")

以这种方式工作,以便返回:

works in that way, so that it returns:

 > V(az)
    Vertex sequence:
     [1] "y1"  "y2"  "y3"  "y4"  "y5"  "y7"  "y8"  "y9"  "y10" "y11" "y12" "y13"
    [13] "y14" "y15" "y16" "y19" "y20" "y21" "y22" "y23" "y24" "y25" "y26" "y27"

但是,plot(az)仍然返回带有x个节点的图形

However, plot(az) stills return the graph with the x nodes

推荐答案

您可以使用

ay <- set.vertex.attribute(az, "name", value=paste("y",1:27,sep=""))

也可以使用"label"而不是"name".

这篇关于Riggraph重命名顶点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆