def splitEdge(self, edgeToSplit): upVertex = edgeToSplit.startVertex downVertex = edgeToSplit.endVertex midX = (upVertex.x + downVertex.x) / 2 midY = (upVertex.y + downVertex.y) / 2 middleVertex = Vertex(self.getNewVertexId(), midX, midY) self.addVertex(middleVertex) iMovs = [(mov.inEdge, mov.numLanes) for mov in edgeToSplit.iterInMovements()] eMovs = [(mov.outEdge, mov.numLanes) for mov in edgeToSplit.iterOutMovements()] numLanes = edgeToSplit.getNumLanes() self.deleteEdge(edgeToSplit) newEdge1 = Edge(upVertex, middleVertex, numLanes) newEdge2 = Edge(middleVertex, downVertex, numLanes) self.addEdge(newEdge1) self.addEdge(newEdge2) for upEdge, numInLanes in iMovs: newMovement = Movement(upEdge, newEdge1, numInLanes) upEdge.addOutMovement(newMovement) for downEdge, numOutLanes, in eMovs: newMovement = Movement(newEdge2, downEdge, numOutLanes) newEdge2.addOutMovement(newMovement) movement = Movement(newEdge1, newEdge2, numLanes) newEdge1.addOutMovement(movement) return newEdge1, newEdge2