networkx_gml.py
NetworkxGML
dataclass
Bases: IO[Graph]
IO to load from and save graph data using NetworkX's GML support.
Calls networkx.read_gml and networkx.write_gml under the hood.
Example usage:
>>> from pathlib import Path
>>> import networkx as nx
>>> from ordeq_networkx import NetworkxGML
>>> random_graph = nx.erdos_renyi_graph(10, 0.5)
>>> my_graph = NetworkxGML(
... path=Path("graph.gml")
... )
>>> my_graph.save(random_graph) # doctest: +SKIP
load(**load_options)
Load a graph from the GML file at the specified path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**load_options
|
Any
|
Additional keyword arguments passed to
|
{}
|
Returns:
| Type | Description |
|---|---|
Graph
|
The loaded NetworkX graph. |
save(graph, **save_options)
Save a NetworkX graph to the GML file at the specified path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
graph
|
Graph
|
The NetworkX graph to save. |
required |
**save_options
|
Any
|
Additional keyword arguments passed to
|
{}
|