org.jtool.jxplatform.graph
Class Graph

java.lang.Object
  extended byorg.jtool.jxplatform.graph.Graph
Direct Known Subclasses:
CFG, PDG

public class Graph
extends java.lang.Object

A graph object which is either a CFG or PDG.

Author:
Katsuhsa Maruyama

Field Summary
protected  GraphElementSet edges
          Edges of this graph.
protected  GraphElementSet nodes
          Nodes of this graph.
 
Constructor Summary
protected Graph()
          Creates a new, empty objects.
 
Method Summary
 void add(GraphEdge edge)
          Adds a given edge to this graph.
 void add(GraphNode node)
          Adds a given node to this graph.
 void clear()
          Clears nodes and edges of this graph.
 boolean contains(GraphEdge edge)
          Tests if this graph contains a given edge.
 boolean contains(GraphNode node)
          Tests if this graph contains a given node.
 boolean equals(Graph graph)
          Tests if this graph equals to a given graph.
 GraphElementSet getEdges()
          Returns all edges of this graph.
 GraphElementSet getNodes()
          Returns all nodes of this graph.
 void print()
          Displays information about this graph.
 void printEdges(java.lang.StringBuffer buf)
          Collects information about edges of this graph for printing.
 void printNodes(java.lang.StringBuffer buf)
          Collects information about nodes of this graph for printing.
 void remove(GraphEdge edge)
          Removes a given edge from this graph.
 void remove(GraphNode node)
          Removes a given node from this graph.
 void setEdges(GraphElementSet set)
          Sets edges of this graph.
 void setNodes(GraphElementSet set)
          Sets nodes of this graph.
 void setSrcDstNodes()
          Calculates source and destination nodes for each of the edges of this graph.
 void writeEdges(java.lang.StringBuffer buf)
          Collects information about edges of this graph for writing an XML document.
 void writeNodes(java.lang.StringBuffer buf)
          Collects information about nodes of this graph for writing an XML document.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

nodes

protected GraphElementSet nodes
Nodes of this graph.


edges

protected GraphElementSet edges
Edges of this graph.

Constructor Detail

Graph

protected Graph()
Creates a new, empty objects.

Method Detail

setNodes

public void setNodes(GraphElementSet set)
Sets nodes of this graph.

Parameters:
set - The collection of nodes.

getNodes

public GraphElementSet getNodes()
Returns all nodes of this graph.

Returns:
The nodes of this graph.

setEdges

public void setEdges(GraphElementSet set)
Sets edges of this graph.

Parameters:
set - The collection of edges.

getEdges

public GraphElementSet getEdges()
Returns all edges of this graph.

Returns:
The edges of this graph.

clear

public void clear()
Clears nodes and edges of this graph.


add

public void add(GraphNode node)
Adds a given node to this graph.

Parameters:
node - A node to be added.

add

public void add(GraphEdge edge)
Adds a given edge to this graph.

Parameters:
edge - An edge to be added.

remove

public void remove(GraphNode node)
Removes a given node from this graph.

Parameters:
node - A node to be removed.

remove

public void remove(GraphEdge edge)
Removes a given edge from this graph.

Parameters:
edge - An edge to be removed.

contains

public boolean contains(GraphNode node)
Tests if this graph contains a given node.

Parameters:
node - A node to be checked.
Returns:
true if this graph contains the node, otherwise false.

contains

public boolean contains(GraphEdge edge)
Tests if this graph contains a given edge.

Parameters:
edge - An edge to be checked.
Returns:
true if this graph contains the edge, otherwise false.

setSrcDstNodes

public void setSrcDstNodes()
Calculates source and destination nodes for each of the edges of this graph.


equals

public boolean equals(Graph graph)
Tests if this graph equals to a given graph.

Parameters:
graph - A graph to be checked.
Returns:
true if the graphs are equal, otherwise false.

print

public void print()
Displays information about this graph.


printNodes

public void printNodes(java.lang.StringBuffer buf)
Collects information about nodes of this graph for printing.

Parameters:
buf - The information about the nodes.

printEdges

public void printEdges(java.lang.StringBuffer buf)
Collects information about edges of this graph for printing.

Parameters:
buf - The information about the edges.

writeNodes

public void writeNodes(java.lang.StringBuffer buf)
Collects information about nodes of this graph for writing an XML document.

Parameters:
buf - The information about the nodes.

writeEdges

public void writeEdges(java.lang.StringBuffer buf)
Collects information about edges of this graph for writing an XML document.

Parameters:
buf - The information about the edges.