igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] Shortest path


From: Tamas Nepusz
Subject: Re: [igraph] Shortest path
Date: Wed, 24 Dec 2014 01:44:34 +0100
User-agent: Mutt/1.5.23 (2014-03-12)

>  I would like to color the shortest path differently than the rest of my
> network.  I scoured the documentation and found no way to select individual
> edges.  Changing the attributes of all edges and vertices is well
> documented.  There's a code snippet on-line for R
> E(g, path=pa)$color <- 'red'
> 
> which doesn't seem to translate to python.
Changing the attribute of an individual edge is done by indexing g.es first and
then using the standard dict-like syntax to set the attribute; e.g.:

g.es[2]["color"] = "red"

It also works with multiple edges:

edges = 2, 3, 4

g.es[edges]["color"] = "red"

If you have a path with the vertex IDs, you can get the corresponding edge IDs
with:

vertices = [2, 3, 4, 42]
edges = g.get_eids(path=vertices)
g.es[edges]["color"] = "red"

All the best,
-- 
T.



reply via email to

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