Borders only edges with a certain weight - igraph

I have a really large list of ribs and I would like to build only those edges that have a certain weight, how can I do this?

I still tried

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

but i always get this error

Error in V(g) : Not a graph object
+5
source share
1 answer

Copy your chart first, delete the edges that you don’t need, and write down the rest:

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

-1required delete.edgesbecause igraph uses zero-based zero indexes, while R uses 1-based indexes.

Update : as an anonymous editor (whose editing was sadly rejected), indicated that igraph uses 1-base edge indices from igraph 0.6 onwards. Therefore, subtract 1 only if you use igraph 0.5.x or earlier.

+11
source

All Articles