Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

the bipartite graph constructor may fail when immutable=True #39295

Open
2 tasks done
dcoudert opened this issue Jan 7, 2025 · 0 comments
Open
2 tasks done

the bipartite graph constructor may fail when immutable=True #39295

dcoudert opened this issue Jan 7, 2025 · 0 comments

Comments

@dcoudert
Copy link
Contributor

dcoudert commented Jan 7, 2025

Steps To Reproduce

sage: B = BipartiteGraph(matrix([[1, 1], [1, 1]]), immutable=True)

Expected Behavior

build the bipartite graph

Actual Behavior

sage: B = BipartiteGraph(matrix([[1, 1], [1, 1]]), immutable=True)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[4], line 1
----> 1 B = BipartiteGraph(matrix([[Integer(1), Integer(1)], [Integer(1), Integer(1)]]), immutable=True)

File ~/sage/src/sage/graphs/bipartite_graph.py:478, in BipartiteGraph.__init__(self, data, partition, check, hash_labels, *args, **kwds)
    474 self.right = set(range(ncols, nrows + ncols))
    476 # ensure that the vertices exist even if there
    477 # are no associated edges (trac #10356)
--> 478 self.add_vertices(self.left)
    479 self.add_vertices(self.right)
    481 if kwds.get("multiedges", False):

File ~/sage/src/sage/graphs/generic_graph.py:11446, in GenericGraph.add_vertices(self, vertices)
  11411 def add_vertices(self, vertices):
  11412     """
  11413     Add vertices to the (di)graph from an iterable container of vertices.
  11414 
   (...)
  11444         [0, 6]
  11445     """
> 11446     return self._backend.add_vertices(vertices)

File ~/sage/src/sage/graphs/base/static_sparse_backend.pyx:603, in sage.graphs.base.static_sparse_backend.StaticSparseBackend.add_vertices()
    601         ValueError: graph is immutable; please change a copy instead (use function copy())
    602     """
--> 603     raise ValueError("graph is immutable; please change a copy instead (use function copy())")
    604 
    605 cpdef del_edge(self, object u, object v, object l, bint directed):

ValueError: graph is immutable; please change a copy instead (use function copy())

Additional Information

No response

Environment

  • OS: all
  • Sage Version: 10.6.beta3

Checklist

  • I have searched the existing issues for a bug report that matches the one I want to file, without success.
  • I have read the documentation and troubleshoot guide
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant