package dkohl.bayes.bayesnet;

import java.util.HashMap;
import java.util.LinkedList;

import dkohl.bayes.probability.Variable;
import dkohl.bayes.probability.distribution.ProbabilityDistribution;

/**
 * Represents a Bayes net as a graph with a probability table associated with
 * each node.
 * 
 * @author Daniel Kohlsdorf
 */
public class BayesNet extends NamedGraph {

	/**
	 * The probability tables for each node
	 */
	private HashMap<String, ProbabilityDistribution> nodes;
	private LinkedList<Variable> variables;

	public BayesNet(String names[]) {
		super(names);
		this.nodes = new HashMap<String, ProbabilityDistribution>();
		this.variables = new LinkedList<Variable>();
	}

	public void setDistribution(Variable node, ProbabilityDistribution dist) {
		nodes.put(node.getName(), dist);
		variables.add(node);
	}

	public void updateDistribution(Variable node, ProbabilityDistribution dist) {
		nodes.put(node.getName(), dist);
	}

	public HashMap<String, ProbabilityDistribution> getNodes() {
		return nodes;
	}

	public LinkedList<Variable> getVariables() {
		return variables;
	}
}
