Click or drag to resize
Edge Class
The Edge class represents a weighted edge in an . Each edge consists of two integers (naming the two vertices) and a real-value weight. The data type provides methods for accessing the two endpoints of the edge and the weight. The natural order for this data type is by ascending order of weight.
Inheritance Hierarchy
SystemObject
  Algs4NetEdge

Namespace: Algs4Net
Assembly: Algs4Net (in Algs4Net.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
public class Edge : IComparable<Edge>

The Edge type exposes the following members.

Constructors
  NameDescription
Public methodEdge(Int32, Int32)
Initializes an edge between vertices v and w of an undirected graph when weight is immaterial.
Public methodEdge(Int32, Int32, Double)
Initializes an edge between vertices v and w of an undirected graph with the given weight.
Top
Properties
  NameDescription
Public propertyEither
Returns either endpoint of this edge.
Public propertyWeight
Returns the weight of this edge.
Top
Methods
  NameDescription
Public methodCompareTo
Compares two edges by weight. Note that CompareTo() is not consistent with Equals(), which uses the reference equality implementation inherited from object.
Public methodStatic memberMainTest
Demo test the Edge data type.
Public methodOther
Returns the endpoint of this edge that is different from the given vertex.
Public methodToString
Returns a string representation of this edge.
(Overrides ObjectToString.)
Top
Remarks
For additional documentation, see Section 4.3 of Algorithms, 4th Edition by Robert Sedgewick and Kevin Wayne.

This class is a C# port from the original Java class Edge implementation by Robert Sedgewick and Kevin Wayne.

See Also