org.jgrapht.graph

## Class AsUnweightedGraph<V,E>

- java.lang.Object
- - org.jgrapht.graph.AbstractGraph<V,E>
  - - org.jgrapht.graph.GraphDelegator<V,E>
    - - org.jgrapht.graph.AsUnweightedGraph<V,E>

- All Implemented Interfaces:
    Serializable, Graph<V,E>
  Direct Known Subclasses:
    AsUnweightedDirectedGraph

      public 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 directed 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.

  Since:
    Sep 7, 2007
  Author:
    Lucas J. Scharenbroich
  See Also:
    Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `AsUnweightedGraph(Graph<V,E> g)` Constructor for AsUnweightedGraph.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `double` | `getEdgeWeight(E e)` Returns the weight assigned to a given edge.

    - ### Methods inherited from class org.jgrapht.graph.GraphDelegator

      `addEdge, addEdge, addVertex, containsEdge, containsVertex, degreeOf, edgeSet, edgesOf, getAllEdges, getEdge, getEdgeFactory, getEdgeSource, getEdgeTarget, incomingEdgesOf, inDegreeOf, outDegreeOf, outgoingEdgesOf, removeEdge, removeEdge, removeVertex, setEdgeWeight, toString, vertexSet`

    - ### Methods inherited from class org.jgrapht.graph.AbstractGraph

      `assertVertexExist, containsEdge, equals, hashCode, removeAllEdges, removeAllEdges, removeAllEdges, removeAllVertices, toStringFromSets`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface org.jgrapht.Graph

      `containsEdge, removeAllEdges, removeAllEdges, removeAllVertices`

- - ### Constructor Detail

    - #### AsUnweightedGraph

          public AsUnweightedGraph(Graph<V,E> g)

      Constructor for AsUnweightedGraph.
      Parameters:
        `g` - the backing graph over which an unweighted view is to be created.

  - ### Method Detail

    - #### getEdgeWeight

          public double getEdgeWeight(E e)

      Description copied from interface: `Graph`
      Returns the weight assigned to a given edge. Unweighted graphs return 1.0 (as defined by `WeightedGraph.DEFAULT_EDGE_WEIGHT`), allowing weighted-graph algorithms to apply to them where meaningful.
      Specified by:
        `getEdgeWeight` in interface `Graph<V,E>`
      Overrides:
        `getEdgeWeight` in class `GraphDelegator<V,E>`
      Parameters:
        `e` - edge of interest
      Returns:
        edge weight
      See Also:
        `Graph.getEdgeWeight(E)`

Copyright © 2016. All rights reserved.