Shared.Gamma

Shared.Gamma(return_as: str = 'csr', transpose: bool = False) scipy.sparse.base.spmatrix[source]

Return the incidence matrix Gamma of the network.

Gamma is of shape (m, n) and is defined as:

Gamma[v, e] = 1 if edge e enters vertex v,
Gamma[v, e] = -1 if edge e leaves vertex v,
Gamma[v, e] = 0 otherwise.
Parameters
return_asstr, default=’csr’

Sparse matrix type to be returned.

transposebool, default=True

Whether to transpose Gamma matrix.

Returns
Gammaspmatrix

Incidence matrix of the network.

See also

scipy.sparse

References

https://en.wikipedia.org/wiki/Incidence_matrix

Examples

Sioux-Falls:

>>> import paminco
>>> net = paminco.net.load_sioux()
>>> net.Gamma().toarray()[:5, :5]
array([[-1, -1,  1,  0,  1],
        -[ 1,  0, -1, -1,  0],
        -[ 0,  1,  0,  0, -1],
        -[ 0,  0,  0,  0,  0],
        -[ 0,  0,  0,  0,  0]], dtype=int32)