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
-
Method Summary
Modifier and TypeMethodDescriptionint
final boolean
Indicates whether some other object is "equal to" this one.final int
hashCode()
Returns a hash code value for this object.final String
toString()
Returns a string representation of this record class.int
u()
Returns the value of theu
record component.int
v()
Returns the value of thev
record component.double
weight()
Returns the value of theweight
record component.
-
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 aEdge
record class.
-
-
Method Details
-
compareTo
- Specified by:
compareTo
in interfaceComparable<Graph.Edge>
-
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. -
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. -
equals
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 '=='. -
u
public int u()Returns the value of theu
record component.- Returns:
- the value of the
u
record component
-
v
public int v()Returns the value of thev
record component.- Returns:
- the value of the
v
record component
-
weight
public double weight()Returns the value of theweight
record component.- Returns:
- the value of the
weight
record component
-