igraph-help
[Top][All Lists]
Advanced

[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
>




reply via email to

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