|
From: | Ayushi Dalmia |
Subject: | Re: [igraph] Adjacency List of a Subgraph using iGraph |
Date: | Wed, 30 Dec 2015 19:36:02 +0530 |
> 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.
T.
_______________________________________________
igraph-help mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/igraph-help
[Prev in Thread] | Current Thread | [Next in Thread] |