next | previous | forward | backward | up | top | index | toc | Macaulay2 website
PhylogeneticTrees :: digraph(LeafTree,List)

digraph(LeafTree,List) -- convert a LeafTree to a Digraph

Synopsis

Description

A rooted tree can be represented by an object of class LeafTree and a choice of vertex to be the root. This function converts such a representation of a rooted tree into an object of class Digraph with edges oriented away from the root.

The internal vertices of an object of class LeafTree are not named, so each vertex is specified by the partition of the set of leaves formed by removing the vertex. Each partition is given as a list of sets. This is also how the root vertex should be passed to the function.

i1 : T = leafTree(4,{{0,1}})

o1 = {{0, 1, 2, 3}, {set {0, 1}, set {0}, set {1}, set {2}, set {3}}}

o1 : LeafTree
i2 : r = {set{0,1}, set{2}, set{3}}

o2 = {set {0, 1}, set {2}, set {3}}

o2 : List
i3 : D = digraph(T,r)

o3 = Digraph{set {set {0, 1, 2}} => {}                                                                                           }
             set {set {0, 1, 3}} => {}
             set {set {0, 1}, set {2}, set {3}} => {set {set {0}, set {1}, set {2, 3}}, set {set {0, 1, 2}}, set {set {0, 1, 3}}}
             set {set {0, 2, 3}} => {}
             set {set {0}, set {1}, set {2, 3}} => {set {set {1, 2, 3}}, set {set {0, 2, 3}}}
             set {set {1, 2, 3}} => {}

o3 : Digraph
i4 : adjacencyMatrix D

o4 = | 0 1 1 0 0 0 |
     | 0 0 0 0 0 0 |
     | 0 0 0 0 0 0 |
     | 1 0 0 0 1 1 |
     | 0 0 0 0 0 0 |
     | 0 0 0 0 0 0 |

              6        6
o4 : Matrix ZZ  <--- ZZ