|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
V
- The vertices in this graph.public interface UndirectedGraph<V>
An undirected weighted graph.
Nested Class Summary | |
---|---|
static interface |
UndirectedGraph.Edge<V>
A possible edge connecting two vertices of an underlying UndirectedGraph. |
Field Summary | |
---|---|
static double |
DEFAULT_UNCONNECTED_WEIGHT
The default weight for two not connected vertices. |
Method Summary | |
---|---|
boolean |
addVertex(V vertex)
Adds a vertex to the graph. |
UndirectedGraph<V> |
clone()
|
boolean |
containsEdge(V vertexA,
V vertexB)
Check if there exists an edge in the graph connecting the two vertices given as parameters. |
boolean |
containsVertex(V vertex)
Checks if given vertex is contained in the graph. |
UndirectedGraph.Edge<V> |
getEdge(V vertexA,
V vertexB)
Returns the Edge connecting the two vertices. |
java.util.Iterator<? extends UndirectedGraph.Edge<V>> |
getEdges()
Returns an iterator over all edges of the graph. |
java.util.Iterator<? extends UndirectedGraph.Edge<V>> |
getEdgesConnectedTo(V vertex)
Returns an iterator over all edges in the graph that are connected to given vertex |
double |
getEdgeWeight(V vertexA,
V vertexB)
Returns the weight of the edge connecting the two vertices. |
double |
getMass(V vertex)
Returns the sum of the weights of all edges connected to given vertex. |
int |
getNumberOfEdges()
Returns the number of edges. |
int |
getNumberOfEdgesConnectedTo(V vertex)
Returns the number of edges connected to given vertex. |
int |
getNumberOfVertices()
Returns the number of vertices. |
double |
getUnconnectedWeight()
Returns the default weight for unconnected vertices. |
java.util.Iterator<V> |
getVertices()
Returns an iterator over all current vertices of this graph. |
java.util.Iterator<V> |
getVerticesConnectedTo(V vertex)
Returns an iterator over all vertices that are connected with given vertex at the moment of this call. |
double |
removeEdge(V vertexA,
V vertexB)
Removes the edge determined by two vertices. |
boolean |
removeVertex(V vertex)
Remove a vertex from the graph. |
double |
setEdgeWeight(V vertexA,
V vertexB,
double weight)
Sets the weight of a edge determined by two vertices. |
void |
setUnconnectedWeight(double unconnectedWeight)
Change the weight that is returned by getEdgeWeight(Object, Object) if the two vertices are not connected. |
Methods inherited from interface java.lang.Iterable |
---|
iterator |
Field Detail |
---|
static final double DEFAULT_UNCONNECTED_WEIGHT
Method Detail |
---|
void setUnconnectedWeight(double unconnectedWeight)
unconnectedWeight
- the new weight for unconnected vertices.getEdgeWeight(Object, Object)
,
getUnconnectedWeight()
double getUnconnectedWeight()
Returns the default weight for unconnected vertices.
The method getEdgeWeight(Object, Object) returns a double value for any possible edge connecting two vertices in the graph. If an edge does not exist, the method will return this value.
getEdgeWeight(Object, Object)
,
setUnconnectedWeight(double)
int getNumberOfVertices()
int getNumberOfEdges()
int getNumberOfEdgesConnectedTo(V vertex) throws java.lang.NullPointerException, java.util.NoSuchElementException
vertex
- which vertex to count edges of.
java.util.NoSuchElementException
- if the vertex is not part of the
graph.
java.lang.NullPointerException
- if vertex is null.boolean addVertex(V vertex) throws java.lang.NullPointerException
vertex
- the vertex to be added.
java.lang.NullPointerException
- if vertex is null.boolean removeVertex(V vertex) throws java.lang.NullPointerException
vertex
- the vertex to be removed.
java.lang.NullPointerException
- if vertex is null.java.util.Iterator<V> getVertices()
Iterable.iterator()
,
getNumberOfEdges()
java.util.Iterator<V> getVerticesConnectedTo(V vertex) throws java.lang.NullPointerException, java.util.NoSuchElementException
vertex
- the vertex.
java.util.NoSuchElementException
- if the vertex is not part of the
graph.
java.lang.NullPointerException
- if vertex is null.getNumberOfEdges()
double getMass(V vertex) throws java.lang.NullPointerException, java.util.NoSuchElementException
vertex
- the vertex.
java.util.NoSuchElementException
- if the vertex is not part of the
graph.
java.lang.NullPointerException
- if vertex is null.double setEdgeWeight(V vertexA, V vertexB, double weight) throws java.lang.NullPointerException, java.util.NoSuchElementException
Sets the weight of a edge determined by two vertices. If the new weight is the value returned by getUnconnectedWeight(), this is be the same as calling removeEdge(Object, Object).
The old weight of the edge is returned, which may be the same as getUnconnectedWeight(), if the edge had not existed.
vertexA
- one vertex of the edge.vertexB
- the other vertex of the edge.weight
- the new weight of the edge.
java.util.NoSuchElementException
- if at least one of the two vertices is
not a part of the graph.
java.lang.NullPointerException
- if at least one vertex is null.containsVertex(Object)
,
getUnconnectedWeight()
,
getEdgeWeight(Object, Object)
,
removeEdge(Object, Object)
double removeEdge(V vertexA, V vertexB) throws java.lang.NullPointerException, java.util.NoSuchElementException
vertexA
- one vertex of the edge.vertexB
- the other vertex of the edge.
java.util.NoSuchElementException
- if at least one of the two vertices is
not a part of the graph.
java.lang.NullPointerException
- if at least one vertex is null.containsEdge(Object, Object)
,
containsVertex(Object)
,
getEdgeWeight(Object, Object)
,
getUnconnectedWeight()
,
setEdgeWeight(Object, Object, double)
java.util.Iterator<? extends UndirectedGraph.Edge<V>> getEdges()
getNumberOfEdges()
java.util.Iterator<? extends UndirectedGraph.Edge<V>> getEdgesConnectedTo(V vertex) throws java.lang.NullPointerException, java.util.NoSuchElementException
vertex
- the vertex.
java.util.NoSuchElementException
- if the vertex is not part of the
graph.
java.lang.NullPointerException
- if the vertex is null.getNumberOfEdges()
boolean containsVertex(V vertex) throws java.lang.NullPointerException
vertex
- the vertex to look for.
java.lang.NullPointerException
- if vertex is null.boolean containsEdge(V vertexA, V vertexB) throws java.lang.NullPointerException, java.util.NoSuchElementException
vertexA
- one vertex.vertexB
- the other vertex.
java.util.NoSuchElementException
- if at least one of the vertices is not
part of the graph.
java.lang.NullPointerException
- if one of the vertices is null.double getEdgeWeight(V vertexA, V vertexB) throws java.lang.NullPointerException, java.util.NoSuchElementException
vertexA
- one vertex.vertexB
- the other vertex.
java.util.NoSuchElementException
- if at least one of the vertices is not
part of the graph.
java.lang.NullPointerException
- if one of the vertices is null.containsEdge(Object, Object)
,
getEdge(Object, Object)
,
getUnconnectedWeight()
UndirectedGraph.Edge<V> getEdge(V vertexA, V vertexB) throws java.lang.NullPointerException, java.util.NoSuchElementException
vertexA
- one vertex.vertexB
- the other vertex.
java.util.NoSuchElementException
- if at least one of the vertices is not
part of the graph.
java.lang.NullPointerException
- if one of the vertices is null.UndirectedGraph.Edge
,
containsEdge(Object, Object)
,
getEdgeWeight(Object, Object)
UndirectedGraph<V> clone()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |