Interface WeightedEdge<V,W>

All Known Implementing Classes:
DefaultWeightedEdge

public interface WeightedEdge<V,W>
An edge in a weighted graph.

Represents a directed edge from a source vertex to a target vertex with an associated weight. Can also represent undirected edges.

Since:
1.0
Author:
Silvere Martin-Michiellot, Gemini AI (Google DeepMind)
  • Method Summary

    Modifier and Type
    Method
    Description
    default boolean
    connects(V u, V v)
    Checks if this edge connects the given vertices.
    Returns the source vertex of this edge.
    Returns the target vertex of this edge.
    Returns the weight of this edge.
    default boolean
    isIncidentTo(V vertex)
    Checks if this edge is incident to the given vertex.
  • Method Details

    • getSource

      V getSource()
      Returns the source vertex of this edge.
      Returns:
      the source vertex
    • getTarget

      V getTarget()
      Returns the target vertex of this edge.
      Returns:
      the target vertex
    • getWeight

      W getWeight()
      Returns the weight of this edge.
      Returns:
      the edge weight
    • connects

      default boolean connects(V u, V v)
      Checks if this edge connects the given vertices.

      For undirected interpretation, returns true if the edge connects u to v OR v to u.

      Parameters:
      u - the first vertex
      v - the second vertex
      Returns:
      true if this edge connects u and v (in either direction)
    • isIncidentTo

      default boolean isIncidentTo(V vertex)
      Checks if this edge is incident to the given vertex.
      Parameters:
      vertex - the vertex to check
      Returns:
      true if vertex is source or target