Traffic simulation : directed graph including specific rules

  • I
  • Thread starter Guitz
  • Start date
In summary, the algorithm must exclude the previous node from the nodes to traverse next, unless its the only option.
  • #1
Guitz
22
8
Hi all,

I'm trying to use a directed graph for a traffic simulation program.

This is an example of a simplified graph :

graph.gif


The red triangle is the position and orientation of the car. The green circle is the destination node.

I wish to prohibit a U-turn on a bend and a crossroads but I authorize it on a dead end (node 4).

The array of nodes (3, 6, 8) is therefore prohibited.
Likewise (3, 1, 3, 6, 8) is forbidden.
On the other hand, (3, 1, 2, 3, 6, 8) and (3, 4, 3, 6, 8) are allowed. The latter being the shortest path.

How please modify the data structure of my graph and the A* (or Dijkstra's) algorithm to achieve my goals?

Thanks
 
Last edited:
Mathematics news on Phys.org
  • #2
Your search algorithm must exclude the previous node from the nodes to traverse next, unless its the only option.

If a search algorithm marks nodes as allread visted (to abort subsequent longer paths), then you must refine this flag to encode from wich node it has already been entered.

Did you really not find any code online for this?
 
Last edited:
  • #3
I would probably also consider changing the algorithm to adjust for the need at hand, but in case you are somehow required to use a "standard" algorithm unchanged you can perhaps consider to generate a new directed graph from your undirected graph such that the two travel directions on each edge is transformed into a node and these nodes are then connected with directed edges representing valid ways through an intersection or end-point.

This should be possible to do in a fairly mechanic way. For example, the sub-graph from your nodes 1, 2 and 3 you would add the nodes and transitions (1-2) -> (2-3) -> (3-1) and (3-2) -> (2-1) -> (1-3), that is two isolated cycles. Adding your node 4 to this would then add nodes (3-4) and (4-3) along with the transitions {(1-3), (2-3)} -> (3-4) -> (4-3) -> {(3-1), (3-2)}, and so forth.

Old suggestion that was only half baked:
Perhaps it is possible to transform your problem into a directed graph where your original nodes with more than one edge is replaced by two nodes, each with directed edges in relevant directions?
 
Last edited:
  • Like
Likes Guitz and FactChecker
  • #4
thanks a lot for your replies
 
  • Like
Likes berkeman
  • #5
A.T. said:
Did you really not find any code online for this?
Unfortunately no
 
  • #6
  • Like
Likes Guitz

1. What is a traffic simulation directed graph?

A traffic simulation directed graph is a visual representation of a road network, where nodes represent intersections and edges represent roads. This graph is used to simulate the flow of traffic and understand how different factors, such as traffic lights and road rules, affect the overall traffic patterns.

2. How are specific rules incorporated into the traffic simulation directed graph?

Specific rules, such as speed limits, traffic light timings, and road signs, are incorporated into the traffic simulation directed graph through the use of algorithms. These algorithms take into account the rules and apply them to the simulation to accurately reflect real-world traffic conditions.

3. What is the purpose of a traffic simulation directed graph?

The purpose of a traffic simulation directed graph is to study and analyze traffic patterns in a controlled environment. By simulating different scenarios and implementing specific rules, researchers and city planners can better understand how to improve traffic flow and reduce congestion on real roads.

4. How is data collected for a traffic simulation directed graph?

Data for a traffic simulation directed graph can be collected through various methods, such as traffic cameras, GPS devices, and surveys. This data is then used to create a realistic simulation that accurately reflects the behavior of drivers on the road network.

5. What are the benefits of using a traffic simulation directed graph?

There are several benefits to using a traffic simulation directed graph. It allows researchers and city planners to test different scenarios and make informed decisions on how to improve traffic flow. It also provides a cost-effective and safe way to study traffic patterns without disrupting real traffic. Additionally, it can help identify potential issues and improve road design before it is implemented in the real world.

Similar threads

  • General Math
Replies
5
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
4
Views
1K
  • Programming and Computer Science
Replies
15
Views
2K
Replies
1
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
9
Views
1K
  • Programming and Computer Science
Replies
7
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
5K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
1K
  • Astronomy and Astrophysics
Replies
2
Views
3K
  • Math Proof Training and Practice
2
Replies
60
Views
8K
Back
Top