Assuming I have a list of nodes that have position x,y, each node has an index, and each node stores all its connections, how could I find the nearest point on a line segment? I was able to come up with something but it isn't able to differentiate between line segments and two nodes that aren't connected.
For example, assume I have node 1, 2, and 3. Node 1 is connected to node 2 and node 2 is connected to node 3. I have point A that I want to find the nearest point on line segments. In this case, it is some point between node 1 and 2. How could I find that point? How could I make sure that it doesn't try to check between 1 and 3?