9.5.1. aequilibrae.Graph

class aequilibrae.Graph

Bases: object

Graph class

__init__()

Initialize self. See help(type(self)) for accurate signature.

Methods

__init__()

Initialize self.

available_skims()

Returns graph fields that are available to be set as skims

create_from_geography(geo_file, id_field, …)

Creates a graph from a Shapefile.

default_types(tp)

Returns the default integer and float types used for computation

load_from_disk(filename)

Loads graph from disk

prepare_graph(centroids)

Prepares the graph for a computation for a certain set of centroids

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

__init__()

Initialize self. See help(type(self)) for accurate signature.

default_types(tp: str)

Returns the default integer and float types used for computation

Args:

tp (str): data type. ‘int’ or ‘float’

create_from_geography(geo_file: str, id_field: str, dir_field: str, cost_field: str, centroids: numpy.ndarray, skim_fields=[], anode='A_NODE', bnode='B_NODE') → None

Creates a graph from a Shapefile. (Deprecated)

Args:
geo_file (str): Path to the geographic file to be used. File is usually the output of the network

preparation tool from the AequilibraE plugin for QGIS

id_field (str): Name of the field that has link IDs (must be unique)

dir_field (str): Name of the field that has the link directions of flow ([-1, 0, 1])

cost_field (str): Name of the field that has the cost data (field to minimized in shortest path)

centroids (np.ndarray): Numpy Array with a list of centroids included in this graph

skim_fields (list): List with the name of fields to be skimmed

anode (str): Name of the field with information of A_Node of links (if different than A_NODE)

bnode (str): Name of the field with information of B_Node of links (if different than B_NODE)

prepare_graph(centroids: numpy.ndarray) → 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.

Args:

centroids (np.ndarray): Array with centroid IDs. Mandatory type Int64, unique and positive

set_graph(cost_field) → None

Sets the field to be used for path computation

Args:

cost_field (str): Field name. Must be numeric

set_skimming(skim_fields: list) → None

Sets the list of skims to be computed

Args:

skim_fields (list): Fields must be numeric

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

Args:

block_centroid_flows (bool): Blocking or not

save_to_disk(filename: str) → None

Saves graph to disk

Args:

filename (str): Path to file. Usual file extension is aeg

load_from_disk(filename: str) → None

Loads graph from disk

Args:

filename (str): Path to file

available_skims() → List[str]

Returns graph fields that are available to be set as skims

Returns:

list (str): Field names

_Graph__add_single_field(new_field)
_Graph__build_derived_properties()
_Graph__build_dtype(all_titles) → list
_Graph__reset_single_fields()