         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])
+            let node1 = Node(location: $0.indexedPathLocation1, path: path1)
+            let node2 = Node(location: $0.indexedPathLocation2, path: path2)
             node1.addNeighbor(node2)
             node2.addNeighbor(node1)
             path1Intersections.append(node1)

            return temp
        }()
        self.components = (0..<path.components.count).map {
            PathComponentGraph(for: path.components[$0], componentIndex: $0, using: intersectionsByComponent[$0])
        }
    }
}


private class PathComponentGraph {
    private let nodes: [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, path: path), at: 0)
        }
        if nodes.last?.location != endingLocation {
            nodes.append(Node(location: endingLocation, path: path))
        }
        for i in 1..<nodes.count {
            let startingNode = nodes[i-1]
