Added function for converting map to graph.