[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [igraph] Adding edges from one graph to another
From: |
Tamas Nepusz |
Subject: |
Re: [igraph] Adding edges from one graph to another |
Date: |
Mon, 18 Oct 2010 17:24:48 +0100 |
> If I have a large graph G and a small graph M and a list L of size M (in
> vertices) containing the vertex IDs in G that correspond to each vertex of M,
> do any functions exist to add the edges present in L to G based on the
> mapping L?
There is no function to do that directly -- you have to code that yourself (I
guess). It's only a matter of remapping the edge list. In Python, this boils
down to the following code:
def add_edges_mapped(graph, edgelist, mapping):
mapped_edgelist = [(mapping[source], mapping[target]) for source, target in
edgelist]
graph.add_edges(mapped_edgelist)
--
T.