Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Node

Represents a node with one or more variables in a Bayesian network.

Note that node names must be unique per network, and are case sensitive.

To specify a distribution for a node, see the {@link com.bayesserver.Node#getDistribution} property.

To add a directed link between two nodes, it must be added through the {@link com.bayesserver.Network#getLinks Network.Links} property.

see

com.bayesserver.Network

see

com.bayesserver.Link

Hierarchy

  • Node

Index

Constructors

constructor

  • Initializes a new instance of the {@link com.bayesserver.Node} class, with no variables, and no name.

    Returns Node

  • Initializes a new instance of the {@link com.bayesserver.Node} class with a specified {@link com.bayesserver.Variable} and assigns the name of the variable to the node.

    Parameters

    • variable: Variable

      A single variable for the node.

    Returns Node

  • Initializes a new instance of the {@link com.bayesserver.Node} class with the specified [name]. A {@link com.bayesserver.Variable} is automatically created for the node and assigned the same name as the node with the {@link com.bayesserver.VariableValueType} specified.

    Parameters

    • name: string

      The name to give the node and variable, which can be null or empty.

    • valueType: VariableValueType

      The {@link com.bayesserver.VariableValueType} of the node variable, e.g. discrete or continuous.

    • kind: VariableKind

      The kind of variable, e.g. Probability (standard), Decision or Utility.

    Returns Node

  • Initializes a new instance of the {@link com.bayesserver.Node} class with the specified [name]. A {@link com.bayesserver.Variable} is automatically created for the node and assigned the same name as the node with the {@link com.bayesserver.VariableValueType} specified.

    Parameters

    • name: string

      The name to give the node and variable, which can be null or empty.

    • valueType: VariableValueType

      The {@link com.bayesserver.VariableValueType} of the node variable, e.g. discrete or continuous.

    Returns Node

  • Initializes a new instance of the {@link com.bayesserver.Node} class with the specified [name] and automatically adds a discrete {@link com.bayesserver.Variable} with the number of states specified in [states].

    exception

    RangeError Raised when the [states] parameter is less than zero.

    Parameters

    • name: string

      The name to give the node and variable, which can be null or empty.

    • states: number

      The number of states to add to the automatically created {@link com.bayesserver.Variable}. States will be given default names.

    Returns Node

  • Initializes a new instance of the {@link com.bayesserver.Node} class, with the name of the node, automatically creating an associated discrete {@link com.bayesserver.Variable} and adds the states specified in [states] to that variable.

    exception

    ReferenceError Raised when [states] is null.

    Parameters

    • name: string

      The name to give the node and variable, which can be null or empty.

    • states: string[]

      The number of states to add to the automatically created {@link com.bayesserver.Variable}. States will be given default names.

    Returns Node

  • Initializes a new instance of the {@link com.bayesserver.Node} class, with the name of the node, automatically creating an associated discrete {@link com.bayesserver.Variable} and adds the states specified in [states] to that variable.

    exception

    ReferenceError Raised when [states] is null.

    Parameters

    • name: string

      The name to give the node and variable, which can be null or empty.

    • states: State[]

      The number of states to add to the automatically created {@link com.bayesserver.Variable}. States will be given default names.

    Returns Node

  • Initializes a new instance of the {@link com.bayesserver.Node} class with a specified name and a number of variables.

    Parameters

    • name: string

      The name to give the node and variable, which can be null or empty.

    • variables: Variable[]

      The variable(s) represented by the node.

    Returns Node

Accessors

bounds

  • Gets the size and location of the node.

    Returns Bounds

    The size and location of the node.

  • Sets the size and location of the node.

    Parameters

    • value: Bounds

      The size and location of the node.

    Returns void

    The size and location of the node.

customProperties

  • Gets custom properties associated with this instance.

    Custom properties allow storage of custom information, which will be saved with the network.

    Returns CustomPropertyCollection

description

  • get description(): string
  • set description(value: string): void
  • An optional description for the node.

    Returns string

  • An optional description for the node.

    Parameters

    • value: string

    Returns void

distribution

  • Returns the distribution currently associated with the {@link com.bayesserver.Node}. The distribution cannot be modified when it is assigned to a node. It is also automatically set to null, when certain structural changes occur (see remarks).

    If a structural change occurs to the network that invalidates the current distribution, it is automatically set to null. This occurs in the following situations:States are added or removed from the node.States are added or removed from one of the node's parents.The {@link com.bayesserver.Node#getLinksIn} collection changes. I.e. adding or removing a parent node. Note that if a node is removed from a network, all of its links are automatically removed also.

    exception

    Error Raised when the distribution is invalid.

    Returns IDistribution

  • Returns the distribution currently associated with the {@link com.bayesserver.Node}. The distribution cannot be modified when it is assigned to a node. It is also automatically set to null, when certain structural changes occur (see remarks).

    If a structural change occurs to the network that invalidates the current distribution, it is automatically set to null. This occurs in the following situations:States are added or removed from the node.States are added or removed from one of the node's parents.The {@link com.bayesserver.Node#getLinksIn} collection changes. I.e. adding or removing a parent node. Note that if a node is removed from a network, all of its links are automatically removed also.

    exception

    Error Raised when the distribution is invalid.

    Parameters

    Returns void

distributionOptions

  • Options that apply to all distributions of this instance.

    Returns NodeDistributionOptions

distributions

  • Returns the distributions associated with this instance with NodeDistributionKind = Probability. Some node types such as temporal nodes can have more than one distribution assigned to them.

    Returns NodeDistributions

groups

index

  • get index(): number
  • The Index of this instance in the collection of nodes belonging to a network, or -1 if the node does not belong to a network.

    Returns number

links

  • Collection of both incoming and outgoing links (parent and child nodes).

    Returns NodeLinkCollection

linksIn

  • Collection of incoming links (linking to parent nodes).

    Returns NodeLinkCollection

linksOut

  • Collection of outgoing links (linking to child nodes).

    Returns NodeLinkCollection

name

  • get name(): string
  • set name(value: string): void
  • The name of the node. Node names in a network must be unique, and comparisons are case sensitive.

    Returns string

  • The name of the node. Node names in a network must be unique, and comparisons are case sensitive.

    Parameters

    • value: string

    Returns void

network

  • The {@link com.bayesserver.Network} the node belongs to. Value will be null unless the node has been added to a network.

    Returns Network

temporalType

  • The {@link com.bayesserver.TemporalType} of the node. The default value is {@link com.bayesserver.TemporalType#Contemporal}.

    exception

    Error Raised if the node belongs to a network, in which case the TemporalType cannot be changed. s

    Returns TemporalType

  • The {@link com.bayesserver.TemporalType} of the node. The default value is {@link com.bayesserver.TemporalType#Contemporal}.

    exception

    Error Raised if the node belongs to a network, in which case the TemporalType cannot be changed. s

    Parameters

    Returns void

variables

Methods

_setIndex

  • _setIndex(value: number): void
  • Parameters

    • value: number

    Returns void

_setNetwork

  • _setNetwork(value: Network): void
  • Parameters

    Returns void

_ttu_x_

_ttv_x_

  • _ttv_x_(): void
  • Returns void

_tuq_x_

copy

  • Makes a copy of this instance.

    The copy does not include links or distribution(s).

    Returns Node

    The copy.

newDistribution

  • Creates a new distribution suitable for the requested temporal order, however it is not assigned to the node. Use {@link com.bayesserver.Node#getDistributions} to perform the assignment.

    See {@link com.bayesserver.NodeDistributions} for more information.

    Note: if the resulting distribution contains continuous variables, but no discrete head variables, all table values are initialized to 1.

    see

    com.bayesserver.NodeDistributions

    Parameters

    • temporalOrder: number

      The order for the requested distribution.

    Returns IDistribution

    The new distribution.

  • Creates a new distribution suitable for the requested temporal order/related node, however it is not assigned to the node. Use {@link com.bayesserver.Node#getDistributions} to perform the assignment.

    See {@link com.bayesserver.NodeDistributions} for more information.

    Note: if the resulting distribution contains continuous variables, but no discrete head variables, all table values are initialized to 1.

    A noisy node is specified using multiple distributions, one for each parent and a leak distribution. Set the related node property to a parent, or set it to the current node to set the leak distribution.

    see

    com.bayesserver.NodeDistributions

    Parameters

    Returns IDistribution

    The new distribution.

  • Creates a new distribution with the given kind, however it is not assigned to the node. Use {@link com.bayesserver.Node#getDistributions} to perform the assignment. For temporal or noisy nodes us a different overload.

    See {@link com.bayesserver.NodeDistributions} for more information.

    Note: if the resulting distribution contains continuous variables, but no discrete head variables, all table values are initialized to 1.

    see

    com.bayesserver.NodeDistributions

    Parameters

    Returns IDistribution

    The new distribution.

  • Creates a new distribution suitable for the requested temporal order/related node, however it is not assigned to the node. Use {@link com.bayesserver.Node#getDistributions} to perform the assignment.

    See {@link com.bayesserver.NodeDistributions} for more information.

    Note: if the resulting distribution contains continuous variables, but no discrete head variables, all table values are initialized to 1.

    Experience table entries are also initialized to 1.

    A noisy node is specified using multiple distributions, one for each parent and a leak distribution. Set the related node property to a parent, or set it to the current node to set the leak distribution.

    see

    com.bayesserver.NodeDistributions

    Parameters

    Returns IDistribution

    The new distribution.

  • Creates a new distribution suitable for the node, however does not assign it to the node's {@link com.bayesserver.Node#getDistribution} property.

    This method is useful for creating distributions appropriate for a node. However, the returned distribution cannot be set to {@link com.bayesserver.Node#getDistribution} until the distribution has been correctly specified.

    Note: if the resulting distribution contains continuous variables, but no discrete head variables, all table values are initialized to 1.

    exception

    Error Raised if the node or one of it's parents has zero states.

    Returns IDistribution

    A new distribution.

toString

  • toString(): string
  • Returns the name of the node, or an empty string if the name is null.

    Returns string

    A {@link String} containing the name of the node which is empty if the name is null.