ra2ce.network.graph_files package#
Submodules#
ra2ce.network.graph_files.graph_file module#
- class GraphFile(name='', folder=None, graph=None)[source]#
Bases:
GraphFileProtocolNote this class resembles NetworkFile to a large extent
- Parameters:
name (str)
folder (Path)
graph (MultiGraph)
- property file: Path | None#
Return the path to the graph
- Returns:
Path | None: _description_
-
folder:
Path= None#
- get_graph()[source]#
Gets a graph file that is already known in the object. It is read if not done yet.
Args: None
- Return type:
MultiGraph
- Returns:
MultiGraph | GeoDataFrame: the graph
-
graph:
MultiGraph= None#
-
name:
str= ''#
ra2ce.network.graph_files.graph_files_collection module#
- class GraphFilesCollection(base_graph=<factory>, base_graph_edges=<factory>, base_graph_hazard=<factory>, base_graph_hazard_edges=<factory>, origins_destinations_graph=<factory>, origins_destinations_graph_hazard=<factory>, base_network=<factory>, base_network_hazard=<factory>, locations_hazard=<factory>)[source]#
Bases:
objectClass containing a collection of the graphs and the paths to the files. The names of the graph file are assumed to be standardized (e.g. “base_graph.p”).
- Parameters:
base_graph (GraphFile)
base_graph_edges (NetworkFile)
base_graph_hazard (GraphFile)
base_graph_hazard_edges (NetworkFile)
origins_destinations_graph (GraphFile)
origins_destinations_graph_hazard (GraphFile)
base_network (NetworkFile)
base_network_hazard (NetworkFile)
locations_hazard (NetworkFile)
-
base_graph_edges:
NetworkFile#
-
base_graph_hazard_edges:
NetworkFile#
-
base_network:
NetworkFile#
-
base_network_hazard:
NetworkFile#
- get_file(graph_file_type)[source]#
Get the file path to the graph
- Return type:
Path|None- Parameters:
graph_file_type (str)
- Args:
graph_file_type (str): Type of graph file
- Returns:
Path: Path to the graph file
- get_graph(graph_file_type)[source]#
Get the graph
- Return type:
MultiGraph|GeoDataFrame- Parameters:
graph_file_type (str)
- Args:
graph_file_type (str): Type of graph file
- Returns:
GraphFileProtocol: Graph of that specific graph_file_type
- has_graphs()[source]#
Tests if any of the types has a graph already read
- Return type:
bool
- Returns:
bool: True if any graph already read
-
locations_hazard:
NetworkFile#
- read_graph(file)[source]#
Read a graph file via the collection
- Return type:
None- Parameters:
file (Path)
- Args:
file (Path): Path fo the graph
- Raises:
ValueError: If the graph_file_type is not one of the known types
Returns: None
- set_file(file)[source]#
Set a path to a graph via the collection
- Return type:
None- Parameters:
file (Path)
- Args:
file (Path): Path of the graph
- Raises:
ValueError: If the graph_file_type is not one of the known types
- classmethod set_files(parent_dir)[source]#
Create a new collection with 1 or more graph files that match the default names
- Return type:
- Parameters:
parent_dir (Path)
- Args:
parent_dir (Path): Path of the parent folder in which the files are searched
- Returns:
GraphFilesCollection: Collection of graphs
- set_graph(graph_file_type, graph)[source]#
Set a graph via the collection based on type of graph
- Args:
graph_file_type (str): Type of graph file graph (MultiGraph | GeoDataFrame): The graph
- Raises:
ValueError: If the graph_file_type is not one of the known types
- Parameters:
graph_file_type (str)
graph (MultiGraph | GeoDataFrame)
ra2ce.network.graph_files.graph_files_protocol module#
- class GraphFileProtocol(*args, **kwargs)[source]#
Bases:
Protocol- property file: Path | None#
Return the path to the graph
- Returns:
Path | None: _description_
-
folder:
Path#
- get_graph()[source]#
Gets a graph file that is already known in the object. It is read if not done yet.
Args: None
- Return type:
MultiGraph|GeoDataFrame
- Returns:
MultiGraph | GeoDataFrame: the graph
-
graph:
MultiGraph|GeoDataFrame#
-
name:
str#
ra2ce.network.graph_files.network_file module#
- class NetworkFile(name='', folder=None, graph=None)[source]#
Bases:
GraphFileProtocolNote this class resembles GraphFile to a large extent
- Parameters:
name (str)
folder (Path)
graph (GeoDataFrame)
- property file: Path | None#
Return the path to the graph
- Returns:
Path | None: _description_
-
folder:
Path= None#
- get_graph()[source]#
Gets a graph file that is already known in the object. It is read if not done yet.
Args: None
- Return type:
GeoDataFrame
- Returns:
MultiGraph | GeoDataFrame: the graph
-
graph:
GeoDataFrame= None#
-
name:
str= ''#