def split_path(self, path, node): """ Split the path at node :return: """ assert len(node.edges) > 2 # it should be an intersection node nodes = path.get_nodes() if nodes[0] == node or nodes[-1] == node: # Return if this is at the end of this path return idx = nodes.index(node) edges1 = path.edges[:idx] edges2 = path.edges[idx:] path1 = self.create_path(edges=edges1) path2 = self.create_path(edges=edges2) Path.copy_properties(path, path1) Path.copy_properties(path, path2) del self.paths[path.id]