Skip to content

Instantly share code, notes, and snippets.

@maxbeutel
Created September 15, 2017 02:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maxbeutel/fd1982e61875dddf7e8e13946914f4c8 to your computer and use it in GitHub Desktop.
Save maxbeutel/fd1982e61875dddf7e8e13946914f4c8 to your computer and use it in GitHub Desktop.
plotbintree.r
require(igraph)
require(expm)
G <- graph.tree(n=7,children=2)
V(G)$name <- LETTERS[1:length(V(G))]
co <- layout.reingold.tilford(G, params=list(root=1))
plot(G, layout=co)
tmp <- c(
0, 1, 1, 0, 0, 0, 0,
1, 0, 0, 1, 1, 0, 0,
1, 0, 0, 0, 0, 1, 1,
0, 1, 0, 0, 0, 0, 0,
0, 1, 0, 0, 0, 0, 0,
0, 0, 1, 0, 0, 0, 0,
0, 0, 1, 0, 0, 0, 0
)
A <- matrix(tmp, 7, 7)
A %^% 2
@maxbeutel
Copy link
Author

maxbeutel commented Sep 15, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment