[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [igraph] simplify function
From: |
Tamas Nepusz |
Subject: |
Re: [igraph] simplify function |
Date: |
Wed, 11 Mar 2015 22:02:14 +0100 |
User-agent: |
Mutt/1.5.23 (2014-03-12) |
Hi,
Unfortunately the combine_edges... argument of simplify() can only treat
attributes independently of each other -- the underlying C core is not prepared
for the scenario that you mentioned. However, you could simply use a custom
function that merges the individual attributes into a list, so your collapsed
edges would have lists containing the original values for each edge attribute,
and then you could postprocess the edges one by one.
> Also, please point me to a place where combine_edges is used with a
> custom function in an example.
def combinator(values):
return list(values)
g = Graph([(0,1), (1,2), (1,2), (1,2)])
g.es["weight"] = [1,2,3,4]
g.simplify(combine_edges=combinator)
print(g.get_edgelist())
print(g.es["weight"])
--
T.