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.write_matrix_market#
- write_matrix_market(graph, /, path=None)[source]#
Write a 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 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:
- 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.