pyflagser.load_weighted_flag(fname, fmt='csr', dtype=<class 'float'>, infinity_value=None)

Load a .flag file and return the adjacency matrix of the directed/undirected weighted graph it describes.

fnamefile, str, or pathlib.Path, required

Filename of extension .flag containing the information of a flag matrix.

fmt{‘dense’, ‘dia’, ‘csr’, ‘csc’, ‘lil’, …}, optional,

default: 'csr' Matrix format of the result. By default, a CSR sparse matrix is returned. Keep in mind that some matrix formats do not track zero values.

dtypedata-type, optional, default: np.float

Data-type of the resulting array.

infinity_valueint or float or None, optional, default: None

Value to use to denote an absence of edge. It is only useful when fmt is ‘dense’. If None, it is set to the maximum value allowed by dtype.

adjacency_matrixmatrix of shape (n_vertices, n_vertices) and format fmt

Matrix representation of a directed/undirected weighted graph. Diagonal elements are vertex weights.


The input graphs cannot contain self-loops, i.e. edges that start and end in the same vertex, therefore diagonal elements of the input adjacency matrix store vertex weights.



D. Luetgehetmann, “Documentation of the C++ flagser library”; GitHub: luetge/flagser.