Build Time expanded Graph

Builds the Time expanded Graph.

builders.build_time_expanded.add_edges_for_footpaths(stop_times_file, nodes_dict: dict, transfers_file)list[source]

Adds edges corresponding to footpaths

Parameters
  • stop_times_file (pandas.dataframe) – dataframe with stoptimes details.

  • transfers_file (pandas.dataframe) – dataframe with transfers (footpath) details.

  • nodes_dict (dict) – mapping dictionary. Format: {(stop id, arrival time): new node id}

Returns

list of tuples of format: [(from node id, to node id, weight)]

Return type

foot_connection (list)

Examples

>>> foot_connections = add_edges_for_footpaths(stop_times_file, nodes_dict, transfers_file)
builders.build_time_expanded.add_edges_for_trips(stop_times_file, nodes_dict: dict)list[source]

Adds edges corresponding to trips

Parameters
  • stop_times_file (pandas.dataframe) – dataframe with stoptimes details.

  • nodes_dict (dict) – mapping dictionary. Format: {(stop id, arrival time): new node id}

Returns

list of tuples of format: [(from node id, to node id, weight)]

Return type

trip_edges (list)

Examples

>>> trip_edges = add_edges_for_trips(stop_times_file, nodes_dict)
builders.build_time_expanded.add_transfer_edges(stop_times_file, nodes_dict: dict)list[source]

Adds transfer edges between nodes

Parameters
  • stop_times_file (pandas.dataframe) – dataframe with stoptimes details.

  • nodes_dict (dict) – mapping dictionary. Format: {(stop id, arrival time): new node id}

Returns

list of tuples of format: [(from node id, to node id, weight)]

Return type

transfer_edges (list)

Examples

>>> transfer_edges = add_transfer_edges(stop_times_file, nodes_dict)
builders.build_time_expanded.combine_edges(trip_edges: list, foot_connections: list, transfer_edges: list)list[source]

Combines all 3 types of edges into a single list (trip, footpath, and transfer)

Parameters
  • trip_edges (list) – list of tuples of format: [(from node id, to node id, weight)]

  • foot_connections (list) – list of tuples of format: [(from node id, to node id, weight)]

  • transfer_edges (list) – list of tuples of format: [(from node id, to node id, weight)]

Returns

list of tuples of format: [(from node id, to node id, weight)]

Return type

edges (list)

Examples

>>> edge_list = combine_edges(trip_edges, foot_connections, transfer_edges)
builders.build_time_expanded.dump_edges_dict(edges: list, NETWORK_NAME: str)None[source]

Saves the edges list as a pickle file

Parameters
  • edges (list) – list of tuples of format: [(from node id, to node id, weight)]

  • NETWORK_NAME (str) – name of the network

Returns

None

Examples

>>> dump_edges_dict(edges, 'anaheim')
builders.build_time_expanded.dump_graph_dict(edges: list, NETWORK_NAME: str, nodes_dict: dict)None[source]

Builds and saves a networkx multigraph object.

Parameters
  • edges – list of edges. Format: [(from stop, to stop, weight)]

  • NETWORK_NAME (str) – name of the network

  • nodes_dict (dict) – mapping dictionary. Format: {(stop id, arrival time): new node id}

Returns

None

Examples

>>> dump_graph_dict(edges, 'anaheim', nodes_dict)
builders.build_time_expanded.initialize()tuple[source]

Takes the required inputs for building Time expanded graph

Returns

string GENERATE_LOGFILE (int): 1 to redirect and save a log file. Else 0 start_time: timestamp object

Return type

breaker (str)

Examples

>>> breaker, start_time, GENERATE_LOGFILE = initialize()
builders.build_time_expanded.main()None[source]

Main function

Returns

None

Examples

>>> main()