[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [igraph] Cayley Tree
From: |
Tamas Nepusz |
Subject: |
Re: [igraph] Cayley Tree |
Date: |
Wed, 18 Nov 2009 22:33:45 +0000 |
> 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] 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 <=
- Re: [igraph] Cayley Tree, Marco, 2009/11/18
- Re: [igraph] Cayley Tree, Tamas Nepusz, 2009/11/23
- Re: [igraph] Cayley Tree, Gábor Csárdi, 2009/11/29