org.hermit.geometry
Class Graph

java.lang.Object
  extended by org.hermit.geometry.Graph

public class Graph
extends java.lang.Object

An immutable graph, with possibly infinite edges.

This immutable class represents a graph as a collection of Edge objects. These edges can be infinite.


Constructor Summary
Graph(java.util.HashSet<Edge> e)
          Construct a graph with a given set of edges.
 
Method Summary
 void dump(java.lang.String prefix)
          Dump the entire set of edges in this graph to the console.
 Edge[] getEdgeArray()
          Get an array of the edges in the graph.
 java.util.Iterator<Edge> getEdges()
          Get the edges in the graph.
 int getNumEdges()
          Get the number of edges in the graph.
 int getNumVertices()
          Get the number of vertices in the graph.
 Point[] getVertexArray()
          Get an array of the vertices in the graph.
 java.util.Iterator<Point> getVertices()
          Get the vertices in the graph.
 java.lang.String toString()
          Convert this instance to a String suitable for display.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Graph

public Graph(java.util.HashSet<Edge> e)
Construct a graph with a given set of edges.

Parameters:
e - The set of edges which define the graph. May include infinite edges.
Method Detail

getNumEdges

public int getNumEdges()
Get the number of edges in the graph.

Returns:
The number of edges in the graph. Note that this number includes an infinite point if there are any infinite edges in the graph.

getEdges

public java.util.Iterator<Edge> getEdges()
Get the edges in the graph.

Returns:
An iterator over the edges in the graph. Note that this iterator includes an infinite point if there are any infinite edges in the graph.

getEdgeArray

public Edge[] getEdgeArray()
Get an array of the edges in the graph.

Returns:
A newly-allocated array containing the edges in the graph. Note that this is somewhat inefficient, as this array is allocated each time. Note that this array includes an infinite point if there are any infinite edges in the graph.

getNumVertices

public int getNumVertices()
Get the number of vertices in the graph.

Returns:
The number of vertices in the graph.

getVertices

public java.util.Iterator<Point> getVertices()
Get the vertices in the graph.

Returns:
An iterator over the vertices in the graph.

getVertexArray

public Point[] getVertexArray()
Get an array of the vertices in the graph.

Returns:
A newly-allocated array containing the vertices in the graph. Note that this is somewhat inefficient, as this array is allocated each time.

toString

public java.lang.String toString()
Convert this instance to a String suitable for display.

Overrides:
toString in class java.lang.Object
Returns:
String representation of this instance.

dump

public void dump(java.lang.String prefix)
Dump the entire set of edges in this graph to the console.

Parameters:
prefix - Prefix for each output line.