constant time generation of trees with specified diameter
DESCRIPTION
Constant Time Generation of Trees with Specified Diameter. Shin-ichi Nakano Takeaki Uno Gunma University, National Institute of Japan Informatics, Japan 21/Jun/2004 WG2004. Background. Recently, Enumeration algorithms are interesting - PowerPoint PPT PresentationTRANSCRIPT
Constant Time Generation of Trees Constant Time Generation of Trees with Specified Diameterwith Specified Diameter
Shin-ichi NakanoShin-ichi Nakano Takeaki Uno Takeaki Uno Gunma University, National Institute of
Japan Informatics, Japan
21/Jun/2004 WG2004
BackgroundBackground
Recently, Enumeration algorithms are interestingRecently, Enumeration algorithms are interesting
・・ There are still many unsolved nice problems
(unlike to ordinal discrete algorithms)
・・ Recent increase of computer power makes
many enumeration problems practically solvable.
⇒⇒ many applications have been appearing,
such as, genome, data mining, clustering, so on.
Problem & ResultProblem & Result
Problem:Problem: enumerate all (un-rooted) trees of nn vertices and diameter kk without duplications (no two isomorphic trees are allowed)
Result:Result: an algorithm with
time complexitytime complexity: : constant constant for each (delaydelay:: constantconstant)
space complexityspace complexity: : O(n)O(n)
(delay:delay: max. time between two consecutive outputs)
Existing StudiesExisting StudiesR.A.Wright,B.Richmond,A.Odlyzko and B.D.McKay 1986
time complexitytime complexity: : constant for each
space complexityspace complexity: : O(n)
delaydelay:: polynomialpolynomial
Our advantages:Our advantages:
・・ constant delay
・・ simple algorithm
・・ specified diameter
・・ incremental enumeration is possible
(enumerate trees at most nn vertices, s.t. a tree of mm vertices is outputted after outputting its subtree of m-1m-1 vertices )
← motivated by data mining
Recent Related ResearchesRecent Related Researches
Nakano '99
Nakano, Uno '03Arimura, Asai, '01, etc.
Arimura, Asai, Nakano, Uno '03, etc
Kawano, Nakano '04
Nakano, Uno '04
rooted ordered trees
Rooted ordered treeswith labels rooted (un-ordered) trees
Rooted (un-ordered) treeswith labels
trees with labels
(un-rooted, un-(un-rooted, un-ordered)ordered) trees oftrees of specified diameter specified diameter
terminal fixed two-connected series-parallel graphs
this work
DifficultyDifficulty
・・ Enumeration problems are often solved by
backtracking algorithmbacktracking algorithm
Ex. Ex.
- - start from a singlesingle vertex,
- - add a vertex to be a leaf one-by-one,
until the tree becomes n vertices and diameter k,
- - backtrack, and add a leaf at another position.
⇒⇒ Naturally, there occur
so many duplications
Enumerate Rooted Ordered TreesEnumerate Rooted Ordered Trees
・・ Based on backtracking algorithms
・・ Add a vertex to be the rightmost leaf
((Add a vertex at the right side of the rightmost path))
⇒ ⇒ enumerated in constant time for each
⇒ ⇒ no duplication occurs
Enumerate Rooted (Enumerate Rooted (un-orderedun-ordered) Trees) Trees
・・ Many duplications occur, in the same way as ordered trees
← ← because, many non-isomorphic rooted ordered trees
correspond to the same rooted (un-ordered) tree.
・・ Define the canonical form among these isomorphic ordered trees
・・ Enumerate only rooted ordered trees of canonical forms
Depth SequenceDepth Sequence
Depth sequence Depth sequence (of ordered tree) :
pre-order of the left-first depth-first search
(visiting order of depth-first search:
starting from the root, visiting children from left to right)
・ Two rooted ordered trees are isomorphic
⇔ having the same depth sequence
0,1,2,3,3,2,2,1,2,3 0,1,2,2,3,3,2,1,2,3 0,1,2,3,1,2,3,3,2,2
Left Heavy EmbeddingLeft Heavy Embedding
・ ・ We obtain many ordered trees from a rooted (un-ordered) tree,
by giving orders of children to each vertex
Left heavy embeddingLeft heavy embedding: lexicographically maximizer of depth sequence among them
(obtained by sorting children by lexicographic order of depth sequences of their subtrees)
・・ Two rooted (un-ordered) trees are isomorphic
⇔⇔ left heavy embeddings are isomorphic, in terms of ordered trees
0,1,2,3,3,2,2,1,2,3 0,1,2,2,3,3,2,1,2,3 0,1,2,3,1,2,3,3,2,2
Parent of Left Heavy Embedding Parent of Left Heavy Embedding
Parent of left-heavy embedding of m m vertices :
removal of the rightmost leaf
⇒⇒ parent is also a left-heavy embedding of m-1m-1 vertices
0,1,2,3,3,2,1,2,3,2,11 0,1,2,3,3,2,1,2,3,22 0,1,2,3,3,2,1,2,33
T parent of T
parent ofparent
Family Tree of Rooted Family Tree of Rooted (un-ordered) Trees Trees
Parent-child relation of left-heavy embeddings
Child of Left Heavy Embedding Child of Left Heavy Embedding
・・ Any child of left-heavy embedding is obtained by adding a vertex to be the rightmost leaf, at the level no lower than copy copy depthdepth
Copy depth Copy depth : deepest level s.t. left-heavy condition is not violated
by adding the rightmost leaf on the level.
・ ・ Copy depth can be updated in constant time
⇒⇒ Enumeration can be done in constant time for eachT parent
of Tparent ofparent
Enumerate Un-rooted TreesEnumerate Un-rooted Trees
・・ An un-rooted tree has no root, so depth sequence is not defined
⇒ ⇒ define the root by its centercenter(s)
CenterCenter: vertex minimizing the distance to the furthest leaf
・・ The diameter is even ⇒⇒ the center is unique
・・ We consider the case of even diameter
Parent of Left Heavy EmbeddingParent of Left Heavy EmbeddingParent of a left-heavy embedding of m m vertices and diameter kk : removal of the rightmost leaf,
removal of the second rightmost leaf if its diameter changes
⇒⇒ Parent is a left-heavy embedding of mm-1-1 vertices and diameter kk
・ ・ Diameter changes ⇒⇒ rightmost leaf ∈∈ leftmost spinespine (longest path)
・ ・ Leftmost spine does not change by removing the leaf
⇒⇒ parent and child shares leftmost spine
⇒⇒ constant time for each tree of at most nn vertices diameter kk
T parent parent ofparent
Family Tree of Family Tree of (Un-rooted) TreesTrees
diameter 4
Generating Only Trees of Generating Only Trees of nn Vertices Vertices
Active leaf: rightmost leaf s.t. not a child of root and
whose removal does not change the diameter
Parent of a left-heavy embedding of nn vertices and diameter k k :
remove active leaf and add a leaf to the root
⇒⇒ also a left-heavy embedding of nn vertices and diameter kk
T parent parent ofparent
Family Tree of Trees of Family Tree of Trees of nn Vertices Vertices
7 verticesdiameter 4
Constant DelayConstant Delay
・ Output before recursive calls in odd levels
Output after recursive calls in even levels
At least one iteration in consecutive three iterations
Recursion structure
Similar algorithm by considering two centers as the single root vertex(the order of children of the root has to be an exception)
Odd DiameterOdd Diameter
・ ・ There are always two centers
ConclusionConclusion
・ Proposed an algorithm for enumerating un-rooted trees of n vertices and diameter k
・ Time complexity is constant for each, and delay is also constant
Future workFuture work ::・ Enumeration of plane trees, plane graphs, and other classes of graphs with simple ideas