Search Results for

    Show / Hide Table of Contents

    Class Network

    Represents a Bayesian Network, or a Dynamic Bayesian Network. To perform inference with a network see the BayesServer.Inference namespace.

    Inheritance
    object
    Network
    Implements
    INotifyPropertyChanged
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: BayesServer
    Assembly: BayesServer.dll
    Syntax
    public sealed class Network : INotifyPropertyChanged
    Remarks

    A Bayesian network consists of nodes which contain one or more variables. Each node can be connected with a directed link (A link in a Dynamic Bayesian Network can have an associated order which links nodes in different time slices).

    <p>
    Each node in a Bayesian network must have a distribution specified over its own variables conditional on its parents variables.  For example if a network contains
    nodes A and B each with a single variable of the same name, and A is a parent of B, then the distribution at A equals P(A), since A has no parents,
    and the distribution at B equals P(B|A).
    </p>
    <p>Once the nodes, links, and distributions in a Bayesian network have been specified, one or more inference engines
    can be created based on the network, to perform probabilistic inference.  See <xref href="BayesServer.Inference.IInference" data-throw-if-not-resolved="false"></xref>.</p>
    

    Constructors

    Network()

    Initializes a new instance of the Network class.

    Declaration
    public Network()

    Network(string)

    Initializes a new instance of the Network class with the specified name.

    Declaration
    public Network(string name)
    Parameters
    Type Name Description
    string name

    The optional name of the network. Can be null.

    Properties

    CustomProperties

    Gets custom properties associated with this instance.

    Declaration
    public CustomPropertyCollection CustomProperties { get; }
    Property Value
    Type Description
    CustomPropertyCollection
    Remarks

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

    Description

    An optional description for the Bayesian network.

    Declaration
    public string Description { get; set; }
    Property Value
    Type Description
    string

    HasChanged

    Indicates whether the network has changed.

    Declaration
    public bool HasChanged { get; }
    Property Value
    Type Description
    bool
    Remarks

    This property is automatically set to false when the network is saved, or loaded.

    IsInternal

    For internal use only. May be removed in future versions.

    Declaration
    public bool IsInternal { get; set; }
    Property Value
    Type Description
    bool

    Links

    The collection of links in the Bayesian network.

    Declaration
    [TypeConverter(typeof(ExpandableObjectConverter))]
    public NetworkLinkCollection Links { get; }
    Property Value
    Type Description
    NetworkLinkCollection
    Remarks

    Note that if a Node is removed from the network, all of its links are automatically removed.

    See Also
    Link

    Name

    An optional name for the Bayesian network.

    Declaration
    public string Name { get; set; }
    Property Value
    Type Description
    string

    NodeGroups

    Gets groups which nodes can belong to.

    Declaration
    public NetworkNodeGroupCollection NodeGroups { get; }
    Property Value
    Type Description
    NetworkNodeGroupCollection
    Remarks

    Each node can belong to one or more groups.

    Nodes

    The collection of nodes in the Bayesian network.

    Declaration
    [TypeConverter(typeof(ExpandableObjectConverter))]
    public NetworkNodeCollection Nodes { get; }
    Property Value
    Type Description
    NetworkNodeCollection
    See Also
    Node

    SyncNodeVariableName

    When true synchronizes Variable names with their containing Node.

    Declaration
    public static bool SyncNodeVariableName { get; set; }
    Property Value
    Type Description
    bool
    Remarks

    The synchronization is one way from the Node to the Variable only.

    Synchronization only occurs when a node has a single variable, whose name matches its containing node.

    Variables

    The collection of variables in the Bayesian network.

    Declaration
    [TypeConverter(typeof(ExpandableObjectConverter))]
    public NetworkVariableCollection Variables { get; }
    Property Value
    Type Description
    NetworkVariableCollection
    See Also
    Variable

    Methods

    Copy()

    Makes a copy of the network.

    Declaration
    public Network Copy()
    Returns
    Type Description
    Network

    The copy.

    IsDag()

    Determines whether this instance is a Directed Acyclic Graph (DAG) which is a requirement for Bayesian networks.

    Declaration
    public bool IsDag()
    Returns
    Type Description
    bool

    true if this instance is a DAG; otherwise, false.

    IsTree()

    Determines whether this instance is a tree (singly connected).

    Declaration
    public bool IsTree()
    Returns
    Type Description
    bool

    true if this instance is a tree; otherwise, false.

    Load(Stream)

    Loads a Network from the specified input Stream.

    Declaration
    public void Load(Stream input)
    Parameters
    Type Name Description
    Stream input

    The Stream to load from.

    Load(string)

    Loads a Network from the specified path.

    Declaration
    public void Load(string path)
    Parameters
    Type Name Description
    string path

    The path and file name to load from.

    LoadFromString(string)

    Loads a network from a string using UTF-8 encoding.

    Declaration
    public void LoadFromString(string value)
    Parameters
    Type Name Description
    string value

    The persisted string value of the network.

    LoadFromString(string, Encoding)

    Loads a network from a string using the specified encoding.

    Declaration
    public void LoadFromString(string value, Encoding encoding)
    Parameters
    Type Name Description
    string value

    The persisted string value of the network.

    Encoding encoding

    The encoding the network was originally saved in.

    Save(Stream)

    Saves this Network to the specified output Stream.

    Declaration
    public void Save(Stream output)
    Parameters
    Type Name Description
    Stream output

    The Stream to save to.

    Remarks

    When saving to file, .bayes is the recommended file extension. The encoding used is UTF-8.

    Save(string)

    Saves this Network to the specified path overwriting the file if it already exists.

    Declaration
    public void Save(string path)
    Parameters
    Type Name Description
    string path

    The path and name of the file to save to.

    Remarks

    The recommended file extension is .bayes

    SaveToString()

    Saves the network to a string, with UTF-8 encoding. For large networks consider saving to file or a stream.

    Declaration
    public string SaveToString()
    Returns
    Type Description
    string

    The network persisted to a string.

    SaveToString(Encoding)

    Saves the network to a string, with the specified encoding. For large networks consider saving to file or a stream.

    Declaration
    public string SaveToString(Encoding encoding)
    Parameters
    Type Name Description
    Encoding encoding

    The encoding to use.

    Returns
    Type Description
    string

    The network persisted to a string.

    Validate(ValidationOptions)

    Validates that the Bayesian network is correctly specified.

    Declaration
    public void Validate(ValidationOptions options)
    Parameters
    Type Name Description
    ValidationOptions options

    Specifies options to control the validation process.

    Exceptions
    Type Condition
    InvalidNetworkException

    Raised when the network is not correctly specified, containing the error message.

    ValidateTrialSession()

    Evaluation version only.

    Declaration
    [Browsable(false)]
    public static void ValidateTrialSession()

    Events

    PropertyChanged

    Declaration
    public event PropertyChangedEventHandler PropertyChanged
    Event Type
    Type Description
    PropertyChangedEventHandler

    Implements

    INotifyPropertyChanged

    See Also

    Node
    Link
    In this article
    Back to top Copyright Bayes Server Ltd. All rights Reserved.