igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] Trees generations?


From: Marco
Subject: Re: [igraph] Trees generations?
Date: Mon, 9 Nov 2009 13:52:46 +0100

Hi Tamas,

as said: I was reinventing the wheel: this worked perfectly. Thank you!
Now I have to find the optimal layout to draw the trees with. I am
using not-so-big trees (say: a couple thousands nodes).
Any suggestion?

marco

--
restituiremo il riso ai salici



On Mon, Nov 9, 2009 at 1:02 PM, Tamas Nepusz <address@hidden> wrote:
> 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
>
>
> _______________________________________________
> igraph-help mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/igraph-help
>




reply via email to

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