Class TreeGraphNode

Nodes that form a "tree graph", structured as a tree, with their own node's value, as well as references to either possible child node, where a node can only ever have two children, as there are only ever two reverse values. Also records any possible "terminal sequence state", whether that be that the "orbit distance" has been reached, as an "out of bounds" stop, which is the regularly expected terminal state. Other terminal states possible however include the cycle state and cycle length (end) states.

Constructors

  • Create an instance of TreeGraphNode which will yield its entire sub-tree of all child nodes. This is used internally by itself and the public constructor to pass the cycle checking map, recursively determining subsequent child nodes.

    Parameters

    • nodeValue: bigint

      The value for which to find the tree graph node reversal.

    • maxOrbitDistance: number

      The maximum distance/orbit/branch length to travel.

    • P: bigint

      Modulus used to devide n, iff n is equivalent to (0 mod P).

    • a: bigint

      Factor by which to multiply n.

    • b: bigint

      Value to add to the scaled value of n.

    • cycleCheck: Map<bigint, TreeGraphNode>

      Checks if this node's value already occurred.

    • createManually: boolean

      Create an instance of TreeGraphNode by directly passing it the values required to instantiate, intended to be used in testing by manually creating trees in reverse, by passing expected child nodes to their parents until the entire expected tree is created.

    • terminalSequenceState: null | SequenceState

      The expected sequence state; null, MAX_STOP_OUT_OF_BOUNDS, CYCLE_INIT or CYCLE_LENGTH.

    • preNDivPNode: null | TreeGraphNode

      The expected "Pre N/P" child node.

    • preANplusBNode: null | TreeGraphNode

      The expected "Pre aN+b" child node.

    Returns TreeGraphNode

    the tree graph node and its subtree, computed for the parameters provided.

    Throws

    FailedSaneParameterCheck Thrown if either P or a are 0.

Properties

cycleCheck: Map<bigint, TreeGraphNode>

A map of previous graph nodes which maps instances of TreeGraphNode to themselves, to enable cycle detection.

nodeValue: bigint

The value of this node in the tree.

preANplusBNode: null | TreeGraphNode

The "Pre aN+b" child of this node that is present if it exists and this is not a terminal node.

preNDivPNode: null | TreeGraphNode

The "Pre N/P" child of this node that is always present if this is not a terminal node.

terminalSequenceState: null | SequenceState = null

The terminal state; null if not a terminal node, MAX_STOP_OUT_OF_BOUNDS if the maxOrbitDistance has been reached, CYCLE_LENGTH if the node's value is found to have occured previously, or CYCLE_INIT, retroactively applied when a CYCLE_LENGTH state node is found.

emptyMap: Map<bigint, TreeGraphNode> = ...

Methods

  • Traverse a tree and assign the cycle map manually on all nodes.

    Parameters

    Returns void

  • This will only confirm an equality if the whole subtree of both nodes, including node values, sequence states, and child nodes, checked recursively, are equal. It ignores the cycle checking map, which is purely a utility variable.

    Parameters

    • tgn: null | TreeGraphNode

      The TreeGraphNode with which to compare equality.

    Returns boolean

    true, if the entire sub-trees are equal.

  • Create an instance of TreeGraphNode which will yield its entire sub-tree of all child nodes.

    Parameters

    • nodeValue: bigint

      The value for which to find the tree graph node reversal.

    • maxOrbitDistance: number

      The maximum distance/orbit/branch length to travel.

    • P: bigint

      Modulus used to devide n, iff n is equivalent to (0 mod P).

    • a: bigint

      Factor by which to multiply n.

    • b: bigint

      Value to add to the scaled value of n.

    Returns TreeGraphNode

    the tree graph node and its subtree, computed for the parameters provided.

    Throws

    FailedSaneParameterCheck Thrown if either P or a are 0.

  • This is used internally by itself and the public constructor to pass the cycle checking map, recursively determining subsequent child nodes.

    Parameters

    • nodeValue: bigint

      The value for which to find the tree graph node reversal.

    • terminalSequenceState: null | SequenceState

      The expected sequence state; null, MAX_STOP_OUT_OF_BOUNDS, CYCLE_INIT or CYCLE_LENGTH.

    • preNDivPNode: null | TreeGraphNode

      The expected "Pre N/P" child node.

    • preANplusBNode: null | TreeGraphNode

      The expected "Pre aN+b" child node.

    Returns TreeGraphNode

    the tree graph node and its subtree, where the subtrees are passed in.

    Throws

    FailedSaneParameterCheck Thrown if either P or a are 0.

Generated using TypeDoc