public interface WeightedGraph<E extends WeightedEdge> extends Graph<E>
Graph interface to associate each edge
with a numeric value reflecting the strength of connection between the two
vertices.
This interface permits having 0 or negative edge weights.
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(E edge)
Adds an edge between the two vertices, returning
true if the edge
was not previously present or if the edge was previously present
but its weight was changed as a result (optional operation). |
WeightedGraph<E> |
copy(Set<Integer> vertices)
Creates a copy of this graph containing only the specified number of
vertices and all edges between those vertices.
|
Set<E> |
edges()
Returns the set of edges contained in this graph.
|
Set<E> |
getAdjacencyList(int vertex)
Returns the set of edges connected to the provided vertex.
|
Set<E> |
getEdges(int vertex1,
int vertex2)
Returns the
Edge instances connecting the two vertices or an
empty set if the vertices are not connected. |
double |
strength(int vertex)
Returns the sum of the weights for all edges connected to this vertex.
|
WeightedGraph<E> |
subgraph(Set<Integer> vertices)
Returns a view of this graph containing only the specified vertices where
the returned graph's vertinces are renamed (0, ..., n).
|
boolean add(E edge)
true if the edge
was not previously present or if the edge was previously present
but its weight was changed as a result (optional operation). Adding an
edge with the same vertice will not create a parallel edge, but will
instead update the weight of that edge with the weight from most recently
added.add in interface Graph<E extends WeightedEdge>true if the edge was not previously present or if
the edge was previously present but its weight was changed as a
result#containsEdge(int, int)WeightedGraph<E> copy(Set<Integer> vertices)
vertices is
empty a new, empty graph of this instance's type is returned. Any
changes made to this graph will not be reflected in returned copy or
vice-versa.copy in interface Graph<E extends WeightedEdge>Set<E> edges()
edges in interface Graph<E extends WeightedEdge>Set<E> getAdjacencyList(int vertex)
getAdjacencyList in interface Graph<E extends WeightedEdge>Set<E> getEdges(int vertex1, int vertex2)
Edge instances connecting the two vertices or an
empty set if the vertices are not connected.getEdges in interface Graph<E extends WeightedEdge>double strength(int vertex)
0 is returned.WeightedGraph<E> subgraph(Set<Integer> vertices)
Only edges connecting two vertices in the provided set will be viewable in the subgraph. Any changes to the subgraph will be reflected in this graph and vice versa.
This view allows for direct manipulation of a part of the graph. For example, clearing this subgraph will remove all of its corresponding vertices and edges from the backing graph.
subgraph in interface Graph<E extends WeightedEdge>vertices - the vertices to include in the subgraphCopyright © 2012. All Rights Reserved.