pyflagser.save_weighted_flag(fname, adjacency_matrix, max_edge_weight=None)

Save the adjacency matrix of a directed/undirected weighted graph into a .flag file.

fnamefile, str, or pathlib.Path, required

Filename of extension .flag.

adjacency_matrix2d ndarray or scipy.sparse matrix of shape (n_vertices, n_vertices), required

Matrix representation of a directed/undirected weighted graph. Diagonal elements are vertex weights. The way zero values are handled depends on the format of the matrix. If the matrix is a dense numpy.ndarray, zero values denote zero-weighted edges. If the matrix is a sparse scipy.sparse matrix, explicitly stored off-diagonal zeros and all diagonal zeros denote zero-weighted edges. Off-diagonal values that have not been explicitely stored are treated by scipy.sparse as zeros but will be understood as infinitely-valued edges, i.e., edges absent from the filtration.

max_edge_weightint or float or None, optional, default: None

Maximum edge weight to be considered in the filtration. All edge weights greater than that value will be considered as infinitely-valued, i.e., absent from the filtration. If None, all finite edge weights are considered.


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.