-
-
Notifications
You must be signed in to change notification settings - Fork 654
Closed
Labels
Description
Steps To Reproduce
sage: G = Graph([(0, 1), (1, 2), (2, 2)], immutable=True, loops=True)
sage: G.matching_polynomial()
Expected Behavior
x^3 - 3*x
Actual Behavior
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Cell In[2], line 1
----> 1 G.matching_polynomial()
File ~/sage/src/sage/graphs/matchpoly.pyx:244, in sage.graphs.matchpoly.matching_polynomial()
242 L.sort(key=lambda pair: pair[0])
243 G = G.relabel(perm={L[i][1]: i for i in range(nverts)}, inplace=False)
--> 244 G.allow_loops(False)
245
246 # Initialization of pol, edges* variables.
File ~/sage/src/sage/graphs/generic_graph.py:3540, in GenericGraph.allow_loops(self, new, check)
3491 """
3492 Change whether loops are permitted in the (di)graph.
3493
(...)
3537 []
3538 """
3539 if new is False and check:
-> 3540 self.remove_loops()
3541 self._backend.loops(new)
File ~/sage/src/sage/graphs/generic_graph.py:13771, in GenericGraph.remove_loops(self, vertices)
13769 for v in vertices:
13770 if self.has_edge(v, v):
> 13771 self.delete_multiedge(v, v)
File ~/sage/src/sage/graphs/generic_graph.py:13090, in GenericGraph.delete_multiedge(self, u, v)
13088 self.delete_edge(u, v, l)
13089 else:
> 13090 self.delete_edge(u, v)
File ~/sage/src/sage/graphs/generic_graph.py:12817, in GenericGraph.delete_edge(self, u, v, label)
12814 u, v = u
12815 label = None
> 12817 self._backend.del_edge(u, v, label, self._directed)
File ~/sage/src/sage/graphs/base/static_sparse_backend.pyx:679, in sage.graphs.base.static_sparse_backend.StaticSparseBackend.del_edge()
677 raise ValueError("graph is immutable; please change a copy instead (use function copy())")
678
--> 679 cpdef del_edge(self, object u, object v, object l, bint directed):
680 r"""
681 Delete an edge of the graph. No way.
File ~/sage/src/sage/graphs/base/static_sparse_backend.pyx:692, in sage.graphs.base.static_sparse_backend.StaticSparseBackend.del_edge()
690 ValueError: graph is immutable; please change a copy instead (use function copy())
691 """
--> 692 raise ValueError("graph is immutable; please change a copy instead (use function copy())")
693
694 def del_edges(self, edges, directed):
ValueError: graph is immutable; please change a copy instead (use function copy())
Additional Information
No response
Environment
- OS: all (macOS, fedora)
- Sage Version: 10.7.beta0
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