[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [igraph] Cayley Tree
From: |
Marco |
Subject: |
Re: [igraph] Cayley Tree |
Date: |
Wed, 18 Nov 2009 23:44:27 +0100 |
Hey,
thank you.
That was very quick, I didn't have the time to test it myself.
Really, thank you. I will test the code, probably tomorrow morning,
and if everything checks out, it's good to be added to igraph library
;)
I am not sure about this:
if depth == 1:
return Graph.Tree(4, 3)
but will look into it!
Thank again,
marco
--
restituiremo il riso ai salici
On Wed, Nov 18, 2009 at 11:33 PM, Tamas Nepusz <address@hidden> wrote:
>> cayley.tree <- function(coord, depth) {
>> if (depth==0) return(graph.empty(1))
>> if (depth==1) return(graph.tree(4, 3, mode="undir"))
>> d <- coord-1
>> n1 <- (d^(depth+1)-1) / (d-1)
>> n2 <- (d^depth -1)/ (d-1)
>> g <- graph.tree(n1, d, mode="undir") %du% graph.tree(n2, d, mode="undir")
>> add.edges(g, c(0, n1))
>> }
> A similar function in Python (untested):
>
> def cayley_tree(coord, depth):
> if depth == 0:
> return Graph(1)
> if depth == 1:
> return Graph.Tree(4, 3)
> d = coord - 1
> n1, n2 = d ** (depth+1) - 1, d ** depth - 1
> n1 /= d-1
> n2 /= d-1
> return Graph.Tree(n1, d) + Graph.Tree(n2, d) + (0, n1)
>
> --
> Tamas
>
>
>
> _______________________________________________
> igraph-help mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/igraph-help
>
- [igraph] Cayley Tree, Marco, 2009/11/17
- Re: [igraph] Cayley Tree, Tamas Nepusz, 2009/11/18
- Re: [igraph] Cayley Tree, Marco, 2009/11/18
- Re: [igraph] Cayley Tree, Gábor Csárdi, 2009/11/18
- Re: [igraph] Cayley Tree, Tamas Nepusz, 2009/11/18
- Re: [igraph] Cayley Tree,
Marco <=
- Re: [igraph] Cayley Tree, Tamas Nepusz, 2009/11/23
- Re: [igraph] Cayley Tree, Gábor Csárdi, 2009/11/29