Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
GenericGraph.adjacency_matrix: Add doctest with immutable=True
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Koeppe committed Feb 19, 2022
1 parent 01d5541 commit 03343f7
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/sage/graphs/generic_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -1883,6 +1883,18 @@ def adjacency_matrix(self, sparse=None, vertices=None, *, base_ring=None, **kwds
sage: type(_)
<class 'sage.matrix.matrix_numpy_integer_dense.Matrix_numpy_integer_dense'>

As an immutable matrix::

sage: M = graphs.PathGraph(5).adjacency_matrix(sparse=False, immutable=True); M
[0 1 0 0 0]
[1 0 1 0 0]
[0 1 0 1 0]
[0 0 1 0 1]
[0 0 0 1 0]
sage: M[2, 2] = 1
Traceback (most recent call last):
...
ValueError: matrix is immutable; please change a copy instead (i.e., use copy(M) to change a copy of M).

TESTS::

Expand Down

0 comments on commit 03343f7

Please sign in to comment.