[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [igraph] Adjacency List of a Subgraph using iGraph

From: Ayushi Dalmia
Subject: Re: [igraph] Adjacency List of a Subgraph using iGraph
Date: Wed, 30 Dec 2015 19:36:02 +0530

Thanks! This works. :)

On Wed, Dec 30, 2015 at 6:55 PM, Tamas Nepusz <address@hidden> wrote:
> I want to get the adjacency list of a subgraph. I am obtaining the subgraph
> of a graph by passing a set of vertices. Using the adjacency get_adjlist
> method I can get the adjacency list for this subgraph.  However, the
> subgraph now uses a completely different set of ids. How can I get the
> original mapping?
You don't need to do that; you can simply get the adjacency list of a
subgraph by calling neighbors() repeatedly:

adjlist = [g.neighbors(v) for v in vs]

But if you really need the mapping back to the original vertex IDs,
create a vertex attribute named "original_id" before taking the
subgraph, and then use this vertex attribute from the subgraph to find
the original ID of any vertex.


igraph-help mailing list

reply via email to

[Prev in Thread] Current Thread [Next in Thread]