Note
This is the documentation for the current state of the development branch of rustworkx. The documentation or APIs here can change prior to being released.
rustworkx.digraph_write_matrix_market#
- digraph_write_matrix_market(graph, /, path=None)#
Write a directed graph to Matrix Market format.
Matrix Market is a human-readable ASCII file format for storing sparse matrices as coordinate format (row, column, value) triplets. The directed graph is converted to a coordinate (COO) sparse matrix representation where edges become non-zero entries.
For more information about Matrix Market format, see: https://math.nist.gov/MatrixMarket/formats.html
- Parameters:
graph (PyDiGraph) – The directed graph to write in Matrix Market format.
path (Optional[str]) – Optional file path to write the output. If None, returns the Matrix Market content as a string.
- Returns:
None if a file path was provided, otherwise returns the Matrix Market formatted content as a string.
- Return type:
Optional[str]
- Raises:
ValueError – when the graph cannot be converted to a valid COO matrix.
IOError – when an error occurs during file I/O or format serialization.