Object/Trait

com.eharmony.aloha.models.tree

Tree

Related Docs: trait Tree | package tree

Permalink

object Tree

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Tree
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. def adjacenyListStructure(root: Int, parents: Seq[Int]): Map[Int, List[Int]]

    Permalink

    Get an adjacency list structure.

    Get an adjacency list structure.

    root

    the index of the root node in the parents list

    parents

    parents(i) refers to the node id of the parent of i. For the root node, parents(i) == i. Since there is only one root to a tree, there should only be one index i such that parents(i) == i.

    returns

    a map-based adjacency list structure where keys represent parents, values are child lists.

  5. def apply[A, C[_] <: Iterable[_], TreeImpl <: Tree[_, C, _]](nodes: Seq[A], root: (Seq[A]) ⇒ Int, getId: (A) ⇒ Int, childrenIds: (A) ⇒ Seq[Int], builder: (A, Seq[A], Seq[TreeImpl]) ⇒ TreeImpl): TreeImpl

    Permalink

    A

    type of nodes

    C

    type of collection for children

    TreeImpl

    the implementation of the tree

    nodes

    a list of nodes.

    root

    index in nodes of the root node.

    getId

    a function taking a node that returns an ID

    childrenIds

    a function taking a node and a that returns ID for it children

    builder

    a builder function

  6. def apply[A, C[_] <: Iterable[_], TreeImpl <: Tree[_, C, _]](nodes: Seq[A], parents: Seq[Int], builder: (A, Seq[A], Seq[TreeImpl]) ⇒ TreeImpl): TreeImpl

    Permalink

    Build a tree from a sequence of nodes in some raw form with a parent list.

    Build a tree from a sequence of nodes in some raw form with a parent list.

    This is useful when it is difficult to actually build the tree from the bottom up. This method can efficiently build a tree from the bottom up given a tree in a tabular format. O(n) time and O(n) auxiliary space.

    For a binary search tree with three nodes, we may want to do something like the following:

    scala> case class StringTree(value: String, subtrees: Seq[StringTree]) extends Tree[String, StringTree]
    defined class StringTree
    
    scala> val f = (v: String, c: Seq[String], ch: Seq[StringTree]) => StringTree(v, ch)
    f: (String, Seq[String], Seq[StringTree]) => StringTree = <function3>
    
    scala> Tree(Seq("zero", "one", "two"), Seq(1,1,1), f)
    res0: StringTree = StringTree(one,List(StringTree(zero,List()), StringTree(two,List())))
    A

    the value type of the tree

    TreeImpl

    the tree representation

    nodes

    a sequence of nodes in raw form

    parents

    parents(i) refers to the node id of the parent of i. For the root node, parents(i) == i. Since there is only one root to a tree, there should only be one index i such that parents(i) == i.

    builder

    a function that builds a tree given a node in its raw form and its children in raw form and tree form.

    returns

    a tree of type TreeImpl

  7. def apply[A, C[_] <: Iterable[_], TreeImpl <: Tree[_, C, _]](nodes: Seq[A], childMap: Map[Int, Seq[Int]], rootId: Int, builder: (A, Seq[A], Seq[TreeImpl]) ⇒ TreeImpl): TreeImpl

    Permalink

    Build a tree from a sequence of nodes in some raw form with an adjacency list.

    Build a tree from a sequence of nodes in some raw form with an adjacency list.

    This is useful when it is difficult to actually build the tree from the bottom up. This method can efficiently build a tree from the bottom up given a tree in a tabular format. O(n) time and O(n) auxiliary space.

    For a binary search tree with three nodes, we may want to do something like the following:

    scala> case class StringTree(value: String, subtrees: Seq[StringTree]) extends Tree[String, StringTree]
    defined class StringTree
    
    scala> val f = (v: String, c: Seq[String], ch: Seq[StringTree]) => StringTree(v, ch)
    f: (String, Seq[String], Seq[StringTree]) => StringTree = <function3>
    
    scala> Tree(Seq("zero", "one", "two"), Map(1 -> List(0,2)), 1, f)
    res0: StringTree = StringTree(one,List(StringTree(zero,List()), StringTree(two,List())))
    A

    the value type of the tree

    C

    the container type of the descendants in the tree representation

    TreeImpl

    the tree representation

    nodes

    a sequence of nodes in raw form

    childMap

    an adjacency list

    rootId

    the index of the root in the nodes parameter

    builder

    a function that builds a tree given a node in its raw form and its children in raw form and tree form.

    returns

    a tree of type TreeImpl

  8. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  9. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  10. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  11. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  12. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  13. def findRoot(parents: Seq[Int]): Option[Int]

    Permalink

    Determine the root node.

    Determine the root node.

    parents

    parents(i) refers to the node id of the parent of i. For the root node, parents(i) == i. Since there is only one root to a tree, there should only be one index i such that parents(i) == i.

    returns

    Some(i) if there exists an i such that i == parents(i); otherwise, None

  14. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  15. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  16. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  17. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  18. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  19. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  20. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  21. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  22. def topologicalSort(root: Int, childMap: Map[Int, Seq[Int]], numNodes: Int): Seq[Int]

    Permalink

    Determine the topological sort order where the root of the tree is visited last.

    Determine the topological sort order where the root of the tree is visited last.

    root

    the tree root

    childMap

    a map-based adjacency list structure where keys represent parents, values are child lists.

    numNodes

    the number of nodes in the tree

    returns

    zero-based order where i is the node and a(i) is the order to visit the node.

  23. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  24. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  25. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from AnyRef

Inherited from Any

Ungrouped