仅绘制具有特定重量的边缘 - igraph

Jos*_*187 5 r igraph

我有一个非常大的边缘列表,我想只绘制具有特定权重的边缘,我该怎么做?

到目前为止我试过了

plot.graph(E(sgdf)[E(sgdf)$weight==3]))
Run Code Online (Sandbox Code Playgroud)

但我总是得到这个错误

Error in V(g) : Not a graph object
Run Code Online (Sandbox Code Playgroud)

Tam*_*más 12

首先复制图形,删除不需要的边缘,然后绘制其余图形:

> sgdf.copy <- delete.edges(sgdf, which(E(sgdf)$weight != 3)-1)
> plot(sgdf.copy)
Run Code Online (Sandbox Code Playgroud)

-1delete.edges因为igraph使用从零开始的边缘索引,而R使用从1开始的索引.

更新:作为一个匿名编辑(其编辑被遗弃拒绝)指出,igraph使用从igraph 0.6开始的1基边缘索引.因此,仅在使用igraph 0.5.x或更早版本时减去1.