简体   繁体   中英

Efficient way to build an indoor graph of a building to implement path finding?


Lets say, my data set is a shopping mall.
I have to build a graph for it. Whenever asked, I have to generate a path (shortest path) from one shop to another.
Now my question is,

  1. Is it efficient to build a graph of the whole building and generate the path?

  2. Or build a graph (something like a subgraph) between only the 2 nodes and all its connectors (edges) when a user needs to find the path?

I have to implement this for a mobile application where all the data is loaded from a server.
My current code builds the whole graph. But I want to use this as a library for future use.
If it is only for the current building, then it works fine.
But assuming that in the future another type of data set is used which is way too big that the current one, then which one of these methods is more efficient?
These are the only 2 ways I can think of implementing it. If there is any other solution then that would be highly appreciated!

Secondly, I am using Dijkstra's Algorithm for path finding, is that suitable for this kind of a case?

Any help would be highly appreciated,

Thanks.

  1. Is it efficient to build a graph of the whole building and generate the path?
  2. Or build a graph (something like a subgraph) between only the 2 nodes and all its connectors (edges) when a user needs to find the path?

If the graph is known a priori, the most efficient solution, in regards to query times, will be to generate the whole graph and preprocess it. Then, you will query the contracted graph and have a very fast query time. Look for example at Contraction hierarchies , since it is one of the most widely used techniques. Otherwise, when the graph has to be built in runtime, I think it is what you mean with your second point, you could use A* or bidirectional Dijkstra. In the first one I guess the best heuristic you can come up is the straight line distance, so probably not very helpful.

Secondly, I am using Dijkstra's Algorithm for path finding, is that suitable for this kind of a case?

Yes it is, but I would always use bidirectional Dijkstra, it's not difficult to implement and, generally, a great improvement in time requirements over unidirectional Djikstra. Some related questions in SO: 1 , 2

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM