com.eharmony.aloha.models.tree

Tree

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
Learn more about member selection
Visibility
  1. Public
  2. All

Value Members

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

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

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

    Definition Classes
    AnyRef
  5. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  6. def adjacenyListStructure(root: Int, parents: Seq[Int]): Map[Int, List[Int]]

    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.

  7. 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

    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

    returns

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

    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

  9. 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

    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

  10. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  11. def clone(): AnyRef

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

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

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

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

    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

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

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

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

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

    Definition Classes
    AnyRef
  20. final def notify(): Unit

    Definition Classes
    AnyRef
  21. final def notifyAll(): Unit

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

    Definition Classes
    AnyRef
  23. def toString(): String

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

    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.

  25. final def wait(): Unit

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

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

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from AnyRef

Inherited from Any

Ungrouped