[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [igraph] Retrieving edges weight

From: Tamas Nepusz
Subject: Re: [igraph] Retrieving edges weight
Date: Sat, 24 Nov 2018 16:21:06 +0100

> but now I cannot retrieve edges weight from the tree. More generally, how do 
> I get an edge attribute from a given graph ? I was expecting Graph interface 
> to have an edges attribute.
> I only have a list of edges (given by a get_edgelist() method above and this 
> returns tuple, not an edge object).
Internally, the edges are identified by integers from 0 to M-1, where
M is the number of edges. If you only have the two endpoints of an
edge, you need to use get_eid() to get the numeric ID, then you can
use that to index into g.es["weight"]:

>>> edge_indices = [g.get_eid(*pair) for pair in tree.get_edgelist()]
>>> print(g.es[edge_indices]["weight"])
[1, 1, 2, 3, 2]


reply via email to

[Prev in Thread] Current Thread [Next in Thread]