|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.hawaii.ics.yucheng.Graph
final class Graph
A weighted, connected, undirected graph. This class is immutable.
Field Summary | |
---|---|
private java.util.ArrayList<Edge> |
myEdges
|
private java.net.URL |
myUrl
|
private float[] |
myVertices
|
Constructor Summary | |
---|---|
Graph(float[] vertices,
java.util.Collection<Edge> edges)
Initializes a new instance of the class. |
|
Graph(java.util.Scanner scanner,
java.net.URL url)
Initializes a new instance of the class. |
Method Summary | |
---|---|
Edge |
edgeAt(int index)
Returns the edge at the specified index. |
int |
edges()
Returns the number of edges. |
java.util.Iterator<Edge> |
iterator()
Returns an iterator for the edges. |
java.lang.String |
toString()
Returns the string representation of the class. |
java.net.URL |
url()
Returns the URL, if one was assigned. |
private static void |
verifyConnectedGraph(Graph graph)
This method verifies a graph is connected. |
private static void |
verifyNoDuplicateEdges(java.util.Collection<Edge> edges)
Verifies the graph has no duplicate edges. |
float |
vertexAt(int index)
Returns the vertex weight at the specified index. |
int |
vertices()
Returns the number of vertices. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private final java.util.ArrayList<Edge> myEdges
private final java.net.URL myUrl
private final float[] myVertices
Constructor Detail |
---|
public Graph(float[] vertices, java.util.Collection<Edge> edges)
vertices
- The vertices.edges
- The edges.public Graph(java.util.Scanner scanner, java.net.URL url) throws GraphException
scanner
- The scanner.url
- The url.
GraphException
- Thrown if there are any errors reading from the
scanner.Method Detail |
---|
private static void verifyConnectedGraph(Graph graph)
graph
- The graph.
GraphException
- if the graph is invalid.private static void verifyNoDuplicateEdges(java.util.Collection<Edge> edges)
edges
- The collection of edges.
GraphException
- if the graph is invalid.public Edge edgeAt(int index)
index
- The index.
public int edges()
public java.util.Iterator<Edge> iterator()
iterator
in interface java.lang.Iterable<Edge>
public java.lang.String toString()
toString
in class java.lang.Object
public java.net.URL url()
public float vertexAt(int index)
index
- The index.
public int vertices()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |