A protocol specifies requirements that adopting types must satisfy without defining a class hierarchy. Swift uses protocols to put interfaces and composition ahead of inheritance. section 4.1
A graph framework can build on protocols and generics: Graph associates a vertex type with an Edge type, while extensions provide shared operations such as counting vertices, finding indices, and listing neighbors.
A protocol-first city graph
UnweightedGraph<String> stores cities as vertices and uses UnweightedEdge for connections. Adding Seattle–Chicago or Phoenix–Dallas automatically records both directions, and printing the graph shows each city’s neighbors.

