Package smile.graph

Record Class Graph.Edge

java.lang.Object
java.lang.Record
smile.graph.Graph.Edge
Record Components:
u - the vertex id. For directed graph, this is the tail of arc.
v - the other vertex id. For directed graph, this is the head of arc.
weight - the weight of edge. For unweighted graph, this is always 1.
All Implemented Interfaces:
Comparable<Graph.Edge>
Enclosing class:
Graph

public static record Graph.Edge(int u, int v, double weight) extends Record implements Comparable<Graph.Edge>
Graph edge.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Edge(int u, int v)
    Constructor of unweighted edge.
    Edge(int u, int v, double weight)
    Creates an instance of a Edge record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
     
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    final String
    Returns a string representation of this record class.
    int
    u()
    Returns the value of the u record component.
    int
    v()
    Returns the value of the v record component.
    double
    Returns the value of the weight record component.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Edge

      public Edge(int u, int v)
      Constructor of unweighted edge.
      Parameters:
      u - the vertex id.
      v - the other vertex id.
    • Edge

      public Edge(int u, int v, double weight)
      Creates an instance of a Edge record class.
      Parameters:
      u - the value for the u record component
      v - the value for the v record component
      weight - the value for the weight record component
  • Method Details

    • compareTo

      public int compareTo(Graph.Edge o)
      Specified by:
      compareTo in interface Comparable<Graph.Edge>
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • u

      public int u()
      Returns the value of the u record component.
      Returns:
      the value of the u record component
    • v

      public int v()
      Returns the value of the v record component.
      Returns:
      the value of the v record component
    • weight

      public double weight()
      Returns the value of the weight record component.
      Returns:
      the value of the weight record component