Class AsUnweightedGraph<V,​E>

Type Parameters:
V - the graph vertex type
E - the graph edge type
All Implemented Interfaces:, Graph<V,​E>

public class AsUnweightedGraph<V,​E>
extends GraphDelegator<V,​E>
implements, Graph<V,​E>
Provides an unweighted view on a graph. Algorithms designed for unweighted graphs should also work on weighted graphs. This class emulates an unweighted graph based on a weighted one by returning Graph.DEFAULT_EDGE_WEIGHT for each edge weight. The underlying weighted graph is provided at the constructor. Modifying operations (adding/removing vertexes/edges) are also passed through to the underlying weighted graph. As edge weight, Graph.DEFAULT_EDGE_WEIGHT is used. Setting an edge weight is not supported. The edges are not modified. So, if an edge is asked for, the one from the underlying weighted graph is returned. In case the underlying graph is serializable, this one is serializable, too.
See Also:
Serialized Form
  • Constructor Details

    • AsUnweightedGraph

      public AsUnweightedGraph​(Graph<V,​E> g)
      Constructor for AsUnweightedGraph.
      g - the backing directed graph over which an undirected view is to be created.
      java.lang.NullPointerException - if the graph is null
  • Method Details