igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] Shortest path


From: Herb Roseman
Subject: Re: [igraph] Shortest path
Date: Wed, 24 Dec 2014 20:40:22 +0000

Once again thanks for your help.  igraph is an excellent system.  The algorithms for  laying out the networks must be extremely clever and well coded.   Speaking as a hack who programs only occasionally, (this is the first time I used Python.) it is difficult to get through the documentation to deal with problems beyond the basics.  But with your assistance I think I got everything I need.

I'm going to show this to the philosophical world next semester. They have never seen anything like this. If you're interested I'll let you know what happens. 

Again thanks for your help and have a nice holiday.

Herb

On Tue Dec 23 2014 at 7:44:53 PM Tamas Nepusz <address@hidden> wrote:
>  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.

_______________________________________________
igraph-help mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/igraph-help

reply via email to

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