An unweighted edge represents a connection between two vertices without an associated value such as distance. It records which vertices connect, not anything about the connection itself. In the bidirectional graph used here, reversing the edge lets each vertex treat the other as a neighbor. section 4.1
A concrete Swift edge provides:
- A from vertex index, u, and a to vertex index, v. section 4.1
- A reversed edge with the endpoints exchanged. section 4.1
- A description such as "u <-> v" for CustomStringConvertible conformance. section 4.1
Hyperloop network
A city graph can connect Seattle to Chicago and San Francisco, then expose those neighboring cities through adjacency lists. The edges record connectivity only; travel distance is omitted. section 4.1
public protocol Edge: CustomStringConvertible {
var u: Int { get set } // index of the "from" vertex
var v: Int { get set } // index of the "to" vertex
var reversed: Edge { get }
}
The Edge protocol makes endpoint indices and reversal the essential interface for an unweighted edge. section 4.1
