pedviz.graph
Class Graph

java.lang.Object
  extended by pedviz.graph.Graph

public class Graph
extends java.lang.Object

This class represents the pedigree as a graph. It contains all nodes (individuals) and their edges (relations). It provides also methods that allow you to modify and update the structure of the graph.

Version:
0.1
Author:
Lukas Forer

Constructor Summary
Graph()
          Create a new and empty graph.
Graph(Cluster cluster)
          Creates a new graph based on the given Cluster object.
 
Method Summary
 void addEdge(Edge edge)
          Adds a relation between two nodes.
 void addEdge(Edge edge, boolean updateNodes)
          Adds a relation between two nodes.
 void addNode(Node node)
          Adds a node to the graph.
 void addNode(Node parent, Node node)
          Adds a sub node to the given node.
 void buildHierarchie(HierarchieBuilder builder)
          Builds a hierarchy based on the given HierarchieBuilder object.
 void clear()
          Removes all nodes, edges and sub nodes.
 void exportAsCsvFile(java.lang.String filename)
          Exports the whole graph as a csv-file.
 java.util.Collection<Node> getAllNodes()
          Returns a collection of all nodes and subnodes.
 java.util.Collection<Edge> getEdges()
          Returns a collection of all edges.
 int getFreeId()
          Returns a free id for a node.
 int getHierachiesCount()
          Returns the number of hierachies.
 int getHierachiesDepth()
          Returns the max number of nodes in a hierachy.
 Hierarchy getHierachy(int id)
          Returns the hierarchie with the given id.
 java.lang.String getName()
          Returns the name of the graph.
 Node getNode(java.lang.Object id)
          Returns the node with the given id.
 java.util.Collection<Node> getNodes()
          Returns a collection of all single nodes, dummy nodes and cluster nodes.
 int getSize()
           
 boolean isLayouted()
          Returns true, if the graph is layouted.
 void print()
           
 void removeAllHierachies()
          Removes all hierarchies from this graph.
 void removeEdge(Edge edge)
          Removes the given edge.
 void removeNode(Node node)
          Removes the given node.
 void removeNode(Node node, boolean updateNode)
          Removes the given node. if updateNodes is true, it updates the in-edges and out-edges from the node.
 void setLayouted(boolean layouted)
          Sets
 void setName(java.lang.String name)
          Sets the name of the graph.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Graph

public Graph()
Create a new and empty graph.


Graph

public Graph(Cluster cluster)
Creates a new graph based on the given Cluster object.

Parameters:
cluster - Cluster object
Method Detail

addNode

public void addNode(Node node)
Adds a node to the graph.

Parameters:
node - new node

getNode

public Node getNode(java.lang.Object id)
Returns the node with the given id.

Parameters:
id -
Returns:
if there exists a node with the given id, the reference to the node, else null.

addEdge

public void addEdge(Edge edge)
Adds a relation between two nodes. It updates automatically the in-edges and out-edges from the two nodes.

Parameters:
edge - new edge

addEdge

public void addEdge(Edge edge,
                    boolean updateNodes)
Adds a relation between two nodes. If updateNodes is true, it updates the in-edges and out-edges from the two nodes.

Parameters:
edge - new edge
updateNodes - if updateNodes is true, it updates the in-edges and out-edges from the two nodes.

removeNode

public void removeNode(Node node)
Removes the given node. It updates automatically the in-edges and out-edges from the two nodes.

Parameters:
node - node

removeNode

public void removeNode(Node node,
                       boolean updateNode)
Removes the given node. if updateNodes is true, it updates the in-edges and out-edges from the node.

Parameters:
node - node
updateNodes - if updateNodes is true, it updates the in-edges and out-edges from the node.

removeEdge

public void removeEdge(Edge edge)
Removes the given edge.

Parameters:
edge - edge

getNodes

public java.util.Collection<Node> getNodes()
Returns a collection of all single nodes, dummy nodes and cluster nodes.

Returns:
Collection of nodes.

getAllNodes

public java.util.Collection<Node> getAllNodes()
Returns a collection of all nodes and subnodes.

Returns:
Collection of nodes and subnodes.

getEdges

public java.util.Collection<Edge> getEdges()
Returns a collection of all edges.

Returns:
Returns the edges.

getFreeId

public int getFreeId()
Returns a free id for a node. If you create a dummy node, then you can use this method to get a free not used id.

Returns:
Returns a free id for a node.

addNode

public void addNode(Node parent,
                    Node node)
Adds a sub node to the given node.

Parameters:
parent - cluster node
node - sub node

clear

public void clear()
Removes all nodes, edges and sub nodes.


isLayouted

public boolean isLayouted()
Returns true, if the graph is layouted.

Returns:
true, if the graph is layouted.

setLayouted

public void setLayouted(boolean layouted)
Sets

Parameters:
layouted - true, if the graph is layouted.

exportAsCsvFile

public void exportAsCsvFile(java.lang.String filename)
Exports the whole graph as a csv-file.

Parameters:
filename - filename of the csv-file.

getName

public java.lang.String getName()
Returns the name of the graph.

Returns:
the name of the graph.

setName

public void setName(java.lang.String name)
Sets the name of the graph.

Parameters:
name - the name of the graph.

removeAllHierachies

public void removeAllHierachies()
Removes all hierarchies from this graph.


getHierachy

public Hierarchy getHierachy(int id)
Returns the hierarchie with the given id.

Parameters:
id -
Returns:
if the hierarchy exists, returns the Hierachie object, else null.

getHierachiesCount

public int getHierachiesCount()
Returns the number of hierachies.

Returns:
number of hierachies

getHierachiesDepth

public int getHierachiesDepth()
Returns the max number of nodes in a hierachy.

Returns:
max number of nodes in a hierachy

buildHierarchie

public void buildHierarchie(HierarchieBuilder builder)
Builds a hierarchy based on the given HierarchieBuilder object.

Parameters:
builder - HierarchieBuilder object.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getSize

public int getSize()

print

public void print()