Added safe option to avoid cloning nodes and edges.