Use associatedtype in a Swift protocol when conforming types should choose the concrete type used by the protocol. A Graph can therefore remain reusable while each implementation selects its vertex and edge types. VertexType is constrained to Equatable, while EdgeType must conform to Edge. section 4.1
A graph with configurable types
protocol Graph: class, CustomStringConvertible { associatedtype VertexType: Equatable associatedtype EdgeType: Edge var vertices: [VertexType] { get set } var edges: [[EdgeType]] { get set } } An UnweightedGraph<String> can use city names as VertexType and UnweightedEdge as EdgeType. The graph algorithms work with integer indexes internally, while the stored vertices remain strings or another Equatable type. section 4.1
