V
- the graph vertex typeE
- the graph edge typepublic class AsUnweightedGraph<V,E> extends GraphDelegator<V,E> implements Serializable
An unweighted view of the backing weighted graph specified in the constructor. This graph allows modules to apply algorithms designed for unweighted graphs to a weighted graph by simply ignoring edge weights. Query operations on this graph "read through" to the backing graph. Vertex addition/removal and edge addition/removal are all supported (and immediately reflected in the backing graph).
Note that edges returned by this graph's accessors are really just the edges of the underlying graph.
This graph does not pass the hashCode and equals operations through to the backing graph, but relies on Object's equals and hashCode methods. This graph will be serializable if the backing graph is serializable.
DEFAULT_EDGE_WEIGHT
Constructor and Description |
---|
AsUnweightedGraph(Graph<V,E> g)
Constructor
|
Modifier and Type | Method and Description |
---|---|
double |
getEdgeWeight(E e)
Returns the weight assigned to a given edge.
|
GraphType |
getType()
Get the graph type.
|
void |
setEdgeWeight(E e,
double weight)
Assigns a weight to an edge.
|
addEdge, addEdge, addVertex, addVertex, containsEdge, containsVertex, degreeOf, edgeSet, edgesOf, getAllEdges, getDelegate, getEdge, getEdgeFactory, getEdgeSource, getEdgeSupplier, getEdgeTarget, getVertexSupplier, incomingEdgesOf, inDegreeOf, outDegreeOf, outgoingEdgesOf, removeEdge, removeEdge, removeVertex, toString, vertexSet
assertVertexExist, containsEdge, equals, hashCode, removeAllEdges, removeAllEdges, removeAllEdges, removeAllVertices, toStringFromSets
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
containsEdge, removeAllEdges, removeAllEdges, removeAllVertices
public double getEdgeWeight(E e)
Graph.DEFAULT_EDGE_WEIGHT
), allowing weighted-graph algorithms to apply to them when
meaningful.getEdgeWeight
in interface Graph<V,E>
getEdgeWeight
in class GraphDelegator<V,E>
e
- edge of interestpublic void setEdgeWeight(E e, double weight)
setEdgeWeight
in interface Graph<V,E>
setEdgeWeight
in class GraphDelegator<V,E>
e
- edge on which to set weightweight
- new weight for edgepublic GraphType getType()
Copyright © 2018. All rights reserved.