Class BayesNetwork

java.lang.Object
de.uka.ipd.sdq.dsexplore.bayesnets.utility.BayesNetwork

public class BayesNetwork extends Object
This class is used for representing a Bayesian Network. It also contains many methods to operate on a given Bayesian Network.
  • Constructor Summary

    Constructors
    Constructor
    Description
    BayesNetwork(int var)
    The constructor for the class.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    checkCycles(int[][] Graph)
    This method checks the Graph for any cycles contained in it.
    int[][]
    Creates an empty network structure with no edges between the various nodes.
    int[][]
    Creates a random network structure.
    int[]
    getChildren(int[][] Graph, int Node)
    Used to retrieve the list of children of the node Node.
    int[]
    getParents(int[][] Graph, int Node)
    Used to retrieve the list of Parents of the node Node.
    int[]
    getRemovedNodes(int[][] Graph)
    This method keeps a track of all the nodes which are removed when we remove all the leaves and roots of the Graph.
    static void
    main(String[] args)
     
    int[][]
    removeCycles(int[][] Graph)
    Removes the cycles (if they exist) in a given network structure.
    int[][]
    removeLeavesAndRoots(int[][] Graph)
    This method removes all the leaves and roots contained in a Graph.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • BayesNetwork

      public BayesNetwork(int var)
      The constructor for the class. Initialzes the number of variables.
  • Method Details

    • main

      public static void main(String[] args)
    • createRandomStructure

      public int[][] createRandomStructure()
      Creates a random network structure. Currently, the network produced will mostly be a DAG (Directed Acyclic Graph), though it isn't guaranteed.
      Parameters:
      No - Parameters
      Returns:
      An int[][] adjacency matrix of the created Graph/Network
    • createEmptyStructure

      public int[][] createEmptyStructure()
      Creates an empty network structure with no edges between the various nodes.
      Parameters:
      No - Parameters
      Returns:
      An int[][] adjacency matrix of the created Graph/Network
    • removeCycles

      public int[][] removeCycles(int[][] Graph)
      Removes the cycles (if they exist) in a given network structure. For the logic of removing cycles, please see the comments in code.
      Parameters:
      int - [][] Graph - The Adjaceny matrix of the Bayesian Network
      Returns:
      An int[][] adjacency matrix of the result Graph/Network
    • checkCycles

      public boolean checkCycles(int[][] Graph)
      This method checks the Graph for any cycles contained in it. If the Graph is acyclic, then it returns TRUE. Otherwise, it returns FALSE.
      Parameters:
      int - [][] Graph
      Returns:
      boolean - TRUE if Graph is acyclic, else FALSE
    • removeLeavesAndRoots

      public int[][] removeLeavesAndRoots(int[][] Graph)
      This method removes all the leaves and roots contained in a Graph. It returns the resulting Graph to the user.
      Parameters:
      int - [][] Graph
      Returns:
      An int[][] adjacency matrix of the resulting Graph/Network
    • getRemovedNodes

      public int[] getRemovedNodes(int[][] Graph)
      This method keeps a track of all the nodes which are removed when we remove all the leaves and roots of the Graph. The indices of the removed leaves and roots are returned as an array of integers.
      Parameters:
      int - [][] Graph
      Returns:
      An int[] array of the removed leaves and roots of the Graph/Network
    • getParents

      public int[] getParents(int[][] Graph, int Node)
      Used to retrieve the list of Parents of the node Node.
      Parameters:
      int - [][] Graph - Adjacency matrix of the Bayesian Graph
      int - Node - The node about which we want the information about the parents.
      Returns:
      An int[] array of the indices of the parents of Node
    • getChildren

      public int[] getChildren(int[][] Graph, int Node)
      Used to retrieve the list of children of the node Node.
      Parameters:
      int - [][] Graph - Adjacency matrix of the Bayesian Graph
      int - Node - The node about which we want the information about the children.
      Returns:
      An int[] array of the indices of the children of Node