uk.ac.bbk.dcs.automed.graph
Class DirectedGraph

java.lang.Object
  extended by uk.ac.bbk.dcs.automed.graph.DirectedGraph

public class DirectedGraph
extends java.lang.Object

Class that abstracts a directed unlabelled graph.

Author:
Lucas Zamboulis

Field Summary
(package private)  java.util.List graphNodes
           
private  java.util.Set subGraphs
           
 
Constructor Summary
DirectedGraph()
           
 
Method Summary
 void addGraphNode(DirectedGraphNode n)
          Adds a node in the graph.
protected  void addSubGraph(DirectedGraph graph)
          Adds a subGraph in the set of subGraphs.
 boolean containsGraphNode(DirectedGraphNode n)
           
private  TreeNode convertToTree(DirectedGraphNode n, TreeNode parentT)
          This method converts a given DirectedGraphNode into a TreeNode, by giving it the same name and assigning to it the same children as the DirectedGraphNode.
private  void createSubGraph(DirectedGraph newSubGraph, DirectedGraphNode currentNode)
           
protected  java.util.List getGraph()
           
protected  DirectedGraphNode getNode(int i)
           
 DirectedGraphNode getNode(java.lang.String name)
           
protected  java.util.Set getSubGraphs()
           
 java.util.Set graphToForest(Forest f)
          This method first divides a given graph into subGraphs.
private  java.util.List graphToTrees(DirectedGraph n, int treeType)
          This method creates a tree from a given graph.
protected  void identifySubGraphs()
          Discovers the subGraphs in the graph
protected  void printGraph(DirectedGraph n)
           
 int size()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

graphNodes

java.util.List graphNodes

subGraphs

private java.util.Set subGraphs
Constructor Detail

DirectedGraph

public DirectedGraph()
Method Detail

addGraphNode

public void addGraphNode(DirectedGraphNode n)
                  throws GraphException
Adds a node in the graph.

Parameters:
n - the node to add
Throws:
GraphException

containsGraphNode

public boolean containsGraphNode(DirectedGraphNode n)
Parameters:
n - a DirectedGraphNode object
Returns:
true if the object given exists in the graph; false otherwise

getGraph

protected java.util.List getGraph()
Returns:
the nodes consisting the graph

size

public int size()
Returns:
the number of nodes consisting the graph

getNode

protected DirectedGraphNode getNode(int i)

getNode

public DirectedGraphNode getNode(java.lang.String name)
                          throws NotFoundException
Throws:
NotFoundException

graphToForest

public java.util.Set graphToForest(Forest f)
                            throws GraphException
This method first divides a given graph into subGraphs. Then it converts each one to a tree, effectively transforming a graph into a forest

Parameters:
graph - the graph
Returns:
the forest
Throws:
GraphException

graphToTrees

private java.util.List graphToTrees(DirectedGraph n,
                                    int treeType)
                             throws GraphException
This method creates a tree from a given graph.

Parameters:
n - the graph
treeType - 1 for minimum fan-out (possibly minimum data replication).
Returns:
the tree
Throws:
GraphException

convertToTree

private TreeNode convertToTree(DirectedGraphNode n,
                               TreeNode parentT)
This method converts a given DirectedGraphNode into a TreeNode, by giving it the same name and assigning to it the same children as the DirectedGraphNode. However , it does not assign a parent to the TreeNode.

Parameters:
n - the graph node
Returns:
the TreeNode

getSubGraphs

protected java.util.Set getSubGraphs()
Returns:
the subGraphs of the graph

addSubGraph

protected void addSubGraph(DirectedGraph graph)
Adds a subGraph in the set of subGraphs.

Parameters:
graph - the subGraph to add

identifySubGraphs

protected void identifySubGraphs()
                          throws GraphException
Discovers the subGraphs in the graph

Throws:
GraphException

createSubGraph

private void createSubGraph(DirectedGraph newSubGraph,
                            DirectedGraphNode currentNode)
                     throws GraphException
Throws:
GraphException

printGraph

protected void printGraph(DirectedGraph n)