 
 private class PathComponentGraph {
     private let nodes: [Node]
-    init(for component: PathComponent, componentIndex: Int, using intersections: [Node]) {
+    init(for path: Path, componentIndex: Int, using intersections: [Node]) {
         var nodes = intersections
+        let component = path.components[componentIndex]
         let startingLocation = IndexedPathLocation(componentIndex: componentIndex, elementIndex: component.startingIndexedLocation.elementIndex, t: component.startingIndexedLocation.t)
         let endingLocation = IndexedPathLocation(componentIndex: componentIndex, elementIndex: component.endingIndexedLocation.elementIndex, t: component.endingIndexedLocation.t)
         if nodes.first?.location != startingLocation {
-            nodes.insert(Node(location: startingLocation, pathComponent: component), at: 0)
+            nodes.insert(Node(location: startingLocation, path: path), at: 0)
         }
         if nodes.last?.location != endingLocation {
-            nodes.append(Node(location: endingLocation, pathComponent: component))
+            nodes.append(Node(location: endingLocation, path: path))
         }
         for i in 1..<nodes.count {
             let startingNode = nodes[i-1]

        var path1Intersections: [Node] = []
        var path2Intersections: [Node] = []
        intersections.forEach {
            let node1 = Node(location: $0.indexedPathLocation1, pathComponent: path1.components[$0.indexedPathLocation1.componentIndex])
            let node2 = Node(location: $0.indexedPathLocation2, pathComponent: path2.components[$0.indexedPathLocation2.componentIndex])
            node1.addNeighbor(node2)
            node2.addNeighbor(node1)
            path1Intersections.append(node1)

    var forwardEdge: Edge?
    var backwardEdge: Edge?
    private(set) var neighbors: [Node] = []
    let path: Path
    var pathComponent: PathComponent {
        return path.components[self.location.componentIndex]
    }
    init(location: IndexedPathLocation, path: Path) {
        self.location = location
        self.path = path
    }
    func neighborsContain(_ node: Node) -> Bool {
        return self.neighbors.contains(where: { $0 === node })
