Network construction.
More...
#include <string.h>
#include "osurs/network.h"
|
Network * | new_network () |
| Create a new network. More...
|
|
Node * | new_node (Network *network, const char *id, double x, double y) |
| Create a new node and add it to the network. More...
|
|
Route * | new_route (Network *network, const char *id, Node *nodes[], int arrival_offsets[], int departure_offsets[], size_t route_size, const char *trip_ids[], int departures[], Vehicle *vehicles[], size_t trip_size) |
| Create a new route and add it to the network. More...
|
|
Vehicle * | new_vehicle (Network *network, const char *id, Composition *composition) |
| Create a new vehicle and add it to the network. More...
|
|
Composition * | new_composition (Network *network, const char *id, int seat_count) |
| Create a new composition and add it to the network. More...
|
|
Network construction.
- Date
- : 2022-07-12
- Author
- : Merlin Unterfinger
◆ new_composition()
Create a new composition and add it to the network.
- Parameters
-
network | The network to add the composition. |
id | The id of the composition. |
seat_count | The seat capacity of the composition. |
- Returns
- A pointer to the newly allocated node (Composition*).
◆ new_network()
Create a new network.
The network consists of nodes where vehicles stop and passengers can get on and off. A route stores the order in which the nodes are approached by a vehicle in a chain of stops. Each stop contains information about which stop is next and how long it takes to reach it. On routes, trips indicate the departure times at which a vehicle leaves from the route's root stop. Vehicle information such as capacity and reservations are stored at the trip level.
- Note
- All objects of the network are located on the heap and are directly or indirectly linked to the network structure. If the memory of the network is released (delete_network(Network *)) all associated structures of the network are also cleared.
- Returns
- Network*
◆ new_node()
Node* new_node |
( |
Network * |
network, |
|
|
const char * |
id, |
|
|
double |
x, |
|
|
double |
y |
|
) |
| |
Create a new node and add it to the network.
- Parameters
-
network | The network to add the node. |
id | The id of the node. |
x | The x coordinate of the node. |
y | The y coordinate of the node. |
- Returns
- A pointer to the newly allocated node (Node*).
◆ new_route()
Route* new_route |
( |
Network * |
network, |
|
|
const char * |
id, |
|
|
Node * |
nodes[], |
|
|
int |
arrival_offsets[], |
|
|
int |
departure_offsets[], |
|
|
size_t |
route_size, |
|
|
const char * |
trip_ids[], |
|
|
int |
departures[], |
|
|
Vehicle * |
vehicles[], |
|
|
size_t |
trip_size |
|
) |
| |
Create a new route and add it to the network.
- Parameters
-
network | The network to add the route. |
id | The identifier of the route. |
nodes | A pointer to an array of nodes, which define the stops of the route (n=route_size). |
arrival_offsets | A pointer to an array of arrival offset times from the root stop. The offsets define the travel times between the departure of the root stop and the arrival at the current stop (n=route_size). |
departure_offsets | A pointer to an array of departure offset times from the root stop. The offsets define the travel times between the departure of the root stop and the departure at the current stop (n=route_size). |
route_size | The number of nodes (=stops) in the route. |
trip_ids | The identifier of the trips on the route (n=trip_size). |
departures | The departure times at the first node (=root_stop) of the route in seconds after midnight (00:00:00). Every departure time will define a new trip, which starts traveling along the route (n=trip_size) |
vehicles | An array of vehicles for each trip (n=trip_size). |
trip_size | The number of departures (=trips) on the route. |
- Returns
- A pointer to the newly allocated node (Route*).
◆ new_vehicle()
Create a new vehicle and add it to the network.
- Parameters
-
network | The network to add the vehicle. |
id | The id of the vehicle. |
composition | The composition the vehicle has. |
- Returns
- A pointer to the newly allocated vehicle (Vehicle*).