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:
path (Union[Path, str]) -- The path to the RDF file with which the graph will be created.
Examples
>>> from cfpq_data import * >>> p = download("generations") >>> g = graph_from_csv(path=p) >>> path = graph_to_rdf(g, "test.ttl") >>> generations = graph_from_rdf(path) >>> generations.number_of_nodes() 129 >>> generations.number_of_edges() 273
- Returns:
g -- Loaded graph.
- Return type:
MultiDiGraph
- graph_to_rdf(graph: MultiDiGraph, path: Path | str) Path [source]#
Saves the
graph
to the RDF file bypath
.- Parameters:
graph (MultiDiGraph) -- Graph to save.
path (Union[Path, str]) -- The path to the file where the graph will be saved.
Examples
>>> from cfpq_data import * >>> p = download("generations") >>> g = graph_from_csv(p) >>> path = graph_to_rdf(g, "test.ttl")
- Returns:
path -- Path to the RDF file where the graph will be saved.
- Return type:
Path