igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] Cayley Tree


From: Gábor Csárdi
Subject: Re: [igraph] Cayley Tree
Date: Wed, 18 Nov 2009 23:12:17 +0100

Yep, but the degree of the root node must be the same as for the other
nodes. graph.tree() creates graphs, where the degree of the root is
one less.

It is not too hard to fix this, with something like:

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))
}

Best,
Gabor

On Wed, Nov 18, 2009 at 1:41 PM, Tamas Nepusz <address@hidden> wrote:
> If I understand it right, a k-Cayley tree is simply a tree where each
> non-leaf vertex has degree k. The standard tree generation routine in
> igraph therefore builds a Cayley tree if the number of nodes is set
> appropriately. (See igraph_tree in C, graph.tree in R, Graph.Tree in
> Python).
>
> --
> Tamas
>
> On Wed, Nov 18, 2009 at 12:29:59AM +0100, Marco wrote:
>> Hi all,
>>
>> any ideas on how to implement efficiently a routine to build a Cayley tree?
>>
>> Thanks in advance,
>>
>> marco
>>
>> --
>> restituiremo il riso ai salici
>>
>>
>> _______________________________________________
>> igraph-help mailing list
>> address@hidden
>> http://lists.nongnu.org/mailman/listinfo/igraph-help
>
>
> _______________________________________________
> igraph-help mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/igraph-help
>



-- 
Gabor Csardi <address@hidden>     UNIL DGM




reply via email to

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