|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgraph.MyGraph
public class MyGraph
Field Summary |
---|
Fields inherited from interface support.graph.AdjacencyMatrixGraph |
---|
MAX_VERTICES |
Constructor Summary | |
---|---|
MyGraph()
Constructor for your Graph, where among other things, you will most likely want to instantiate your matrix array, and your NodeSequence's. |
Method Summary | |
---|---|
boolean |
areAdjacent(CS16Vertex v1,
CS16Vertex v2)
Returns true if there exists an Edge that connects Vertex v1 and Vertex v2. |
void |
clear()
Clears all the vertices and edges from the graph. |
CS16Edge |
connectingEdge(CS16Vertex v1,
CS16Vertex v2)
Returns the edge that connects the two vertices. |
java.util.Iterator<CS16Edge> |
edges()
Returns an iterator holding all the Edge's of the graph. |
CS16Vertex[] |
endVertices(CS16Edge e)
Returns the two Vertex's that the Edge e is incident upon. |
java.util.Iterator<CS16Edge> |
incidentEdges(CS16Vertex v)
Returns an Iterator over all the Edges that are connected to this Vertex. |
CS16Edge |
insertEdge(CS16Vertex v1,
CS16Vertex v2,
java.lang.Object edgeElement)
Inserts a new Edge into your Graph. |
CS16Vertex |
insertVertex(java.lang.Object vertElement)
Inserts a new Vertex into your Graph. |
CS16Vertex |
opposite(CS16Vertex v,
CS16Edge e)
Returns the Vertex that is on the other side of Edge e opposite of Vertex v. |
java.lang.Object |
removeEdge(CS16Edge e)
Removes an Edge from your Graph. |
java.lang.Object |
removeVertex(CS16Vertex v)
Removes a Vertex from your graph. |
java.util.Iterator<CS16Vertex> |
vertices()
Returns an iterator holding all the Vertex's of the graph. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MyGraph()
NodeSequence
Method Detail |
---|
public CS16Vertex insertVertex(java.lang.Object vertElement)
insertVertex
in interface AdjacencyMatrixGraph
vertElement
- The element of the inserted Vertex.
public CS16Edge insertEdge(CS16Vertex v1, CS16Vertex v2, java.lang.Object edgeElement) throws InvalidVertexException
insertEdge
in interface AdjacencyMatrixGraph
v1
- The first vertex of the edge connection.v2
- The second vertex of the edge connection.edgeElement
- The element of the newly inserted edge.
InvalidVertexException
- Thrown when the Vertex is not valid.public java.lang.Object removeVertex(CS16Vertex v) throws InvalidVertexException
removeVertex
in interface AdjacencyMatrixGraph
v
- The Vertex to remove.
InvalidVertexException
- Thrown when the Vertex is not valid.public java.lang.Object removeEdge(CS16Edge e) throws InvalidEdgeException
removeEdge
in interface AdjacencyMatrixGraph
e
- The Edge to remove.
InvalidEdgeException
- Thrown when the Edge is not valid.public CS16Edge connectingEdge(CS16Vertex v1, CS16Vertex v2) throws InvalidVertexException, NoSuchEdgeException
connectingEdge
in interface AdjacencyMatrixGraph
v1
- The first vertex that may be connected.v2
- The second vertex that may be connected.
InvalidVertexException
- Thrown when either vertex is invalid.
NoSuchEdgeException
- Thrown when no edge connects the vertices.public java.util.Iterator<CS16Edge> incidentEdges(CS16Vertex v) throws InvalidVertexException
incidentEdges
in interface AdjacencyMatrixGraph
v
- The vertex to find the incident edges on.
InvalidVertexException
- Thrown when the Vertex is not valid.This must run in O(n) time;
public CS16Vertex opposite(CS16Vertex v, CS16Edge e) throws InvalidVertexException, InvalidEdgeException, NoSuchVertexException
opposite
in interface AdjacencyMatrixGraph
v
- The first vertex on Edge e.e
- The edge connecting Vertex v and the uknown opposite Vertex.
InvalidVertexException
- Thrown when the Vertex is not valid.
InvalidEdgeException
- Thrown when the Edge isnot valid.
NoSuchVertexException
- Thrown when Edge e is not incident on v.public CS16Vertex[] endVertices(CS16Edge e) throws InvalidEdgeException
endVertices
in interface AdjacencyMatrixGraph
e
- The edge to find the connecting Vertex's on.
InvalidEdgeException
- Thrown when the Edge e is not valid.public boolean areAdjacent(CS16Vertex v1, CS16Vertex v2) throws InvalidVertexException
areAdjacent
in interface AdjacencyMatrixGraph
v1
- The first Vertex to test adjacency.v2
- The second Vertex to test adjacency.
InvalidVertexException
- Thrown if either vertex is invalid.public java.util.Iterator<CS16Edge> edges()
edges
in interface AdjacencyMatrixGraph
This must run in O(m) time.
public java.util.Iterator<CS16Vertex> vertices()
vertices
in interface AdjacencyMatrixGraph
This must run in O(n) time.
public void clear()
clear
in interface AdjacencyMatrixGraph
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |