# What is the best way to represent a map

Page 1 of 1

## 2 Replies - 746 Views - Last Post: 03 February 2013 - 07:44 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=311037&amp;s=0d3e72626fc7f782870c919719f0c7bc&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 <3DIC

• D.I.C Regular

Reputation: 6
• Posts: 327
• Joined: 06-October 10

# What is the best way to represent a map

Posted 03 February 2013 - 03:02 PM

I am trying to represent a map and I am wondering what is the best data structure to do so?

I though about using a graph, so that I can use Dijkstra's algorithm to find the shortest path from one room to another. But I am now wondering if that is a good approaph, maybe I should use a HashMap instead?

If you're curious here is the map I am trying to represent. (I am going to program a robot to navigate from one room to another. The rooms are the squares with numbers and the red lines are the doors to the rooms and the robot has to travel along the blue line only.)

Is This A Good Question/Topic? 0

## Replies To: What is the best way to represent a map

### #2 macosxnerd101

• Games, Graphs, and Auctions

Reputation: 11447
• Posts: 43,144
• Joined: 27-December 08

## Re: What is the best way to represent a map

Posted 03 February 2013 - 04:08 PM

A Map would be a good data structure for modeling a series of adjacency lists, which is a common representation of a graph. You could still apply Dijkstra's algorithm to an adjacency list representation, which is the preferred representation for such path-finding algorithms.

### #3 CasiOo

• D.I.C Lover

Reputation: 1514
• Posts: 3,375
• Joined: 05-April 11

## Re: What is the best way to represent a map

Posted 03 February 2013 - 07:44 PM

So the squares are the rooms, the red lines are doors, but what are the red/blue dots and the triangles?

How does one get into room 5?