cfpq_data.graphs.readwrite.rdf#
Read (and write) a graph from (and to) RDF file.
Functions
|
Loads a graph from RDF file. |
|
Saves the |
- graph_from_rdf(path: Path | str) MultiDiGraph[source]#
Loads a graph from RDF file.
- Parameters:
- pathUnion[Path, str]
The path to the RDF file with which the graph will be created.
- Returns:
- gMultiDiGraph
Loaded graph.
Examples
>>> from cfpq_data import * >>> import pathlib, tempfile >>> d = pathlib.Path(tempfile.mkdtemp()) >>> p = d / "g.csv" >>> _ = p.write_text("0 1 a\n1 2 b\n") >>> g = graph_from_csv(path=p) >>> path = graph_to_rdf(g, d / "g.ttl") >>> generations = graph_from_rdf(path) >>> generations.number_of_nodes() 3 >>> generations.number_of_edges() 2
- graph_to_rdf(graph: MultiDiGraph, path: Path | str) Path[source]#
Saves the
graphto the RDF file bypath.- Parameters:
- graphMultiDiGraph
Graph to save.
- pathUnion[Path, str]
The path to the file where the graph will be saved.
- Returns:
- pathPath
Path to the RDF file where the graph will be saved.
Examples
>>> from cfpq_data import * >>> import pathlib, tempfile >>> d = pathlib.Path(tempfile.mkdtemp()) >>> p = d / "g.csv" >>> _ = p.write_text("0 1 a\n1 2 b\n") >>> g = graph_from_csv(p) >>> path = graph_to_rdf(g, d / "g.ttl")