aequilibrae.paths.Graph#
- class aequilibrae.paths.Graph(*args, **kwargs)[source]#
-
Methods
__init__
(*args, **kwargs)Returns graph fields that are available to be set as skims
Create three arrays providing a mapping of compressed ID to link ID.
default_types
(tp)Returns the default integer and float types used for computation
exclude_links
(links)Excludes a list of links from a graph by setting their B node equal to their A node
load_from_disk
(filename)Loads graph from disk
prepare_graph
([centroids])Prepares the graph for a computation for a certain set of centroids
save_compressed_correspondence
(path, ...)Save graph and nodes_to_indices to disk
save_to_disk
(filename)Saves graph to disk
set_blocked_centroid_flows
(block_centroid_flows)Chooses whether we want to block paths to go through centroids or not.
set_graph
(cost_field)Sets the field to be used for path computation
set_skimming
(skim_fields)Sets the list of skims to be computed
- available_skims() List[str] #
Returns graph fields that are available to be set as skims
- Returns:
list (
str
): Field names
- create_compressed_link_network_mapping()#
Create three arrays providing a mapping of compressed ID to link ID.
Uses sparse compression. Index ‘idx’ by the by compressed ID and compressed ID + 1, the network IDs are then in the range
idx[id]:idx[id + 1]
.Links not in the compressed graph are not contained within the ‘data’ array.
>>> project = create_example(project_path) >>> project.network.build_graphs() >>> graph = project.network.graphs['c'] >>> graph.prepare_graph(np.arange(1,25)) >>> idx, data, node_mapping = graph.create_compressed_link_network_mapping()
- Returns:
idx (
np.array
): index array fordata
data (
np.array
): array of link idsnode_mapping: (
np.array
): array of node_mapping ids
- default_types(tp: str)#
Returns the default integer and float types used for computation
- Arguments:
tp (
str
): data type. ‘int’ or ‘float’
- exclude_links(links: list) None #
Excludes a list of links from a graph by setting their B node equal to their A node
- Arguments:
links (
list
): List of link IDs to be excluded from the graph
- load_from_disk(filename: str) None #
Loads graph from disk
- Arguments:
filename (
str
): Path to file
- prepare_graph(centroids: ndarray | None = None) None #
Prepares the graph for a computation for a certain set of centroids
Under the hood, if sets all centroids to have IDs from 1 through n, which should correspond to the index of the matrix being assigned.
This is what enables having any node IDs as centroids, and it relies on the inference that all links connected to these nodes are centroid connectors.
- Arguments:
centroids (
np.ndarray
): Array with centroid IDs. Mandatory type Int64, unique and positive
- save_compressed_correspondence(path, mode_name, mode_id)#
Save graph and nodes_to_indices to disk
- save_to_disk(filename: str) None #
Saves graph to disk
- Arguments:
filename (
str
): Path to file. Usual file extension is ‘aeg’
- set_blocked_centroid_flows(block_centroid_flows) None #
Chooses whether we want to block paths to go through centroids or not.
Default value is
True
- Arguments:
block_centroid_flows (
bool
): Blocking or not
- set_graph(cost_field) None #
Sets the field to be used for path computation
- Arguments:
cost_field (
str
): Field name. Must be numeric
- set_skimming(skim_fields: list) None #
Sets the list of skims to be computed
Skimming with A* may produce results that differ from traditional Dijkstra’s due to its use a heuristic.
- Arguments:
skim_fields (
list
): Fields must be numeric