lio.probdistributions
Class Network

java.lang.Object
  extended by lio.probdistributions.Network
Direct Known Subclasses:
MultivariateModel

public abstract class Network
extends java.lang.Object

This class represents a generic network and can be used to build trees or graphs with directed links


Field Summary
protected  boolean laplace
           
protected  int numNodes
           
 
Constructor Summary
Network()
           
Network(int numNodes)
           
 
Method Summary
 void addLink(int parentNode, int childNode)
          Set a new link between these nodes
 boolean existsLink(int parentNode, int childNode)
           
 int[] getChildren(int node)
           
 int getNumNodes()
           
 int[] getParents(int node)
           
abstract  double getProbability(int X, Individual configuration)
           
 int[] getTopologicalOrder()
           
 boolean hasCycle()
          Checks whether the graph in this network isn't acyclic
 boolean isLaplace()
           
abstract  void learnCPT()
          Learn conditional probability tables from the data in population according with structure in the graph
 boolean makeCycle(int parentNode, int childNode)
          Checks whether the link between patentNode and childNode introduces a cycle in the graph
 void removeLink(int parentNode, int childNode)
          Delete link between these nodes
abstract  void setData(Individual[] individuals)
           
 void setLaplace(boolean laplace)
           
 void setNumNodes(int numNodes)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

numNodes

protected int numNodes

laplace

protected boolean laplace
Constructor Detail

Network

public Network()

Network

public Network(int numNodes)
Method Detail

isLaplace

public boolean isLaplace()
Returns:
Returns the laplace.

setLaplace

public void setLaplace(boolean laplace)
Parameters:
laplace - The laplace to set.

addLink

public void addLink(int parentNode,
                    int childNode)
Set a new link between these nodes

Parameters:
parentNode - node where the new link goes out
childNode - node where the new link point to

removeLink

public void removeLink(int parentNode,
                       int childNode)
Delete link between these nodes

Parameters:
parentNode -
childNode -

existsLink

public boolean existsLink(int parentNode,
                          int childNode)
Parameters:
parentNode -
childNode -
Returns:
true if exists such link from parentNode to childNode

makeCycle

public boolean makeCycle(int parentNode,
                         int childNode)
Checks whether the link between patentNode and childNode introduces a cycle in the graph

Parameters:
parentNode -
childNode -
Returns:
true if new link makes a cycle

hasCycle

public boolean hasCycle()
Checks whether the graph in this network isn't acyclic

Returns:
true if this network has cycles

getParents

public int[] getParents(int node)
Parameters:
node -
Returns:
an array with this node's parents

getChildren

public int[] getChildren(int node)
Parameters:
node -
Returns:
an array with this node's children

getTopologicalOrder

public int[] getTopologicalOrder()
Returns:
nodes in topological order or null if this it's impossible

learnCPT

public abstract void learnCPT()
Learn conditional probability tables from the data in population according with structure in the graph

Parameters:
pop -

setData

public abstract void setData(Individual[] individuals)

getProbability

public abstract double getProbability(int X,
                                      Individual configuration)
Parameters:
X - variable of interest
configuration - list of values of each variable in the proper order
Returns:
probability for X according this configuration of values

getNumNodes

public int getNumNodes()
Returns:
Returns the numNodes.

setNumNodes

public void setNumNodes(int numNodes)
Parameters:
numNodes - The numNodes to set.