Options
All
  • Public
  • Public/Protected
  • All
Menu

Class BinaryTreeViz

Extremely similar to MultiTreeViz but for binary trees only. Documentation is the same for most methods.

Hierarchy

Index

Constructors

constructor

  • new BinaryTreeViz(width: number, height: number): BinaryTreeViz
  • Initialize binary tree with dimensions.

    Parameters

    • width: number

      (px)

    • height: number

      (px)

    Returns BinaryTreeViz

Properties

baseTree

baseTree: MultiTreeViz

containerDict

containerDict: default<NodeViz, NodeChildrenContainer>

Stores current node id along with the visualization structure of its children

edgeDict

edgeDict: default<string, EdgeViz>

Stores edges that are not regular (eg. have some highlight or label) by string source.id + "_" + target.id

id

id: string

dom id for <g> element

maxHeight

maxHeight: number

maxWidth

maxWidth: number

pseudo

pseudo: Pseudocode

root

root: NodeViz

Root NodeViz of the tree

timeline

timeline: any[]

Array of animation states through time

transitionDuration

transitionDuration: number

Methods

Private addBinaryChild

  • Adds a child node to the binary tree.

    Parameters

    • parent: NodeViz

      node

    • left: boolean

      true if child added should be the left child

    Returns NodeViz

    child node

addChild

  • Should NOT be used for binary trees. See addBinaryChild. To avoid errors it is identical to addLeft.

    Parameters

    Returns NodeViz

addLeft

  • Add a left child to parent node.

    Parameters

    Returns NodeViz

    left child node

addRight

  • Add right child to parent node.

    Parameters

    Returns NodeViz

    right child node

addRoot

  • Adds a root to the binary tree.

    Returns NodeViz

    root node

allNodes

  • Returns NodeViz[]

    a list of all nodes in the binary tree.

getEdgeByNodes

  • Gets an EdgeViz object to manipulate an edge. If no object existed before it create a new one. Otherwise it returns the old one.

    Parameters

    Returns EdgeViz

    a new nodeViz object to manipulate the edge

Protected getElement

  • getElement(): Selection<any, any, any, any>
  • Returns the d3 selection that represents the structure. Probably a <g> element

    Returns Selection<any, any, any, any>

getNodeById

  • getNodeById(nId: string): NodeViz
  • ONLY MADE FOR TESTING PURPOSES. Returns node with id == nId`

    Parameters

    • nId: string

    Returns NodeViz

getParent

  • Returns the parent of node or null if node is the root.

    Parameters

    Returns NodeViz

getState

  • getState(): any
  • Returns a copy of the structures current state.

    Returns any

moveSubtree

  • Puts the subtree rooted at source in the location of target. Deleting the subtree of target.

    pre

    Precondition: target must not be a descendant of source.

    Parameters

    Returns void

pushAndTransition

  • pushAndTransition(): void
  • Pushes the current state onto the timeline and transitions to it.

    Returns void

pushState

  • pushState(): void
  • Adds the current state to the timeline.

    Returns void

removeNode

  • Removes node from the structure

    Parameters

    Returns void

setMaxHeight

  • setMaxHeight(n: number): void
  • Parameters

    • n: number

    Returns void

setMaxHeightWidth

  • setMaxHeightWidth(n: number): void

transition

  • transition(state: any): void
  • See the transition function of TreeViz.

    Parameters

    • state: any

    Returns void

transplant

  • Swaps the position of 2 subtrees. If one node is a descendant of the other then the subtree of the ancestor will be removed and replaced with just the subtree of the descendant.

    Parameters

    Returns void

wipeOut

  • wipeOut(): void
  • Clear the binary tree of all nodes.

    Returns void

Generated using TypeDoc