I Traffic simulation : directed graph including specific rules

  • I
  • Thread starter Thread starter Guitz
  • Start date Start date
AI Thread Summary
A directed graph is being utilized for a traffic simulation program, where specific rules prohibit U-turns at bends and crossroads but allow them at dead ends. The user seeks to modify their graph's data structure and adapt the A* or Dijkstra's algorithm to implement these restrictions. Suggestions include refining the search algorithm to exclude previously visited nodes unless necessary and potentially transforming the undirected graph into a directed one to reflect valid travel paths. The discussion emphasizes the need for a systematic approach to create directed edges that represent permissible movements through intersections. The user is encouraged to explore coding resources online for further assistance.
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 wich 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 Guitz and FactChecker
thanks a lot for your replies
 
A.T. said:
Did you really not find any code online for this?
Unfortunately no
 
Suppose ,instead of the usual x,y coordinate system with an I basis vector along the x -axis and a corresponding j basis vector along the y-axis we instead have a different pair of basis vectors ,call them e and f along their respective axes. I have seen that this is an important subject in maths My question is what physical applications does such a model apply to? I am asking here because I have devoted quite a lot of time in the past to understanding convectors and the dual...
Insights auto threads is broken atm, so I'm manually creating these for new Insight articles. In Dirac’s Principles of Quantum Mechanics published in 1930 he introduced a “convenient notation” he referred to as a “delta function” which he treated as a continuum analog to the discrete Kronecker delta. The Kronecker delta is simply the indexed components of the identity operator in matrix algebra Source: https://www.physicsforums.com/insights/what-exactly-is-diracs-delta-function/ by...

Similar threads

Replies
5
Views
2K
Replies
2
Views
4K
Replies
125
Views
19K
Replies
1
Views
2K
Replies
1
Views
2K
Replies
13
Views
3K
Back
Top