igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] how to select eid on the basis of an edge attribute


From: Tamas Nepusz
Subject: Re: [igraph] how to select eid on the basis of an edge attribute
Date: Wed, 21 Jan 2009 10:07:54 +0000

> is it possible to tell igraph to select the eid of the RED link between 1 and 
> 2?
Well, the C core has igraph_get_eids which returns all the edge IDs
between two vertices, but it's not in the Python interface yet
(*blushes*). As a workaround, you could use the following:

def get_eids(graph, v1, v2):
  eids = set(g.adjacent(v1, type="out"))
  eids.intersection_update(set(g.adjacent(v2, type="in")))
  return list(eids)

Now, you can call get_eids(your_graph, 1, 2) to get all the edge IDs
between vertex 1 and 2. Your original question will then be solved as
follows:

for eid in get_eids(your_graph, 1, 2):
  if g.es[eid]["color"] == "red":
    print eid      # or do whatever you want

-- 
Tamas






reply via email to

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