[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [igraph] Trees generations?
From: |
Tamas Nepusz |
Subject: |
Re: [igraph] Trees generations? |
Date: |
Mon, 9 Nov 2009 12:02:18 +0000 |
User-agent: |
Mutt/1.5.17 (2007-11-01) |
Hi Marco,
> The question is: if I plot the graph is there an "easy" way to color
> the different generations' node?
You can conduct a breadth first search from the root node and color each
node according to the distance:
>>> colors = ["red", "green", "blue", "yellow", "white", "black"]
>>> tree = Graph.Tree(n, d)
>>> for vertex, distance, _ in tree.bfsiter(0, advanced=True):
... vertex["color"] = colors[distance]
This should work for at most six levels -- add more colors to the
"colors" list if you need. Alternatively, you can use a palette (e.g.,
GradientPalette) and numeric color indices.
--
Tamas