Mapping graph

Hey everyone.

I want a bot to scan/follow the lines in a room and maps the graph itself with a starting and an end point to find the shortest path. I am using array of IR to make it follow the lines, but how do I make the bot to create the graph itself? Please help