public interface Graph extends Serializable
Note that all methods which return collections return unmodifiable collections; callers that need modifiable collections must copy the unmodifiable collections explicitly using collection constructors (e.g. new ArrayList(graph.getEdgeSet())). The reason is that the returned collections may be owned by the graph and so should not be modified by callers. $Id: Graph.java,v 1.20 2002/08/24 07:31:34 jmsalvo Exp $
| Modifier and Type | Method and Description |
|---|---|
void |
add(Vertex v)
Adds a Vertex into the Graph.
|
void |
addEdge(Edge e)
Adds a previously-defined Edge into the Graph.
|
Edge |
addEdge(Vertex v1,
Vertex v2)
Creates an edge between two vertices and adds it into the Graph.
|
void |
addGraphAddEdgeListener(GraphAddEdgeListener listener)
Deprecated.
Use addListener instead
|
void |
addGraphAddVertexListener(GraphAddVertexListener listener)
Deprecated.
Use addListener instead
|
void |
addGraphRemoveEdgeListener(GraphRemoveEdgeListener listener)
Deprecated.
Use addListener instead
|
void |
addGraphRemoveVertexListener(GraphRemoveVertexListener listener)
Deprecated.
Use addListener instead
|
void |
addListener(GraphListener listener)
Registers a GraphListener with this Graph.
|
List |
cloneVertices()
Returns a modifiable clone of the vertex set as a List in
arbitrary order.
|
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 a 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 an iterator that iterates through the graph's vertices in
arbitrary order.
|
boolean |
isConnected(Vertex v1,
Vertex v2)
Determines if two vertices are connected
|
void |
remove(Vertex v)
Removes the specified Vertex and all of its incident edges from the
Graph.
|
void |
removeEdge(Edge e)
Removes the specified Edge from the Graph, and notifies listeners.
|
void |
removeEdges(Vertex v)
Removes incident Edges of a Vertex.
|
void |
removeGraphAddEdgeListener(GraphAddEdgeListener listener)
Deprecated.
Use removeListener instead
|
void |
removeGraphAddVertexListener(GraphAddVertexListener listener)
Deprecated.
Use removeListener instead
|
void |
removeGraphRemoveEdgeListener(GraphRemoveEdgeListener listener)
Deprecated.
Use removeListener instead
|
void |
removeGraphRemoveVertexListener(GraphRemoveVertexListener listener)
Deprecated.
Use removeListener instead
|
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
|
List |
traverse(Vertex startat)
Traverses the Graph starting at startat Vertex by performing a
depth-first traversal.
|
int getVerticesCount()
GraphFactory getGraphFactory()
void setGraphFactory(GraphFactory factory)
void add(Vertex v) throws Exception
v - Vertex to be added to the GraphExceptionvoid remove(Vertex v) throws Exception
edge - The Edge object to be removed.ExceptionIterator getVerticesIterator()
List cloneVertices()
Set getVertexSet()
Edge addEdge(Vertex v1, Vertex v2) throws Exception
v1 - One endpoint of the edgev2 - Other endpoint of the edgeExceptionvoid addEdge(Edge e) throws Exception
Note: It is the caller's responsibility to make sure that the type of Edge being added to the Graph matches the Graph. For example, only a DirectedEdge must be added to a DirectedGraph.
e - The edge to be added to the Graph.Exceptionvoid removeEdge(Edge e) throws Exception
e - The Edge object to be removed.Exceptionvoid removeEdges(Vertex v) throws Exception
v - Vertex whose Edges are to be removedExceptionSet getEdgeSet()
int getEdgesCount()
int getDegree()
int getDegree(Vertex v)
Set getVertices(int degree)
degree - The degree of the vertex to be returned.List getEdges(Vertex v)
v - The vertex whose edges we want returnedList getAdjacentVertices(Vertex v)
v - The Vertex you want to determine its adjacent vertices.Set getAdjacentVertices(List vertices)
vertices - List of Vertex where each vertex in the returned Set
must be adjacent to.Collection getConnectedSet()
Set getConnectedSet(Vertex v)
v - Vertex to which you want the connected set returned.List traverse(Vertex startat)
startat - The Vertex to which you want to start the traversal.GraphTraversal getTraversal()
void setTraversal(GraphTraversal traversal)
traversal - A concrete implementation of the GraphTraversal object.boolean isConnected(Vertex v1, Vertex v2)
v1 - starting Vertex for the pathv2 - ending Vertex for the pathvoid addListener(GraphListener listener)
listener - the listener being registered, which will receive
notifications of all graph modificationsvoid removeListener(GraphListener listener)
listener - the listener being unregistered, which will
cease receiving notificationsvoid addGraphAddVertexListener(GraphAddVertexListener listener)
listener - GraphAddVertexListener you want registered
or be notified when a new Vertex is addedGraphAddVertexListener,
removeGraphAddVertexListener( GraphAddVertexListener ),
addListener(salvo.jesus.graph.GraphListener)void addGraphAddEdgeListener(GraphAddEdgeListener listener)
listener - GraphAddEdgeListener you want registered
or be notified when a new Edge is addedGraphAddEdgeListener,
removeGraphAddEdgeListener( GraphAddEdgeListener ),
addListener(salvo.jesus.graph.GraphListener)void addGraphRemoveEdgeListener(GraphRemoveEdgeListener listener)
listener - GraphRemoveEdgeListener you want registered
or be notified when an Edge is removedGraphRemoveEdgeListener,
removeGraphRemoveEdgeListener( GraphRemoveEdgeListener ),
addListener(salvo.jesus.graph.GraphListener)void addGraphRemoveVertexListener(GraphRemoveVertexListener listener)
listener - GraphRemoveVertexListener you want registered
or be notified when a Vertex is removedGraphRemoveVertexListener,
removeGraphRemoveVertexListener( GraphRemoveVertexListener ),
addListener(salvo.jesus.graph.GraphListener)void removeGraphAddVertexListener(GraphAddVertexListener listener)
listener - GraphAddVertexListener you no longer want registered
or be notified when a Vertex is addedGraphAddVertexListener,
addGraphAddVertexListener( GraphAddVertexListener ),
removeListener(salvo.jesus.graph.GraphListener)void removeGraphAddEdgeListener(GraphAddEdgeListener listener)
listener - GraphAddEdgeListener you no longer want registered
or be notified when an Edge is addedGraphAddEdgeListener,
addGraphAddEdgeListener( GraphAddEdgeListener ),
removeListener(salvo.jesus.graph.GraphListener)void removeGraphRemoveEdgeListener(GraphRemoveEdgeListener listener)
listener - GraphRemoveEdgeListener you no longer want registered
or be notified when an Edge is removedGraphRemoveEdgeListener,
addGraphRemoveEdgeListener( GraphRemoveEdgeListener ),
removeListener(salvo.jesus.graph.GraphListener)void removeGraphRemoveVertexListener(GraphRemoveVertexListener listener)
listener - GraphRemoveVertexListener you no longer want registered
or be notified when a Vertex is removedGraphRemoveVertexListener,
addGraphRemoveVertexListener( GraphRemoveVertexListener ),
removeListener(salvo.jesus.graph.GraphListener)Copyright © 2019 JULIE Lab, Germany. All rights reserved.