         func drawGraph(_ graph: PathGraph) {
             for i in 0..<graph.components.count {
                 graph.components[i].forEachNode { node, _ in
+                    guard let nextNode = node.next else { return }
                     switch node.edge.inSolution {
                     case true:
                         Draw.setColor(context, color: Draw.red)
                     case false:
                         Draw.setColor(context, color: Draw.green)
                     }
-                    for curve in node.component.curves {
+                    for curve in node.forwardComponent(to: nextNode).curves {
                         Draw.drawCurve(context, curve: curve)
                     }
                 }

    func classifyEdges(for graph: PathGraph, isForFirstPath: Bool) {
        func classifyEdge(for node: Node) {
            // TODO: we use a crummy point location
            let nextEdge = node.component.element(at: 0)
            let point = nextEdge.compute(0.5)
            let normal = nextEdge.normal(0.5)
            let smallDistance = CGFloat(Utils.epsilon)

            self.addNeighbor($0)
        }
    }
    func forwardComponent(to node: Node) -> PathComponent {
        var nextLocation = node.componentLocation
        if nextLocation == self.pathComponent.startingIndexedLocation {
            nextLocation = self.pathComponent.endingIndexedLocation
        }
        return self.pathComponent.split(from: self.componentLocation, to: nextLocation)
    }
    func backwardComponent(to node: Node) -> PathComponent {
        var startingLocation = self.componentLocation
        if startingLocation == self.pathComponent.startingIndexedLocation {
            startingLocation = self.pathComponent.endingIndexedLocation
        }
        return self.pathComponent.split(from: startingLocation, to: node.componentLocation)
    }
}

