Skip to content

Passing a PyGraph into copy.copy raises a PanicException #1549

Description

@mr-jakey

Information

  • rustworkx version:0.17.1
  • Python version: 3.12.10
  • Rust version: -
  • Operating system: MacOS

What is the current behavior?

If I run copy.copy on a graph that has been previously operated on by PyGraph.contract_nodes, a PanicException is raised.

What is the expected behavior?

The graph should be copied? If PyGraph is known to not be copy/deepcopy safe, sorry! PyGraph.copy works fine, but I'm more concerned about a possible issue with contract_nodes.

Steps to reproduce the problem

from copy import copy
from rustworkx.visualization import graphviz_draw
from rustworkx import PyGraph

graph = PyGraph()
graph.add_nodes_from(['a', 'b', 'c', 'd'])
graph.add_edge(0, 1, "_")
graph.add_edge(1, 2, "_")
graph.add_edge(2, 3, "_")

_idx = graph.contract_nodes(nodes=(1, 2), obj='G')

_ = copy(graph)

Thanks!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions