Class Graph.WeightedEdge<V,E>

java.lang.Object
Graph.Edge<V,E>
Graph.WeightedEdge<V,E>
Enclosing class:
Graph<V,E>

public static class Graph.WeightedEdge<V,E> extends Graph.Edge<V,E>
An extension of the Edge class that also tracks a double for the associated weight of the edge.
  • Constructor Details

    • WeightedEdge

      public WeightedEdge(Graph.Vertex<V,E> u, Graph.Vertex<V,E> v, double weight)
      Created a weighted edge with the given endpoints and weight.
      Parameters:
      u - an endpoint of this edge
      v - an endpoint of this edge
      weight - the weight of this edge
    • WeightedEdge

      public WeightedEdge(Graph.Vertex<V,E> u, Graph.Vertex<V,E> v, double weight, E data)
      Creates a weighted edge with the specified endpoints, weight, and data.
      Parameters:
      u - an endpoint of this edge
      v - an endpoint of this edge
      weight - the weight of this edge
      data - the associated data of this edge
    • WeightedEdge

      public WeightedEdge(Graph.Vertex<V,E> u, Graph.Vertex<V,E> v, double weight, boolean directed)
      Creates a weighted edge with the associated end points and data.

      If directed is true, this edge is directed from u to v. Otherwise, this edge is undirected.

      Parameters:
      u - an endpoint of this edge
      v - an endpoint of this edge
      weight - the weight of this edge
      directed - whether this edge is to be directed
    • WeightedEdge

      public WeightedEdge(Graph.Vertex<V,E> u, Graph.Vertex<V,E> v, double weight, boolean directed, E data)
      Creates a weighted edge with the associated endpoints, weight, and data.

      If directed is true, this edge is directed from u to v. Otherwise, this edge is undirected.

      Parameters:
      u - an endpoint of this edge
      v - an endpoint of this edge
      weight - the weight of this edge
      directed - whether this edge is to be directed
      data - the data of this edge
  • Method Details

    • reverse

      public Graph.WeightedEdge<V,E> reverse()
      Description copied from class: Graph.Edge
      Returns an edge that is the reverse of this edge.

      If this edge is directed, the edge returned by this method will be directed in the opposite direction.

      Overrides:
      reverse in class Graph.Edge<V,E>
      Returns:
      an edge that is the reverse of this edge.
    • toString

      public String toString()
      Overrides:
      toString in class Graph.Edge<V,E>