public class GraphImpl extends Object implements Graph
| Modifier and Type | Field and Description |
|---|---|
protected GraphFactory |
factory
Reference to the instance of GraphFactory
responsible for creating Vertices and Edges.
|
protected GraphTraversal |
traversal
Delegate object for implementing graph traversal.
|
| Constructor and Description |
|---|
GraphImpl() |
| Modifier and Type | Method and Description |
|---|---|
void |
add(Vertex newvertex)
This implementation of add(Vertex) should not normally be
overridden by subclasses.
|
void |
addEdge(Edge edge)
This implementation of addEdge should not normally be
overridden by subclasses.
|
Edge |
addEdge(Vertex v1,
Vertex v2)
This implementation of addEdge should not normally be
overridden by subclasses.
|
void |
addGraphAddEdgeListener(GraphAddEdgeListener listener)
Adds a GraphAddEdgeListener to the Graph's internal List of
GraphAddEdgeListeners so that when a new Edge is added,
all registered GraphAddEdgeListeners are notified of the event.
|
void |
addGraphAddVertexListener(GraphAddVertexListener listener)
Adds a GraphAddVertexListener to the Graph's internal List of
GraphAddVertexListeners so that when a new Vertex is added,
all registered GraphAddVertedListeners are notified of the event.
|
void |
addGraphRemoveEdgeListener(GraphRemoveEdgeListener listener)
Adds a GraphRemoveEdgeListener to the Graph's internal List of
GraphRemoveEdgeListeners so that when an Edge is removed,
all registered GraphRemoveEdgeListeners are notified of the event.
|
void |
addGraphRemoveVertexListener(GraphRemoveVertexListener listener)
Adds a GraphRemoveVertexListener to the Graph's internal List of
GraphRemoveVertexListeners so that when a Vertex is removed,
all registered GraphRemoveVertexListeners are notified of the event.
|
void |
addListener(GraphListener listener)
Registers a GraphListener with this Graph.
|
List |
cloneVertices()
Returns a clone of the List of vertices.
|
boolean |
containsEdge(Edge edge)
Test whether an edge is included in this graph.
|
boolean |
containsVertex(Vertex v)
Test whether a vertex is included in this graph.
|
void |
forgetConnectedSets()
Forget any information which has been incrementally maintained
about this graph's connected sets.
|
Set |
getAdjacentVertices(List vertices)
Returns the vertices adjacent to all the vertices in the given
collection.
|
List |
getAdjacentVertices(Vertex v)
Returns the vertices adjacent to the specified vertex.
|
Collection |
getConnectedSet()
Returns the connected sets in the Graph.
|
Set |
getConnectedSet(Vertex v)
Returns the connected set to which the specified vertex belongs.
|
int |
getDegree()
Returns the degree of the graph, which is simply the highest degree
of all the graph's vertices.
|
int |
getDegree(Vertex v)
Returns the degree of the vertex, which is simply the number of edges
of the vertex.
|
List |
getEdges(Vertex v)
Returns an unmodifiable List of edges of the specified vertex.
|
int |
getEdgesCount()
Returns the number of edges in the graph
|
Set |
getEdgeSet()
Returns an unmodifiable set of the edges included in this graph.
|
GraphFactory |
getGraphFactory()
Returns the factory that will be responsible for creating Vertices
and Edges in a Graph.
|
GraphTraversal |
getTraversal()
Gets the traversal algorithm used by the Graph.
|
Set |
getVertexSet()
Returns an unmodifiable set of the vertices included in this graph.
|
Set |
getVertices(int degree)
Returns all vertices with the specified degree.
|
int |
getVerticesCount()
Returns the number of vertices in the graph
|
Iterator |
getVerticesIterator()
Returns a read-only iterator that iterates through the graph's vertices.
|
boolean |
isConnected(Vertex v1,
Vertex v2)
Determines if two vertices are connected
|
void |
remove(Vertex v)
This implementation of remove should not normally be
overridden by subclasses.
|
void |
removeEdge(Edge edge)
This implementation of removeEdge should not normally be
overridden by subclasses.
|
void |
removeEdges(Vertex v)
This implementation of removeEdges should not normally be
overridden by subclasses.
|
void |
removeGraphAddEdgeListener(GraphAddEdgeListener listener)
Removes a GraphAddEdgeListener from the Graph's internal List of
GraphAddEdgeListeners.
|
void |
removeGraphAddVertexListener(GraphAddVertexListener listener)
Removes a GraphAddVertexListener from the Graph's internal List of
GraphAddVertexListeners.
|
void |
removeGraphRemoveEdgeListener(GraphRemoveEdgeListener listener)
Removes a GraphRemoveEdgeListener from the Graph's internal List of
GraphRemoveEdgeListeners.
|
void |
removeGraphRemoveVertexListener(GraphRemoveVertexListener listener)
Removes a GraphRemoveVertexListener from the Graph's internal List of
GraphRemoveVertexListeners.
|
void |
removeListener(GraphListener listener)
Unregisters a GraphListener currently attached to this Graph.
|
void |
setGraphFactory(GraphFactory factory)
Sets the factory that will be responsible for creating Vertices
and Edges in a Graph.
|
void |
setTraversal(GraphTraversal traversal)
Sets the graph traversal algorithm to be used
|
String |
toString()
Returns a String representation of the Graph.
|
List |
traverse(Vertex startat)
Traverses the Graph starting at startat Vertex.
|
protected GraphFactory factory
protected GraphTraversal traversal
public GraphFactory getGraphFactory()
getGraphFactory in interface Graphpublic void setGraphFactory(GraphFactory factory)
setGraphFactory in interface Graphpublic Iterator getVerticesIterator()
getVerticesIterator in interface Graphpublic List cloneVertices()
cloneVertices in interface Graphpublic Set getVertexSet()
GraphgetVertexSet in interface GraphGraph.getVertexSet()public Set getEdgeSet()
GraphgetEdgeSet in interface GraphGraph.getEdgeSet()public boolean containsVertex(Vertex v)
v - the vertex to testpublic boolean containsEdge(Edge edge)
edge - the edge to testpublic List getEdges(Vertex v)
public void add(Vertex newvertex) throws Exception
add in interface Graphnewvertex - Vertex to be added to the GraphExceptionGraph.add(salvo.jesus.graph.Vertex)public Edge addEdge(Vertex v1, Vertex v2) throws Exception
addEdge in interface Graphv1 - One endpoint of the edgev2 - Other endpoint of the edgeExceptionGraph.addEdge(Vertex,Vertex)public void addEdge(Edge edge) throws Exception
addEdge in interface Graphedge - The edge to be added to the Graph.ExceptionGraph.addEdge(Edge)public void remove(Vertex v) throws Exception
remove in interface GraphExceptionGraph.remove(salvo.jesus.graph.Vertex)public void removeEdge(Edge edge) throws Exception
removeEdge in interface Graphedge - The Edge object to be removed.ExceptionGraph.removeEdge(salvo.jesus.graph.Edge)public void removeEdges(Vertex v) throws Exception
removeEdges in interface Graphv - Vertex whose Edges are to be removedExceptionGraph.removeEdges(salvo.jesus.graph.Vertex)public int getVerticesCount()
getVerticesCount in interface Graphpublic int getEdgesCount()
GraphgetEdgesCount in interface GraphGraph.getEdgesCount()public Set getVertices(int degree)
getVertices in interface Graphdegree - The degree of the vertex to be returned.public List getAdjacentVertices(Vertex v)
getAdjacentVertices in interface Graphv - The Vertex you want to determine its adjacent vertices.public Set getAdjacentVertices(List vertices)
getAdjacentVertices in interface Graphvertices - List of Vertex where each vertex in the returned Set
must be adjacent to.public Collection getConnectedSet()
GraphgetConnectedSet in interface GraphGraph.getConnectedSet()public Set getConnectedSet(Vertex v)
GraphgetConnectedSet in interface Graphv - Vertex to which you want the connected set returned.Graph.getConnectedSet(Vertex)public void forgetConnectedSets()
public List traverse(Vertex startat)
public GraphTraversal getTraversal()
getTraversal in interface Graphpublic void setTraversal(GraphTraversal traversal)
setTraversal in interface Graphtraversal - A concrete implementation of the GraphTraversal object.public boolean isConnected(Vertex v1, Vertex v2)
isConnected in interface Graphv1 - starting Vertex for the pathv2 - ending Vertex for the pathpublic int getDegree()
public int getDegree(Vertex v)
public void addListener(GraphListener listener)
GraphaddListener in interface Graphlistener - the listener being registered, which will receive
notifications of all graph modificationspublic void removeListener(GraphListener listener)
GraphremoveListener in interface Graphlistener - the listener being unregistered, which will
cease receiving notificationspublic void addGraphAddVertexListener(GraphAddVertexListener listener)
addGraphAddVertexListener in interface Graphlistener - GraphAddVertexListener you want registered or be
notified when a new Vertex is addedGraphAddVertexListener,
removeGraphAddVertexListener( GraphAddVertexListener )public void addGraphAddEdgeListener(GraphAddEdgeListener listener)
addGraphAddEdgeListener in interface Graphlistener - GraphAddEdgeListener you want registered or be notified
when a new Edge is addedGraphAddEdgeListener,
removeGraphAddEdgeListener( GraphAddEdgeListener )public void addGraphRemoveEdgeListener(GraphRemoveEdgeListener listener)
addGraphRemoveEdgeListener in interface Graphlistener - GraphRemoveEdgeListener you want registered or be
notified when an Edge is removedGraphRemoveEdgeListener,
removeGraphRemoveEdgeListener( GraphRemoveEdgeListener )public void addGraphRemoveVertexListener(GraphRemoveVertexListener listener)
addGraphRemoveVertexListener in interface Graphlistener - GraphRemoveVertexListener you want registered or be
notified when a Vertex is removedGraphRemoveVertexListener,
removeGraphRemoveVertexListener( GraphRemoveVertexListener )public void removeGraphAddVertexListener(GraphAddVertexListener listener)
removeGraphAddVertexListener in interface Graphlistener - GraphAddVertexListener you no longer want registered or
be notified when a Vertex is addedGraphAddVertexListener,
addGraphAddVertexListener( GraphAddVertexListener )public void removeGraphAddEdgeListener(GraphAddEdgeListener listener)
removeGraphAddEdgeListener in interface Graphlistener - GraphAddEdgeListener you no longer want registered or be
notified when an Edge is addedGraphAddEdgeListener,
addGraphAddEdgeListener( GraphAddEdgeListener )public void removeGraphRemoveEdgeListener(GraphRemoveEdgeListener listener)
removeGraphRemoveEdgeListener in interface Graphlistener - GraphRemoveEdgeListener you no longer want registered or
be notified when an Edge is removedGraphRemoveEdgeListener,
addGraphRemoveEdgeListener( GraphRemoveEdgeListener )public void removeGraphRemoveVertexListener(GraphRemoveVertexListener listener)
removeGraphRemoveVertexListener in interface Graphlistener - GraphRemoveVertexListener you no longer want registered
or be notified when a Vertex is removedGraphRemoveVertexListener,
addGraphRemoveVertexListener( GraphRemoveVertexListener )Copyright © 2019 JULIE Lab, Germany. All rights reserved.