多层平面图映射
这里有一系列建筑物,每栋建筑物都有多层,通过楼梯和电梯相互连接。目前,我正在尝试设计一个系统,该系统将找到跨任何建筑物(同一建筑物或另一建筑物)的两点之间的最短路径。
目前,每层楼都以图表形式建模,如下所示: 每个房间的门都是一个顶点。连接房间与主边缘(走廊)的边的交汇处也是一个顶点。 楼层之间的楼梯是边缘。
剩下的问题是我应该如何表示电梯(就在楼梯旁边)? 将它作为边缘让我想知道它应该有什么权重,因为我必须在找到最短路径之后运行图形遍历算法。
提升(电梯)作为边还是作为顶点?这就是问题所在。 谢谢!
There's a collection of buildings each having multiple floors that are interconnected by stairs and lifts. Currently, I'm attempting to design a system that will find the shortest-path between two points across the any of the buildings, being the same building or in another building.
At the moment each floor is modeled in a graph as follows:
the door of each room is a vertex. the junctions of edges connecting the rooms to the main edge(corridor) is also a vertex.
The stairs between the floors are edges.
The question that remains is how should I represent the lifts(elevators) (which are right next to the stairs)?
To have it as an edge makes me wonder what weight it should have, given that I'll have to run a graph traversal algorithm after for finding the shortest path.
Lift(elevator) as edge or as vertex? That is the question.
thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
边缘
使用边缘是最直接的答案,就像楼梯一样。然而,虽然楼梯只能从 X 层到 X+1 层,但电梯可以从任何楼层到任何楼层,时间略有不同 - 我通常发现两层楼的楼梯速度更快,但 2 层以上的楼梯速度较慢。镜像这个你需要从每个楼层到每个其他楼层的边缘,并完成每个楼层的权重。
顶点
您可以有一些额外的顶点和边。如果电梯井的每一层都有一个顶点,那么您只需要一条将所有楼层连接在一起的边路径,而不是组合数量的边。
如果您还在每个楼层的门外添加了一个额外的顶点,那么您可以添加进入电梯的平均延迟,从而反映电梯可以快速通过多个楼层的事实。然而,电梯最多需要平均时间。在繁忙的时候,它们最终可能会停在几乎每个楼层,因此对于繁忙的校园,您不会真正从这些额外的顶点中获益。
我的投票是为电梯的每一层设置一个顶点,并用一条边连接相邻楼层。由于路径较少,它应该简化图形并减少任何路径优化算法的工作量。此外,它更准确地反映了现实情况,并最大限度地减少了设置边权重的工作量。
Edges
Using an edge is the most immediate answer, as you do that for stairs. However, while stairs can only go from floor X to floor X+1, a lift can go from any floor to any floor, with slightly different times - I usually find the stairs quicker for two floors, but slower for more than 2. To mirror this you'll need an edge from every floor to every other floor, complete with weightings for each.
Vertices
You could instead have some additional vertices as well as edges. If you had a vertex at each floor of the liftshaft, then you'd only need a single path of edges connecting all the floors together, rather than a combinatorial number of edges.
If you also added an additional vertex outside the doors at each level, then you could add the average delay for getting into a lift and so reflect the fact that a lift can pass multiple floors quickly. However, lifts are going to need average timings at best. At busy times, they can end up stopping at almost every floor anyway, so for a busy campus you wouldn't really gain from these extra vertices.
My vote is for a vertex for each floor of the lift and a single edge to link adjacent floors. It should simplify the graph and reduce the effort of any path-optimisation algorithm as there are fewer paths. Plus it is a more accurate reflection of reality and minimises your workload to set up the edge weights.
如果电梯是从一层到下一层的可能最短路径,那么它们必须是带有重物的边缘。每个级别的入口都是顶点。如果距离楼梯足够近,那么它们可以与楼梯顶点共享。
If the lifts are a possible shortest path from one floor to the next, then they must be edges with weights. The entrances to each level are vertices. If close enough to the stairs then they are possible shared with the stair vertices.
我投票给边缘。
假设您选择使用电梯。你走到它那里,按下按钮,然后稍等一下。然后你进去,再等一会儿,下车继续你的步行。现在,虽然你的身体移动不多,但随着时间的推移,你已经在移动了。乘坐电梯在楼层之间就像步行 50 米一样。
我的意思是,电梯周围站立的时间相当于步行的距离。因此,将电梯视为您在使用电梯期间行走的边缘。使用该距离进行比较,例如走下楼梯。
I vote for edge.
Say you choose to use an elevator. You walk to it, press button and wait a bit. You then get in, wait some more, get out and continue your walk. Now, although you are physically not moving much, in time you are moving. Taking a lift between floors is like walking, say, 50 meters.
What I mean is that the time spent standing around the elevator is equivalent to a distance that you travel if walking. So treat the elevator as an edge that you are walking along during the duration that you are using it. Use that distance to compare, say, walking down the stairs.