Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 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
2 changes: 2 additions & 0 deletions docs/source/api/serialization.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@ Serialization

rustworkx.node_link_json
rustworkx.read_graphml
rustworkx.read_graphml_with_keys
rustworkx.write_graphml
rustworkx.from_node_link_json_file
rustworkx.parse_node_link_json
13 changes: 13 additions & 0 deletions releasenotes/notes/write_graphml-624c10b6f7592ee1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
features:
- |
Added a new function :func:`~rustworkx.write_graphml` that writes
a list of rustworkx graph objects to a file in GraphML format.
- |
Added a new function :func:`~rustworkx.read_graphml_with_keys`
that reads a GraphML file and returns the list of defined keys
along with the list of rustworkx graph objects.
other:
- |
When graphs read with :func:`~rustworkx.read_graphml` include IDs,
these IDs are now stored in the graph attributes.
2 changes: 2 additions & 0 deletions rustworkx/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ from .rustworkx import directed_barabasi_albert_graph as directed_barabasi_alber
from .rustworkx import undirected_random_bipartite_graph as undirected_random_bipartite_graph
from .rustworkx import directed_random_bipartite_graph as directed_random_bipartite_graph
from .rustworkx import read_graphml as read_graphml
from .rustworkx import read_graphml_with_keys as read_graphml_with_keys
from .rustworkx import write_graphml as write_graphml
from .rustworkx import digraph_node_link_json as digraph_node_link_json
from .rustworkx import graph_node_link_json as graph_node_link_json
from .rustworkx import from_node_link_json_file as from_node_link_json_file
Expand Down
36 changes: 36 additions & 0 deletions rustworkx/rustworkx.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,30 @@ class ColoringStrategy:
Saturation: Any
IndependentSet: Any

@final
class GraphMLDomain:
Node: GraphMLDomain
Edge: GraphMLDomain
Graph: GraphMLDomain
All: GraphMLDomain

@final
class GraphMLType:
Boolean: GraphMLType
Int: GraphMLType
Float: GraphMLType
Double: GraphMLType
String: GraphMLType
Long: GraphMLType

@final
class GraphMLKey:
id: str
domain: GraphMLDomain
name: str
ty: GraphMLType
default: Any

# Cartesian product

def digraph_cartesian_product(
Expand Down Expand Up @@ -680,11 +704,23 @@ def directed_random_bipartite_graph(

# Read Write

def read_graphml_with_keys(
path: str,
/,
compression: str | None = ...,
) -> tuple[list[GraphMLKey], list[PyGraph | PyDiGraph]]: ...
def read_graphml(
path: str,
/,
compression: str | None = ...,
) -> list[PyGraph | PyDiGraph]: ...
def write_graphml(
graphs: list[PyGraph | PyDiGraph],
keys: list[GraphMLKey],
path: str,
/,
compression: str | None = ...,
) -> None: ...
def digraph_node_link_json(
graph: PyDiGraph[_S, _T],
/,
Expand Down
Loading