how to convert a 2D dynamic Matrix to an array or DB Table

Started by
1 comment, last by ElCas 12 years, 4 months ago
I have a location map and I have created a 2D Matrix based on the currently existing entries where each rows and cols are the names of the location and the cell value are the number of hops to that destination. This matrix will shrink and grow as I add and remove locations from the DB.

Loc1|Loc2|Loc3|Loc#|
Loc1| 0 | 2 | 1 | # |
Loc2| 2 | 0 | 1 | # |
Loc3| 1 | 1 | 0 | # |
Loc#| # | # | # | # |

I figured could create a table with locations and number of hops and just create an entry for each possible combination but that would quickly eat up memory or HDD space as the list grows
i.e.
Distance
{
Origin
Destination
Hops
}

My question is, Is there a way to accomplish this more efficiently? The game is web-based so I want to find a solution that will not kill my bandwidth as users make their selections and attempt to find the quickest route to take to their final destination.
Advertisement
How frequently does your data change and how many locations will you have(10s? 100s? 1000s?)?

edit: You could probably generate it with a view, but I have to imagine it would be expensive. Unless your data is changing constantly I do not see storing the distance matrix on the db being the most efficient way to do it.

How frequently does your data change and how many locations will you have(10s? 100s? 1000s?)?


Currently there are 15 locations and I don't see it changing that often for now. I just want to have a system in place for future growth.

This topic is closed to new replies.

Advertisement