Network

public class Network : Hashable

The Network class is an abstract class with two subclasses: Domain and Class.

  • Declaration

    Swift

    public func hash(into hasher: inout Hasher)
  • Declaration

    Swift

    public static func == (lhs: Network, rhs: Network) -> Bool
  • This is used to represent domain knowledge about a particular edge between a pair of nodes. Such knowledge can be used to constrain the set of networks that can be learned from data. The knowledge is used by the structure learning algorithm to resolve ambiguities (e.g., deciding the direction of a edge). Concretely, the knowledge can express the direction of a edge, the presence or absence of a edge, or both.

    See more

    Declaration

    Swift

    public enum EdgeConstraint
  • Create a new node of the specified category and kind within this network.

    Declaration

    Swift

    public func newNode (category: Node.Category, kind: Node.Kind) throws
    -> Node
  • Opens a log file to be associated with this Network.

    Declaration

    Swift

    public func openLogFile(_ fileName: String, append: Bool = false) throws

    Parameters

    fileName

    the name of the log file.

    append

    if true opens the log file in append mode; otherwise, opens in create mode.

  • Closes the log file associated with this Network.

    Declaration

    Swift

    public func closeLogFile() throws
  • Returns the name of the most recent log file opened by Network.openLogFile(String,Bool).

    Declaration

    Swift

    public func getLogFile() throws -> String?

    Return Value

    String or nil (if no log file has been opened or the most recent call to Network.openLogFile(String,Bool) has been succeeded by a call to Network.closeLogFile()).

  • Inserts the key/value pair in the attribute list for this Network. If the key is already defined, the value is updated. If no value is provided, the attribute is removed.

    Declaration

    Swift

    public func setAttribute(_ key: String, _ value: String?) throws

    Parameters

    key

    The key identifying the attribute to be updated.

    value

    The value of the attribute.

  • Returns the attribute value associated with the given key in the attribute list for this Network. Returns nil if no value is associated with the given key.

    Declaration

    Swift

    public func getAttribute(_ key: String) throws -> String?

    Parameters

    key

    the key for which the attribute value is returned.

    Return Value

    A String containing the attribute value.

  • Returns the set of attributes (as a dictionary) associated with this Network.

    Declaration

    Swift

    public func getAttributes() throws -> [String : String]
  • Generates the conditional probability tables for all nodes of this Network. This is done by calling Node.generateTable() for all nodes having a model.

    Declaration

    Swift

    public func generateTables() throws
  • Returns the nodes of this Network.

    Declaration

    Swift

    public func getNodes() throws -> [Node]

    Return Value

    A list of all nodes in this Network.

  • Returns the Node with the given name. If no node by the given name exists, nil is returned.

    Declaration

    Swift

    public func getNode(name: String) throws -> Node?

    Parameters

    name

    The name of the Node to search for.

    Return Value

    A Node named name in this Network, or nil if no such node exists.

  • Writes a NET description of this Network to a file.

    Declaration

    Swift

    public func save(netName: String) throws

    Parameters

    netName

    the name of the NET file.

  • Creates a NET description of this Network.

    Declaration

    Swift

    public func toNetString() throws -> String

    Return Value

    A string containing the NET description.

  • Parses the file named fileName and returns a NodeList. This can be used for reading an elimination order from a file.

    Declaration

    Swift

    public func parseNodes (_ fileName: String)
    throws -> [Node]

    Parameters

    fileName

    the name of a file containing the list of node names.

  • Sets the size of the nodes.

    Declaration

    Swift

    public func setNodeSize(width: Int, height: Int) throws

    Parameters

    width

    the horizontal size of nodes

    height

    the vertical size of nodes

  • Returns the size of the displayed nodes.

    Declaration

    Swift

    public func getNodeSize() throws -> (Int, Int)

    Return Value

    The width and height of nodes as a pair of integers