edu.isi.pegasus.planner.partitioner.graph
Interface Graph

All Superinterfaces:
GraphNodeContent
All Known Implementing Classes:
MapGraph

public interface Graph
extends GraphNodeContent

The interface for the Graph Class. It implements the GraphNodeContent interface. This allows us to associate Graphs with the nodes in a Graph i.e. graph of graphs.

Version:
$Revision: 2576 $
Author:
Karan Vahi

Field Summary
static String VERSION
          The version number associated with this Graph API.
 
Method Summary
 void addEdge(String parent, String child)
          Adds an edge between two already existing nodes in the graph.
 void addEdges(String child, List parents)
          A convenience method that allows for bulk addition of edges between already existing nodes in the graph.
 void addNode(GraphNode node)
          Adds a node to the Graph.
 void addRoot(GraphNode root)
          Adds a single root node to the Graph.
 List<GraphNode> getLeaves()
          Returns the leaf nodes of the Graph.
 GraphNode getNode(String identifier)
          Returns the node matching the id passed.
 List<GraphNode> getRoots()
          Returns the root nodes of the Graph.
 boolean isEmpty()
          Returns a boolean if there are no nodes in the graph.
 Iterator<GraphNode> iterator()
          Returns an iterator that traverses through the graph using a graph traversal algorithm.
 Iterator<GraphNode> nodeIterator()
          Returns an iterator for the nodes in the Graph.
 boolean remove(String identifier)
          Removes a node from the Graph.
 int size()
          Returns the number of nodes in the graph.
 Iterator<GraphNode> topologicalSortIterator()
          Returns an iterator for the graph that traverses in topological sort order.
 

Field Detail

VERSION

static final String VERSION
The version number associated with this Graph API.

See Also:
Constant Field Values
Method Detail

addNode

void addNode(GraphNode node)
Adds a node to the Graph. It overwrites an already existing node with the same ID.

Parameters:
node - the node to be added to the Graph.

addEdge

void addEdge(String parent,
             String child)
Adds an edge between two already existing nodes in the graph.

Parameters:
parent - the parent node ID.
child - the child node ID.

addEdges

void addEdges(String child,
              List parents)
A convenience method that allows for bulk addition of edges between already existing nodes in the graph.

Parameters:
child - the child node ID
parents - list of parent identifiers as String.

getNode

GraphNode getNode(String identifier)
Returns the node matching the id passed.

Parameters:
identifier - the id of the node.
Returns:
the node matching the ID else null.

addRoot

void addRoot(GraphNode root)
Adds a single root node to the Graph. All the exisitng roots of the Graph become children of the root.

Parameters:
root - the GraphNode to be added as a root.
Throws:
RuntimeException - if a node with the same id already exists.

remove

boolean remove(String identifier)
Removes a node from the Graph.

Parameters:
identifier - the id of the node to be removed.
Returns:
boolean indicating whether the node was removed or not.

nodeIterator

Iterator<GraphNode> nodeIterator()
Returns an iterator for the nodes in the Graph. These iterators are fail safe.

Returns:
Iterator

iterator

Iterator<GraphNode> iterator()
Returns an iterator that traverses through the graph using a graph traversal algorithm.

Returns:
Iterator through the nodes of the graph.

topologicalSortIterator

Iterator<GraphNode> topologicalSortIterator()
Returns an iterator for the graph that traverses in topological sort order.

Returns:
Iterator through the nodes of the graph.

size

int size()
Returns the number of nodes in the graph.


getRoots

List<GraphNode> getRoots()
Returns the root nodes of the Graph.

Returns:
a list containing GraphNode corressponding to the root nodes.

getLeaves

List<GraphNode> getLeaves()
Returns the leaf nodes of the Graph.

Returns:
a list containing GraphNode corressponding to the leaf nodes.

isEmpty

boolean isEmpty()
Returns a boolean if there are no nodes in the graph.

Returns:
boolean


Copyright © 2011 The University of Southern California. All Rights Reserved.