     let location: CGPoint
     let vertexType: VertextType
     // pointers must be set after initialization
-    var next: PathElementTransition! = nil
-    weak var previous: PathElementTransition! = nil
+    
+    private(set) var next: Vertex! = nil
+    private(set) weak var previous: Vertex! = nil
+    private(set) var nextTransition: VertexTransition! = nil
+    private(set) var previousTransition: VertexTransition! = nil
+    
+    public func setNextVertex(_ vertex: Vertex, transition: VertexTransition) {
+        self.next = vertex
+        self.nextTransition = transition
+    }
+    
+    public func setPreviousVertex(_ vertex: Vertex, transition: VertexTransition) {
+        self.previous = vertex
+        self.previousTransition = transition
+    }
+
     init(location: CGPoint, vertexType: VertextType) {
         self.location = location
         self.vertexType = vertexType

    let indexedComponentLocation1, indexedComponentLocation2: IndexedPathComponentLocation
}

class PathElementTransition {
    enum TransitionType {
        case line
        case quadCurve(control: CGPoint)
        case curve(control1: CGPoint, control2: CGPoint)
        func reversed() -> TransitionType {
            switch self {
                case let .curve(control1: c1, control2: c2):
                    return .curve(control1: c2, control2: c1)
                default:
                    return self
            }
        }
    }
    let vertex: Vertex
    let transition: TransitionType
    init(vertex: Vertex, transition: TransitionType) {
        self.vertex = vertex
        self.transition = transition
    }
}



extension PathComponent {
    func linkedListRepresentation() -> [Vertex] {
        guard self.curves.count > 0 else {
            return []
        }
        var elements: [Vertex] = [] // elements[i] is the first vertex of curves[i]
        let firstPoint: CGPoint = self.curves.first!.startingPoint
        let firstVertex = Vertex(location: firstPoint, vertexType: .regular)
        elements.append(firstVertex)
        var lastVertex = firstVertex
        for i in 1..<self.curves.count {
            let v = Vertex(location: self.curves[i].startingPoint, vertexType: .regular)
            elements[i] = v
            let curveForTransition = self.curves[i-1]
            // set the forwards reference for starting vertex of curve i-1
            lastVertex.setNextVertex(v, transition: VertexTransition(curve: curveForTransition))
            // set the backwards reference for starting vertex of curve i
            v.setPreviousVertex(lastVertex, transition: VertexTransition(curve: curveForTransition.reversed()))
            // point previous at v for the next iteration
            lastVertex = v
        }
        // connect the forward reference of the last vertex to the first vertex
        let lastCurve = self.curves.last!
        lastVertex.setNextVertex(firstVertex, transition: VertexTransition(curve: lastCurve))
        // connect the backward reference of the first vertex to the last vertex
        firstVertex.setPreviousVertex(lastVertex, transition: VertexTransition(curve: lastCurve.reversed()))
   
        // return list of vertexes that point to the start of each element
        return elements
    }
}

public class AugmentedGraph {
    
    func insertIntersection(inList list: [Vertex], at location: IndexedPathComponentLocation) -> Vertex {
        
    }
    
    func connectNeighbors(_ vertex1: Vertex, _ vertex2: Vertex) {

    }
    
    private let list1: [Vertex]
    private let list2: [Vertex]
    
    init(component1: PathComponent, component2: PathComponent, intersections: [PathComponentIntersection]) {
        self.list1 = component1.linkedListRepresentation()
        self.list2 = component1.linkedListRepresentation()
        intersections.forEach {
            let vertex1 = insertIntersection(inList: list1, at: $0.indexedComponentLocation1)
            let vertex2 = insertIntersection(inList: list2, at: $0.indexedComponentLocation1)
            connectNeighbors(vertex1, vertex2) // sets the vertex crossing neighbor pointer
        }
    }
