Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions releasenotes/notes/prepare-0.17-b242552a1301d816.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
prelude: >
This is a new Rustworkx release with bug fixes and new features to
the library. The highlights of this release are:
* Enhanced documentation and tests
* Support for writing GraphML files
* A new method for weighted closeness closeness
This release uses the `Python Stable ABI <https://docs.python.org/3.9/c-api/stable.html>`__,
and will be compatible with all versions from Python 3.9 onwards. The published
binaries have been tested with Python 3.9 to 3.13, although they will likely
work with future versions like 3.14.
A special shoutout goes to Miroslav Šedivý, Etienne Wodey, Krishn Parasar, and Barak Katzir
for their pull requests and GitHub issues! Although not documented in individual
entries, we appreciate your work helping us improve our documentation, type annotations, and tests.
28 changes: 27 additions & 1 deletion rustworkx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2283,5 +2283,31 @@ def single_source_all_shortest_paths(

@_rustworkx_dispatch
def write_graphml(graph, path, /, keys=None, compression=None):
""" """
"""Write a graph to a file in GraphML format.

GraphML is a comprehensive and easy-to-use file format for graphs. It consists
of a language core to describe the structural properties of a graph and a flexible
extension mechanism to add application-specific data.

For more information see:
http://graphml.graphdrawing.org/

.. note::

This implementation does not support mixed graphs (directed and undirected edges together),
hyperedges, nested graphs, or ports.

.. note::

GraphML attributes with `graph` domain are written from the graph's attrs field.

:param graph: The graph to write to the file. This can be a
:class:`~rustworkx.PyGraph` or :class:`~rustworkx.PyDiGraph`.
:param path: The path of the output file to write.
:param keys: Optional list of key definitions for GraphML attributes.
If not specified, keys will be inferred from the graph data.
:param compression: Optional compression format for the output file.
If not specified, no compression is applied.
:raises RuntimeError: when an error is encountered while writing the GraphML file.
"""
raise TypeError(f"Invalid Input Type {type(graph)} for graph")
54 changes: 52 additions & 2 deletions src/graphml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1289,7 +1289,32 @@ impl KeySpec {
}
}

/// Write a graph to a file in GraphML format given the list of key definitions.
/// Write a graph to a file in GraphML format.
///
/// GraphML is a comprehensive and easy-to-use file format for graphs. It consists
/// of a language core to describe the structural properties of a graph and a flexible
/// extension mechanism to add application-specific data.
///
/// For more information see:
/// http://graphml.graphdrawing.org/
///
/// .. note::
///
/// This implementation does not support mixed graphs (directed and undirected edges together),
/// hyperedges, nested graphs, or ports.
///
/// .. note::
///
/// GraphML attributes with `graph` domain are written from :attr:`~.PyGraph.attrs` field.
///
/// :param PyGraph graph: The graph to write to the file.
/// :param str path: The path of the output file to write.
/// :param Optional[list[GraphMLKey]] keys: Optional list of key definitions for GraphML attributes.
/// If None, keys will be inferred from the graph data.
/// :param Optional[str] compression: Optional compression format for the output file.
/// If None, no compression is applied.
///
/// :raises RuntimeError: when an error is encountered while writing the GraphML file.
#[pyfunction]
#[pyo3(signature=(graph, path, keys=None, compression=None),text_signature = "(graph, path, /, keys=None, compression=None)")]
pub fn graph_write_graphml(
Expand All @@ -1306,7 +1331,32 @@ pub fn graph_write_graphml(
Ok(())
}

/// Write a digraph to a file in GraphML format given the list of key definitions.
/// Write a graph to a file in GraphML format.
///
/// GraphML is a comprehensive and easy-to-use file format for graphs. It consists
/// of a language core to describe the structural properties of a graph and a flexible
/// extension mechanism to add application-specific data.
///
/// For more information see:
/// http://graphml.graphdrawing.org/
///
/// .. note::
///
/// This implementation does not support mixed graphs (directed and undirected edges together),
/// hyperedges, nested graphs, or ports.
///
/// .. note::
///
/// GraphML attributes with `graph` domain are written from :attr:`~.PyGraph.attrs` field.
///
/// :param PyDiGraph graph: The graph to write to the file.
/// :param str path: The path of the output file to write.
/// :param Optional[list[GraphMLKey]] keys: Optional list of key definitions for GraphML attributes.
/// If None, keys will be inferred from the graph data.
/// :param Optional[str] compression: Optional compression format for the output file.
/// If None, no compression is applied.
///
/// :raises RuntimeError: when an error is encountered while writing the GraphML file.
#[pyfunction]
#[pyo3(signature=(graph, path, keys=None, compression=None),text_signature = "(graph, path, /, keys=None, compression=None)")]
pub fn digraph_write_graphml(
Expand Down
Loading