Traffic simulation : directed graph including specific rules

  • Context: Undergrad 
  • Thread starter Thread starter Guitz
  • Start date Start date
Click For Summary
SUMMARY

This discussion focuses on implementing a directed graph for traffic simulation, specifically prohibiting U-turns at bends and crossroads while allowing them at dead ends. The user seeks modifications to their graph data structure and the A* or Dijkstra's algorithm to meet these requirements. Key suggestions include refining node visitation flags and potentially transforming undirected graphs into directed graphs to represent valid travel directions. The conversation emphasizes the need for a systematic approach to adjust the graph structure and algorithm to achieve the desired traffic simulation behavior.

PREREQUISITES
  • Understanding of directed graphs and their properties
  • Familiarity with A* and Dijkstra's algorithms
  • Knowledge of graph data structures and traversal techniques
  • Basic programming skills for implementing graph algorithms
NEXT STEPS
  • Research how to modify A* algorithm for specific node traversal rules
  • Learn about graph transformations from undirected to directed graphs
  • Explore advanced graph data structures for traffic simulation
  • Investigate existing libraries or frameworks for traffic simulation modeling
USEFUL FOR

Software developers, traffic simulation engineers, and data scientists interested in optimizing directed graph algorithms for traffic management applications.

Guitz
Messages
22
Reaction score
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
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 which node it has already been entered.

Did you really not find any code online for this?
 
Last edited:
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   Reactions: Guitz and FactChecker
thanks a lot for your replies
 
  • Like
Likes   Reactions: berkeman
A.T. said:
Did you really not find any code online for this?
Unfortunately no
 
  • Like
Likes   Reactions: Guitz

Similar threads

  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 13 ·
Replies
13
Views
3K
Replies
24
Views
8K
  • · Replies 12 ·
Replies
12
Views
6K