[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [igraph] Adjacency List of a Subgraph using iGraph
From: |
Tamas Nepusz |
Subject: |
Re: [igraph] Adjacency List of a Subgraph using iGraph |
Date: |
Wed, 30 Dec 2015 14:25:28 +0100 |
> 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.