cfpq_data.graphs.readwrite.csv#

Read (and write) a graph from (and to) CSV file.

Functions

graph_from_csv(path)

Loads a graph from CSV file.

graph_to_csv(graph, path)

Saves the graph to the CSV file by path.

graph_from_csv(path: Path | str) MultiDiGraph[source]#

Loads a graph from CSV file.

Parameters:

path (Union[Path, str]) -- The path to the CSV file with which the graph will be created.

Examples

>>> from cfpq_data import *
>>> p = cfpq_data.download("generations")
>>> g = cfpq_data.graph_from_csv(p)
>>> g.number_of_nodes()
129
>>> g.number_of_edges()
273
Returns:

g -- Loaded graph.

Return type:

MultiDiGraph

graph_to_csv(graph: MultiDiGraph, path: Path | str) Path[source]#

Saves the graph to the CSV file by path.

Parameters:
  • graph (MultiDiGraph) -- Graph to save.

  • path (Union[Path, str]) -- The path to the CSV file where the graph will be saved.

Examples

>>> from cfpq_data import *
>>> p = download("generations")
>>> g = graph_from_csv(p)
>>> path = graph_to_csv(g, "test.csv")
Returns:

path -- Path to the CSV file where the graph will be saved.

Return type:

Path