【问题标题】:Plot only Edges with a specific weight - igraph仅绘制具有特定权重的边 - igraph
【发布时间】:2014-04-23 05:33:06
【问题描述】:

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

到目前为止我已经尝试过

plot.graph(E(sgdf)[E(sgdf)$weight==3]))

但我总是收到此错误

Error in V(g) : Not a graph object

【问题讨论】:

标签: r igraph


【解决方案1】:

首先复制您的图表,删除不需要的边,然后绘制其余部分:

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

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

更新:正如一位匿名编辑(其编辑被遗憾地拒绝)指出的那样,igraph 从 igraph 0.6 开始使用 1 基边索引。因此,仅当您使用 igraph 0.5.x 或更早版本时,才减 1。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-07-15
    • 1970-01-01
    • 2019-10-17
    • 1970-01-01
    • 2018-11-25
    • 2016-09-19
    • 1970-01-01
    • 2019-06-19
    相关资源
    最近更新 更多