 private class Edge {
     var visited: Bool = false
     var inSolution: Bool = false
-    let forwardNode: Node
-    let backwardNode: Node
-    init(forwardNode: Node, backwardNode: Node) {
-        self.forwardNode = forwardNode
-        self.backwardNode = backwardNode
+    let endingNode: Node
+    let startingNode: Node
+    init(startingNode: Node, endingNode: Node) {
+        self.startingNode = startingNode
+        self.endingNode = endingNode
     }
     var component: PathComponent {
-        let parentComponent = self.forwardNode.pathComponent
-        var nextLocation = forwardNode.componentLocation
+        let parentComponent = self.endingNode.pathComponent
+        var nextLocation = endingNode.componentLocation
         if nextLocation == parentComponent.startingIndexedLocation {
             nextLocation = parentComponent.endingIndexedLocation
         }
-        return self.forwardNode.pathComponent.split(from: backwardNode.componentLocation, to: nextLocation)
+        return self.endingNode.pathComponent.split(from: startingNode.componentLocation, to: nextLocation)
     }
 }
 

        let firstPoint = startingNode.pathComponent.point(at: startingNode.componentLocation)
        var points: [CGPoint] = [firstPoint]
        var orders: [Int] = []
        func visit(from node: Node) -> Node? {
            if let edge = node.forwardEdge, edge.inSolution, edge.visited == false {
                let component = edge.component
                visit(component)
                edge.visited = true
                return edge.forwardNode
            }
            if let edge = node.backwardEdge, edge.inSolution, edge.visited == false {
                let component = edge.component.reversed()
                visit(component)
                edge.visited = true
                return edge.backwardNode
            }
            return nil
        }
        func visit(_ component: PathComponent) {
            points += component.points[1..<component.points.count]
            orders += component.orders
        }
        var currentNode = startingNode
        repeat {

            endCappedIntersections.append(Node(location: endingLocation, pathComponent: component))
        }
        let edges = (1..<endCappedIntersections.count).map {
            Edge(startingNode: endCappedIntersections[$0-1], endingNode: endCappedIntersections[$0])
        }
        for i in 0..<endCappedIntersections.count {
            if i > 0 {
