|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectsalvo.jesus.graph.GraphImpl
salvo.jesus.graph.DirectedGraphImpl
public class DirectedGraphImpl
A directed Graph where edges have a specified direction. Edges in this graph are therefore instances of DirectedEdge.
Field Summary | |
---|---|
(package private) DirectedGraphWeakImpl |
graphDirectionDelegate
Delegate object to handle the implementation of the DirectedGraph interface. |
Fields inherited from class salvo.jesus.graph.GraphImpl |
---|
addedgelistener, addvertexlistener, connectedSetS, edges, removeedgelistener, removevertexlistener, traversal, vertices |
Constructor Summary | |
---|---|
DirectedGraphImpl()
Creates a new instance of an empty directed Graph. |
|
DirectedGraphImpl(DirectedGraphImpl toBeCopied)
|
Method Summary | |
---|---|
void |
add(Vertex newvertex)
Adds a Vertex into the Graph. |
void |
addEdge(Edge edge)
Adds an Edge into the Graph. |
Edge |
addEdge(Vertex v1,
Vertex v2)
Adds an Edge into the Graph. |
java.lang.Object |
clone()
|
Edge |
createEdge(Vertex v1,
Vertex v2)
Factory method implementation that creates an instance of a DirectedEdge. |
DirectedEdge |
getEdge(Vertex fromvertex,
Vertex tovertex)
Returns an Edge in the Graph whose origin is fromVertex and destination is toVertex. |
java.util.Collection |
getIncomingAdjacentVertices(Vertex v)
Returns the vertices that are adjacent to a specified Vertex where the Edge is incoming from the specified Vertex to the adjacent vertex. |
protected java.util.Map |
getIncomingEdges()
Returns the incoming EdgeSets of the Graph. |
java.util.Collection |
getIncomingEdges(Vertex v)
Returns the incoming edges of a particular Vertex in the Graph. |
java.util.Collection |
getOutgoingAdjacentVertices(Vertex v)
Returns the vertices that are adjacent to a specified Vertex where the Edge is outgoing from the specified Vertex to the adjacent vertex. |
protected java.util.Map |
getOutgoingEdges()
Returns the outgoing EdgeSets of the Graph. |
java.util.Collection |
getOutgoingEdges(Vertex v)
Returns the outgoing edges of a particular Vertex in the Graph. |
boolean |
isCycle(Vertex fromVertex)
Determines if there is a cycle from Vertex fromVertex. |
boolean |
isPath(Vertex fromVertex,
Vertex toVertex)
Determines if there is a path from Vertex fromVertex to Vertex toVertex. |
void |
remove(Vertex vertex)
Removes a Vertex from the Graph. |
void |
removeEdge(Edge edge)
Removes an Edge from the Graph. |
java.lang.String |
toString()
Returns a String representation of the Graph. |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
DirectedGraphWeakImpl graphDirectionDelegate
Constructor Detail |
---|
public DirectedGraphImpl()
public DirectedGraphImpl(DirectedGraphImpl toBeCopied)
Method Detail |
---|
public java.lang.Object clone()
clone
in class GraphImpl
protected java.util.Map getOutgoingEdges()
protected java.util.Map getIncomingEdges()
public java.util.Collection getOutgoingEdges(Vertex v)
getOutgoingEdges
in interface DirectedGraph
v
- Vertex you want to determine its outgoing edges.
public java.util.Collection getIncomingEdges(Vertex v)
getIncomingEdges
in interface DirectedGraph
v
- Vertex you want to determine its incoming edges.
public java.util.Collection getOutgoingAdjacentVertices(Vertex v)
getOutgoingAdjacentVertices
in interface DirectedGraph
v
- Vertex you want to determine its outgoing adjacent vertices.
public java.util.Collection getIncomingAdjacentVertices(Vertex v)
getIncomingAdjacentVertices
in interface DirectedGraph
v
- Vertex you want to determine its incoming adjacent vertices.
public DirectedEdge getEdge(Vertex fromvertex, Vertex tovertex)
getEdge
in interface DirectedGraph
fromVertex
- Vertex that is the origin of the directed EdgetoVertex
- Vertex that is the destination of the directed Edge
Edge
public void add(Vertex newvertex) throws java.lang.Exception
add
in interface Graph
add
in class GraphImpl
newvertex
- The Vertex object to be added to the graph.
java.lang.Exception
public Edge createEdge(Vertex v1, Vertex v2)
createEdge
in interface Graph
createEdge
in class GraphImpl
v1
- One endpoint of the vertexv2
- The other endpoint of the vertexpublic Edge addEdge(Vertex v1, Vertex v2) throws java.lang.Exception
addEdge
in interface Graph
addEdge
in class GraphImpl
fromVertex
- Vertex that will be the source of the EdgetoVertex
- Vertex that will be the sink of the Edge
java.lang.Exception
public void addEdge(Edge edge) throws java.lang.Exception
In the event that any one of the vertices are not existing in the Graph, they are added to the Graph.
Note: It is the caller's responsibility to make sure that the type of Edge being added is an DirectedEdgeImpl.
addEdge
in interface Graph
addEdge
in class GraphImpl
e
- The edge to be added to the Graph.
java.lang.Exception
public void removeEdge(Edge edge) throws java.lang.Exception
removeEdge
in interface Graph
removeEdge
in class GraphImpl
edge
- Edge to be removed from the Graph
java.lang.Exception
public void remove(Vertex vertex) throws java.lang.Exception
remove
in interface Graph
remove
in class GraphImpl
vertex
- Vertex to be removed
java.lang.Exception
public boolean isPath(Vertex fromVertex, Vertex toVertex)
isPath
in interface DirectedGraph
fromVertex
- starting Vertex for the pathtoVertex
- ending Vertex for the path
public boolean isCycle(Vertex fromVertex)
isCycle
in interface DirectedGraph
fromVertex
- Vertex to be tested for a cycle path.
public java.lang.String toString()
toString
in class GraphImpl
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |