igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] how to iterate a vertex seq to find neighbors


From: Tamas Nepusz
Subject: Re: [igraph] how to iterate a vertex seq to find neighbors
Date: Tue, 23 Dec 2008 18:45:25 +0100

I am a bit confused... "weight" is an attribute of the edge, not of
the vertex...
Sorry, I misunderstood your question. You can use g.get_eid(mynode, myneighbor) to get the ID of an edge connecting mynode and myneighbour:

g.es[g.get_eid(mynode, myneighbor)]["weight"]

Alternatively, you can get all the weights and the node-neighbour pairs in advance into a dict and then use that dict to look up the weight:

weight_dict = dict(zip(g.get_edgelist(), g.es["weight"]))

weight_dict[mynode, myneighbour] will then give you the weight of the corresponding edge.

--
T.





reply via email to

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