Graph (Java Globus API)

org.globus.ogce.gui.util.graph
Class Graph

java.lang.Object
  |
  +--org.globus.ogce.gui.util.graph.Graph

public class Graph
extends java.lang.Object

This class is used to represents a graphs with arbitrary node and edge objects object of nodes interconnected with edges. Both the actual node and edge objects are completely abstract. Each node (edge) is given a unique node (edge) name in the form of a string. Traversal of the graph is not currently supported in the Graph class itself.

Instantiation:

Currently only a default constructor exists so instantiation is simply as follows:
Graph networkGraph = new Graph();

Working With The Class:

Working with the graph class is like working with a diamond necklace. Just as the diamonds need a backing to attach to the chain, so do the abstract node objects need a backing to attach to the web of edges. When one creates a node using the addNode() method, one must provide a node object which is analogous to the diamond--the real value of the graph node. Just like a jewler could substitute a saphire in place of a diamond, the node objects are completely abstract and can be of any data type either native or user-defined.

Along the same lines, the edges of the graph have abstract edge objects which could represent any type of interconnection between the graph nodes. To add an edge one must have two nodes already created. The addEdge() method, as one may have guessed, is used to accomplish this.

See Also:
org.globus.util.graph.GraphNode, org.globus.util.graph.GraphEdge

Constructor Summary
Graph()
          This method initializes a Graph
 
Method Summary
 void addEdge(java.lang.String name, java.lang.Object object, GraphNode start, GraphNode end)
          This method adds a new edge to the graph and associates the edge with two pre-existing nodes.
 void addEdge(java.lang.String name, java.lang.Object object, java.lang.String startName, java.lang.String endName)
          This method adds a new edge to the graph and associates the edge with two pre-existing nodes by using their unique names.
 void addNode(java.lang.String name, java.lang.Object object)
          This method adds a new node to the graph.
 boolean areRelated(GraphNode parentNode, GraphNode childNode)
          This method decides if there is a parent/child relationship between the two nodes.
 GraphEdge getEdge(int i)
          This method returns the ith edge
 GraphEdge getEdge(java.lang.String edgeName)
          This method returns the edge with the secified name
 GraphNode getNode(int i)
          This method returns the node with the secified name
 GraphNode getNode(java.lang.String nodeName)
          This method returns the node with the secified name
 boolean isChild(GraphNode parentNode, GraphNode childNode)
          This method decides weither the second node is a child of the first node.
 boolean isParent(GraphNode parentNode, GraphNode childNode)
          This method decides if the first node is the parent of the second node.
 int numberOfEdges()
          This method returns the number of edges in the graph.
 int numberOfNodes()
          This method returns the number of nodes in the graph.
 void removeEdge(GraphEdge edge)
          This method removes an edge from the graph.
 void removeEdge(java.lang.String edgeName)
          This method removes an edge from the graph by using it's name.
 void removeNode(GraphNode node)
          This method removes a node and any edges associated to it from the graph.
 void removeNode(java.lang.String nodeName)
          This method removes a node and any edges associated to it from the graph using the nodes name.
 void setEdgeName(java.lang.String oldName, java.lang.String newName)
          This method changes the name of an edge.
 void setEdgeObject(java.lang.String name, java.lang.Object newObject)
          This method changes the object of an edge.
 void setNodeName(java.lang.String oldName, java.lang.String newName)
          This method changes the name of a node.
 void setNodeObject(java.lang.String name, java.lang.Object object)
          This method changes the object of a node.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Graph

public Graph()
This method initializes a Graph

Method Detail

numberOfEdges

public int numberOfEdges()
This method returns the number of edges in the graph.


numberOfNodes

public int numberOfNodes()
This method returns the number of nodes in the graph.


getNode

public GraphNode getNode(int i)
This method returns the node with the secified name

Returns:
GraphNode: This is the node with the given name.

getNode

public GraphNode getNode(java.lang.String nodeName)
This method returns the node with the secified name

Returns:
GraphNode: This is the node with the given name.

getEdge

public GraphEdge getEdge(int i)
This method returns the ith edge

Returns:
GraphEdge: This is the edge with the given name.

getEdge

public GraphEdge getEdge(java.lang.String edgeName)
This method returns the edge with the secified name

Returns:
GraphEdge: This is the edge with the given name.

addNode

public void addNode(java.lang.String name,
                    java.lang.Object object)
This method adds a new node to the graph.


addEdge

public void addEdge(java.lang.String name,
                    java.lang.Object object,
                    GraphNode start,
                    GraphNode end)
This method adds a new edge to the graph and associates the edge with two pre-existing nodes.


addEdge

public void addEdge(java.lang.String name,
                    java.lang.Object object,
                    java.lang.String startName,
                    java.lang.String endName)
This method adds a new edge to the graph and associates the edge with two pre-existing nodes by using their unique names.


setNodeName

public void setNodeName(java.lang.String oldName,
                        java.lang.String newName)
This method changes the name of a node.


setEdgeName

public void setEdgeName(java.lang.String oldName,
                        java.lang.String newName)
This method changes the name of an edge.


setNodeObject

public void setNodeObject(java.lang.String name,
                          java.lang.Object object)
This method changes the object of a node.


setEdgeObject

public void setEdgeObject(java.lang.String name,
                          java.lang.Object newObject)
This method changes the object of an edge.


removeNode

public void removeNode(GraphNode node)
This method removes a node and any edges associated to it from the graph.


removeNode

public void removeNode(java.lang.String nodeName)
This method removes a node and any edges associated to it from the graph using the nodes name.


removeEdge

public void removeEdge(GraphEdge edge)
This method removes an edge from the graph.


removeEdge

public void removeEdge(java.lang.String edgeName)
This method removes an edge from the graph by using it's name.


areRelated

public boolean areRelated(GraphNode parentNode,
                          GraphNode childNode)
This method decides if there is a parent/child relationship between the two nodes. Since the test for weither a node is a child or a node is a parent is the same, both isParent() and isChild() call this function instead of duplicating the same code.

Returns:
boolean: True if the two nodes are parent and child.
False if the two nodes are not parent and child.

isParent

public boolean isParent(GraphNode parentNode,
                        GraphNode childNode)
This method decides if the first node is the parent of the second node.

Returns:
boolean: True if the first node is a parent of the second.
False if the first node is not a parent of the second.

isChild

public boolean isChild(GraphNode parentNode,
                       GraphNode childNode)
This method decides weither the second node is a child of the first node.

Returns:
boolean: True if the second node is a child of the first.
False if the second node is not a child of the first.