[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [igraph] threshold
From: |
Harun Pirim |
Subject: |
RE: [igraph] threshold |
Date: |
Tue, 30 Mar 2010 10:08:48 -0500 |
Thank you very much,
Another question arises about connectivity.
How can I guarantee connectivity for this binary graph, in other words use
determine a threshold optimizing connectivity, strongest 0.2% edges (if
violates connectivity then less stronger edge is chosen) in R?
-----Original Message-----
From: address@hidden
[mailto:address@hidden On Behalf Of
Gábor Csárdi
Sent: Tuesday, March 30, 2010 2:59 AM
To: Help for igraph users
Subject: Re: [igraph] threshold
On Sun, Mar 28, 2010 at 4:30 PM, Tamas Nepusz <address@hidden> wrote:
> Hi,
>
>> Is there a direct way in iGraph to calculate a threshold that will retain
let's say 2% of the strongest weighted edges and convert a weighted graph to
a binary graph using this threshold ?
> No, since it is only a few lines of code using either the R or the Python
interface. In Python, you can do something like this:
>
> weights = sorted(g.es["weight"], reverse=True)
> threshold = weights[len(weights) * 0.02]
> g.delete_edges(g.es.select(weight_lt = threshold))
> del g.es["weight"]
>
> --
> Tamas
[...]
The same in R:
weights <- sort(E(g)$weight, decreasing=TRUE)
threshold <- weights[length(weights) * 0.02]
g2 <- delete.edges(g, which(E(g)$weight < threshold)-1)
g2 <- remove.edge.attribute(g, "weight")
Gabor
--
Gabor Csardi <address@hidden> UNIL DGM
_______________________________________________
igraph-help mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/igraph-help