[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: |
Alex Upton |
Subject: |
Re: [igraph] Creating new graph from existing graph with only top 10 percent of edges |
Date: |
Fri, 6 Jul 2012 01:32:45 +0100 |
Hi Tamás (and others),
Thanks for your response. I am using igraph in R, and have tried implementing
your suggestions, but to no avail. The subgraph.edges function does not seem to
exist in the version of igraph that I am using, so I tried a different
approach.
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. However, this
does not seem to work correctly, as when I then pass the edge weights of g2
using wt <- E(g2)$weights, and then check the smallest edge value using min(wt)
it returns an edge with a weight much less than 0.2455. Have you got any
suggestions how I could fix this?
Cheers,
Alex
Hi Alex,
You haven't specified whether you are working with igraph from C, R or Python,
so I'll only give you a few pointers first:
1. Retrieve all the edge weights and find the indices of the top 10%.
2. Use igraph_subgraph_edges from C, subgraph.edges from R or
Graph.subgraph_edges() from Python to extract the subgraph that contains the
selected edges only. Set the delete_vertices argument to false to keep all the
vertices even if some of them are not incident on the selected edges.
Best,
--
T.
On Thursday, 5 July 2012 at 19:12, Alex Upton wrote:
>
>
> Hi all,
>
> I have a query that hopefully will be easy to resolve. I have a weighted
> graph, g1, that has various edge weights. What I would like to do is create
> another graph, let's call it g2, that contains only the top 10 percent of the
> edges in g1, i.e. the 10 percent of edges in g1 with the highest weight. How
> would I go about doing this? Any help is gratefully appreciated.
>
>
> Regards,
>
> Alex
Alex Upton, BEng, MRes, PG Cert Business Administration
PhD Researcher Biomedical Informatics, Signals and Systems
School of Electronic, Electrical and Computer Engineering,
College of Engineering and Physical Sciences, University of Birmingham
Edgbaston, Birmingham, B15 2TT, United Kingdom
Fax: +44 121 4144291 (school general office)
Email: address@hidden
Personal Web: http://postgrad.eee.bham.ac.uk/uptona/
--------------------------------------------------------------------------