I implemented a simple Dijkstra algorithm to find the shortest path on a .osm map with Java.
The graphic search pattern that is generated from the .osm file works very well. But if the user's current location and / or destination are not a node of this graph (only the raw coordinates), how do we associate these coordinates with the graph to do the job of finding the paths?
The simple direct solution to “find the node closest to the current location and draw a straight line” does not seem realistic. What if we have a situation like in the attached picture? (UPD)

, , - "" (, Dijkstra's), "" , ( ) node , "" - .
- A B, B node , A node?
?