Mon
Mon

Reputation: 281

How can I keep or make a new network from top 5% weighted edges?

I am trying to reduce a large network to only the top 5% of its edges, determined by edge weight.

I usually trim my networks by declaring a cut-off point for edge weight like so:

g2 <- delete.edges(g1, E(g1) [weight<20])

Is there a way to delete the lower 95% of the edges according to weight, something like:

g2 <- delete.edges(g1, E(g1) [weight outside the top 5%])

Or to extract the top 5% otherwise?

Upvotes: 2

Views: 546

Answers (1)

IRTFM
IRTFM

Reputation: 263352

There was no example posted and only minimal code offered, and I am worried that just supplying a "weight" may hide the use of attach. Perhaps:

g2 <- delete.edges(g1, E(g1) [ weight < quantile(weight, 0.95) ])

Upvotes: 2

Related Questions