V
- public interface Graph<V>
Modifier and Type | Method and Description |
---|---|
boolean |
areAdjacent(CS16Vertex<V> v1,
CS16Vertex<V> v2)
For a directed graph, returns true if there exists an Edge that starts on v1 and ends on v2. For an undirected graph, returns true if there is an edge between v1 and v2.
|
void |
clear()
Clears all the vertices and edges from the graph.
|
CS16Edge<V> |
connectingEdge(CS16Vertex<V> v1,
CS16Vertex<V> v2)
Returns the edge that connects the two vertices.
|
java.util.Iterator<CS16Edge<V>> |
edges()
Returns an iterator holding all the edges of the graph.
|
java.util.List<CS16Vertex<V>> |
endVertices(CS16Edge<V> edge)
Returns the two Vertices that the Edge e is connected to.
|
java.util.Iterator<CS16Edge<V>> |
incomingEdges(CS16Vertex<V> vert)
Returns an Iterator over all the Edges that end on this Vertex.
|
CS16Edge<V> |
insertEdge(CS16Vertex<V> v1,
CS16Vertex<V> v2,
java.lang.Integer edgeElement)
Inserts a new Edge into your Graph.
|
CS16Vertex<V> |
insertVertex(V vertElement)
Inserts a Vertex into the graph.
|
CS16Vertex<V> |
opposite(CS16Vertex<V> vert,
CS16Edge<V> edge)
Returns the Vertex that is on the other side of Edge e opposite of Vertex
v.
|
java.lang.Integer |
removeEdge(CS16Edge<V> edge)
Removes an Edge from your Graph.
|
V |
removeVertex(CS16Vertex<V> vert)
Removes a Vertex from your graph.
|
java.util.Iterator<CS16Vertex<V>> |
vertices()
Returns an iterator holding all the Vertices of the graph.
|
java.util.Iterator<CS16Edge<V>> |
outgoingEdges(CS16Vertex<V> vert)
Returns an Iterator over all the Edges that start on this Vertex.
|
boolean areAdjacent(CS16Vertex<V> v1, CS16Vertex<V> v2) throws InvalidVertexException
v1
- The first Vertex to test adjacency.v2
- The second Vertex to test adjacency.InvalidVertexException
- Thrown if either vertex is invalid.void clear()
CS16Edge<V> connectingEdge(CS16Vertex<V> v1, CS16Vertex<V> v2) throws InvalidVertexException, NoSuchEdgeException
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.java.util.Iterator<CS16Edge<V>> edges()
java.util.List<CS16Vertex<V>> endVertices(CS16Edge<V> edge) throws InvalidEdgeException
edge
- The edge to find the connecting Vertex's on.InvalidEdgeException
- Thrown when the Edge e is not valid.java.util.Iterator<CS16Edge<V>> incomingEdges(CS16Vertex<V> vert) throws InvalidVertexException
vert
- The vertex to find the incoming edges on.InvalidVertexException
- Thrown when the Vertex is not valid.java.util.Iterator<CS16Edge<V>> outgoingEdges(CS16Vertex<V> vert) throws InvalidVertexException
vert
- The vertex to find the outgoing edges on.InvalidVertexException
- Thrown when the Vertex is not valid.CS16Edge<V> insertEdge(CS16Vertex<V> v1, CS16Vertex<V> v2, java.lang.Integer edgeElement)
v1
- The first vertex of the edge connection.v2
- The second vertex of the edge connection.edgeElement
- The element of the newly inserted edge. For an unweighted edge, use null element.InvalidVertexException
- Thrown when the Vertex is not valid.CS16Vertex<V> insertVertex(V vertElement)
vertElement
- The element of the inserted Vertex.CS16Vertex<V> opposite(CS16Vertex<V> vert, CS16Edge<V> edge) throws InvalidVertexException, InvalidEdgeException, NoSuchVertexException
vert
- The first vertex on Edge e.edge
- The edge connecting Vertex v and the unknown opposite Vertex.InvalidVertexException
- Thrown when the Vertex is not valid.InvalidEdgeException
- Thrown when the Edge is not valid.NoSuchVertexException
- Thrown when Edge e is not incident on v.java.lang.Integer removeEdge(CS16Edge<V> edge) throws InvalidEdgeException
edge
- The Edge to remove.InvalidEdgeException
- Thrown when the Edge is not valid.V removeVertex(CS16Vertex<V> vert) throws InvalidVertexException
vert
- The Vertex to remove.InvalidVertexException
- Thrown when the Vertex is not valid.java.util.Iterator<CS16Vertex<V>> vertices()