Data Structures with C Project Year 2016
The train is to have 15 bogeys. Each bogey contains one item to be dropped off at a certain destination. The map and bogey details are to be entered by the user. The program then routes the train in an efficient path.
train.c contains the main program. First number of stations are taken using getstation(). Stations are then numbered from 0 to N-1, where N is the number of stations. 0 is the source station.
Next, a station map is to be created. All related functions lie in station.h. Map is stored as an adjacency matrix.
Next, bogey details are input. All related functions lie in bogey.h.
Next route is created. All related functions lie in route.h, which in turn depends on graph.h, which has implementations of graph-related algorithms.
This function creates the route, implemented as a linked list, and returns head node.
- Only the required stations are taken, based on bogey details. The
reqStationsarray is used for this.reqStations[i]if1ifiis a required station,0ifiis not. - A subgraph is created using
createSubGraph(). - The source station is attached to the subgraph connecting to the nearest node in the subgraph
- A minimal spanning tree of this subgraph is made and stored as an adjacency matrix
- All leaf nodes are taken. A leaf node is a terminal station.
findLeaves()does this job - Route is created by the
createRoute()
- Initially
source = 0. - Loop until
leavesis empty:- Remove source from leaves, that is,
leaves[source] = 0 - Find the nearest leaf to
source - Append shortest path to nearest leaf from
sourcetoroute source= nearest leaf
- Remove source from leaves, that is,