R igraph rename vertices

前端 未结 2 1394
耶瑟儿~
耶瑟儿~ 2020-12-10 17:33

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

相关标签:
2条回答
  • 2020-12-10 18:17

    You can use

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

    Also works with "label" instead of "name".

    0 讨论(0)
  • 2020-12-10 18:23

    If V(az) has both a set of 'name' attributes and a set of 'label' attributes, it is the 'label' attributes that get plotted.

    > gt <- graph.tree(24, children = 4, mode=c("out", "in", "undirected"))
    > V(gt)$name <- letters[1:24]
    > plot(gt)   # So 'name's get displayed if no label is present
    > V(gt)$label <- LETTERS[1:24]
    > plot(gt)    # Labels get displayed
    > V(gt)$name <- letters[1:24]  # see if then get overwritten 
    > plot(gt)    # Still plots with 'label's
    
    0 讨论(0)
提交回复
热议问题