[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [igraph] graph operations
From: |
Tamas Nepusz |
Subject: |
Re: [igraph] graph operations |
Date: |
Thu, 5 Mar 2015 22:51:48 +0100 |
User-agent: |
Mutt/1.5.23 (2014-03-12) |
Hi,
> 1) I am looking for the definitions of graph operations such as
> intersection, union, etc., but could not find them in the API
> documentation. Is there any place where I can find their definitions?
In cases when the documentation of the Python interface is not detailed enough,
you can try to find the corresponding functions in the documentation of the
C core:
http://igraph.org/c/doc/igraph-Operators.html
Although, to be honest, it seems that the documentation of the C core is not
too verbose either. Let me know if you need more information about these
operators.
> 2) I tried to glean out the current state of augmenting attributes to
> edges when adding them through add_edges() from the mailing list
> archives, but could not. I understand this is possible when using
> add_edge(), but it is clear from the authors' replies that add_edges()
> is much more faster.
Unfortunately this is not supported directly by add_edges() yet, but you can
create a helper function like:
def better_add_edges(graph, es, **kwds):
m = graph.ecount()
graph.add_edges(es)
for attr_name, values in kwds.iteritems():
graph.es[m:][attr_name] = values
(If you use igraph from Python 3.x, use kwds.items() instead of
kwds.iteritems())
Then you can do something like this:
better_add_edges(graph, [(2,3), (2,4)], weight=[21,42], color=["red", "green"])
Actually, this is probably what the "real" imlpementation of add_edges() would
do if it weren't for me being too lazy to add it in the first place ;)
Best,
Tamas