There is no built-in way to construct such a set of matrices, but you can construct the set of integer lists of length `n^2`

with entries 0, 1, 2. Then you can subtract 1 from each entry to get entries -1, 0, 1, and then you can form a matrix from them:

```
sage: n = 3
sage: L = IntegerListsLex(length=n**2, max_part=2)
sage: len(L)
19683
sage: L[:6]
[[2, 2, 2, 2, 2, 2, 2, 2, 2],
[2, 2, 2, 2, 2, 2, 2, 2, 1],
[2, 2, 2, 2, 2, 2, 2, 2, 0],
[2, 2, 2, 2, 2, 2, 2, 1, 2],
[2, 2, 2, 2, 2, 2, 2, 1, 1],
[2, 2, 2, 2, 2, 2, 2, 1, 0]]
sage: [matrix(n, n, [b-1 for b in a]) for a in L[:6]]
[
[1 1 1] [1 1 1] [ 1 1 1] [1 1 1] [1 1 1] [ 1 1 1]
[1 1 1] [1 1 1] [ 1 1 1] [1 1 1] [1 1 1] [ 1 1 1]
[1 1 1], [1 1 0], [ 1 1 -1], [1 0 1], [1 0 0], [ 1 0 -1]
]
sage: M = [matrix(3, 3, [b-1 for b in a]) for a in L]
sage: len(M)
19683
```

Using `M = (matrix(...))`

with parentheses instead of square brackets is faster and more memory efficient, because it doesn't create the whole list at once. In particular, if you want to loop over the set, don't construct the whole list, but do something like this:

```
sage: for a in L:
....: mat = matrix(3, 3, [b-1 for b in a])
....: ... do stuff with mat ...
```

I do not understand the question. Matrix entries and edge labels can be assigned to any numbers including -1, 0, +1.

Actually, what I want to do is construct the set of all matrices of given order n whose entries are either +1, -1 or 0. I know that the following: MS = MatrixSpace(GF(2),n,n) given me a space of all matrices with entries 1 or 0, but here 1+1=0, whereas I want the addition to be done over the integer field. In terms of digraphs, is there a way to restrict the weights to only +1, -1 or 0?