[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [igraph] Creating new graph from existing graph with only top 10 per
From: |
Tamás Nepusz |
Subject: |
Re: [igraph] Creating new graph from existing graph with only top 10 percent of edges |
Date: |
Fri, 6 Jul 2012 09:36:32 +0200 |
Hi Alex,
subgraph.edges was added in 0.6 so you can try upgrading your igraph
installation to the latest version. An alternative to subgraph.edges is to
_delete_ the edges you don't need using delete.edges.
> I use weights <- E(g1)$weight to get all the edge weights. My idea then was
> to use quantile(weights, 0.9) to return the 90% edge weight, and then create
> the graph g2 using g2 <- delete.edges(g1,which(E(g1)$weight<=0.2455)) if
> 0.2455 was the 90th percent edge weight returned by the quantile function.
You were bitten by the 0-based indexing of igraph 0.5.x and below (igraph 0.6
uses 1-based indexing). Basically, the indices that R returns from which() are
1-based, so you need to subtract 1 from them to convert them to igraph edge
IDs. You need this only if you use igraph 0.5.x or below.
Best,
T.