Imagine that I have a 6x6 square consisting of 36 vertices (i.e. 6 vertices per row and 6 vertices per column), looks something like this:
• • • • • •
• • • • • •
• • • • • •
• • • • • •
• • • • • •
• • • • • •
Each vertex is either connected with 1, 2, 3, or 4 close vertices, so we basically get a graph with vertices and edges. My problem is this: I want the robot to go through this “maze” of edges until it finds a specific object placed at some vertex. As soon as he discovers this object, he must return to the starting point using the fastest way back.
Now I'm not quite sure how to implement this, so my question is: what is the best structure to store information about these vertices and edges in C? (The adjacency matrix seems ineffective to me, since 36x36 is quite large). And using this information, how can I find a quick way to get back to the beginning?
vauge source
share