Define a class for a directed graph representing a traffic network. The types of nodes are: 1) location nodes, such as cities, parking lots, etc.—anything that can serve as a starting point or destination for a drive, 2) road nodes, which represent a road or road segment, in one direction, between exactly two nodes in the graph, and 3) intersection nodes, which can connect multiple roads. For each road node, the following data is stored: 1) the road length in meters, which determines the weight between the nodes that the road node connects, 2) the maximum allowed speed on the road, and 3) the maximum number of vehicles on the road. Road nodes are connected to intersection nodes, so road nodes that have a directed connection to an intersection node are considered incoming nodes, while road nodes to which the intersection node has directed connections are considered outgoing nodes. In this context, for each pair of incoming and outgoing nodes, it is defined whether it is possible to move from that incoming node to that outgoing node, the distance in meters that needs to be covered, and the average speed of vehicles, which depends on the current number of vehicles at the intersection. Additionally, it should be possible to specify the maximum allowed number of vehicles at the intersection. Serialization and deserialization of the traffic network graph should be enabled.
Define a class that represents vehicles. A vehicle moves from one location to another. Each vehicle has a defined average speed that it tends to maintain on the road, with the actual speed of the vehicle at any given time being limited by the maximum speed allowed on the road segment. It should be possible to calculate the best route for the vehicle through the traffic network, in order to minimize either the distance traveled or the time spent, taking into account the road lengths and speed limits on the road.
I tried with basic clas Node and three derived classes Location Road and Intersection
Kuzmax is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.