3

Well, I'm working with the igraph package, and I'd like to pick the edges by the name that I've assigned to their vertex, in a tiny example..

library(igraph)

g <- barabasi.game(8)

labels<-c("G1","G2","G3","T1","T2","T3","H1","H2")

V(g)$name<-labels

Now My edge list hast this form

> E(g)
Edge sequence:

    [0] G2 -> G1
    [1] G3 -> G2
    [2] T1 -> G2
    [3] T2 -> G3
    [4] T3 -> G1
    [5] H1 -> G1
    [6] H2 -> H1

What i want now is to find a way of, instead of using this

E(g)[1%--%2]

doing something more like E(g)[G2%--%G1] (calling the vertex by the name i've assigned), or an equivalent way of knowing some edges attributes by the name of the vertex involved.

4

2 回答 2

0

这对于 igraph 的 0.5 分支是不可能的,但开发版本 (0.6) 添加了对基于name属性而不是数字 ID 引用顶点的支持。我不知道该怎么做,因为我不熟悉 R 界面。尝试订阅igraph-help 邮件列表并在那里询问,因为这绝对是最近在 igraph 0.6 中解决的问题。

于 2010-10-21T09:23:18.763 回答
0

用引号将顶点名称括起来。这给出了与使用顶点编号相同的输出。这适用于 igraph 0.7.1。

例如:

> E(g)[1%--%8]
Edge sequence:
    e         
e [7] H2 -> G1

> E(g)['H2'%--%'G1']
Edge sequence:
    e         
e [7] H2 -> G1
于 2014-09-28T23:07:07.337 回答