Interface GraphWeightAdapter<W>

All Superinterfaces:
Comparator<W>

public interface GraphWeightAdapter<W> extends Comparator<W>
Adapter for handling generic edge weights in graph algorithms.

Defines the necessary operations (addition, zero, comparison) for algorithms like Dijkstra's shortest path or Minimum Spanning Tree to work with any weight type.

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

  • Method Details

    • zero

      W zero()
      Returns the zero element (identity for addition).
      Returns:
      the zero weight
    • add

      W add(W a, W b)
      Adds two weights.
      Parameters:
      a - the first weight
      b - the second weight
      Returns:
      the sum of a and b
    • compare

      int compare(W a, W b)
      Compares two weights.
      Specified by:
      compare in interface Comparator<W>
      Parameters:
      a - the first weight
      b - the second weight
      Returns:
      negative if a invalid input: '<' b, zero if a = b, positive if a > b