neo4j中的出租车共享计划

编程入门 行业动态 更新时间:2024-10-23 15:23:20
本文介绍了neo4j中的出租车共享计划的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想问您一些有关我的Java应用程序的建议和想法,以计算共享行车的出租车时间表.

I would like to ask you some suggestions and ideas for my java application to compute a taxi scheduling with sharing ride.

让我们假设我有一辆有两个用户(乘客)的出租车.用户将共享行程,但是两位乘客都位于不同的地方,并且将在不同的时间上落.带有其上下车地点的用户模型为:

Let's suppose that i have a taxi with two users (passengers). The users are going to share the trip, but both passengers are located in different places and are going to be picked up/dropped off at different times. The user model with its pick up and drop off locations, is:

(Grid1)<-[:PICK_UP {time:'10:30'}]-(user1)-[:DROP_OFF {time:'11:00'}]->(Grid9) (Grid4)<-[:PICK_UP {time:'10:15'}]-(user2)-[:DROP_OFF {time:'10:45'}]->(Grid11)

或者甚至我可以在用户节点内编写所有属性,例如用户1

Or even i can write all the properties inside a User Node e.g. user 1

pickUpLocation:'Grid1' pickUpTime:'10:30' dropOffLocation:'Grid9' dropOffTime:'11:00'

两个选项都可以吗?

我想计算出租车路径调度,以便知道必须先/最后放下/放下哪个用户,如下所示:

I would like to compute the taxi path scheduling, in order to know which user has to be picked/dropped first/last, something like this:

Grid4 --- Grid1 --- Grid11 --- Grid9 10:15 10:30 10:45 11:00 (pick (pick (drop (drop user2) user1) user2) user1)

我的想法是获取每个用户的拾取时间值,并将其存储到Collection(TreeSet)中,然后对放置时间执行相同的操作.这样我就可以订购有序的收藏品.那是个好主意吗?

My idea is to get the pick up-time value for each user, and store it into a Collection(TreeSet), then do the same with the drop-times. So i can get an ordered collection. Is that a good idea??

但是,我应该在哪里存储网格位置(Grid4,Grid1等)?因此,最后,我可以获取出租车的所有信息,前往何处以及何时到达.

But then, where should i store the Grid location (Grid4, Grid1, etc.)?? So then at the end, i can have all the information for the taxi, Where to go and at what time.

有什么建议或想法吗?

提前谢谢!

推荐答案

这当然取决于您的要求,但是我觉得您缺少一个实体.我可能会称其为Ride或预订".以下可能是有道理的:

This all depends on your requirements of course, but I feel like you're missing an entity. I would probably call it Ride or `Reservation'. The following might make sense:

(:User)-[:BOOKED_RIDE]->(:Ride) (:Ride)-[:STARTS_AT]->(:GridItem) (:Ride)-[:ENDS_AT]->(:GridItem)

STARTS_AT可以具有time属性.

对于两个用户,以下Cypher可能提供了有关如何查询的示例:

For two users the following Cypher might provide an example of how to query:

MATCH (user1:User), (user2:User) MATCH (user1)-[:BOOKED_RIDE]->(ride1:Ride), (user2)-[:BOOKED_RIDE]->(ride2:Ride), (start1)<-[start_rel1:STARTS_AT]-(ride1)-[end_rel1:ENDS_AT]->(end1), (start2)<-[start_rel2:STARTS_AT]-(ride2)-[end_rel2:ENDS_AT]->(end2) WITH [ {grid_item: start1, time: start_rel1.time}, {grid_item: end1, time: end_rel1.time}, {grid_item: start2, time: start_rel2.time}, {grid_item: end2, time: end_rel2.time} ] AS stops UNWIND stops AS stop WITH stop ORDER BY stop.time RETURN collect(stop) AS stops

当然,可能会有更多的逻辑(特别是如果您正在使用Neo4j Java API),但这可能是一个艰难的开始.

Of course there might be more logic to it (especially if you're using the Neo4j Java APIs), but that might be a rough start.

更多推荐

neo4j中的出租车共享计划

本文发布于:2023-11-30 21:04:37,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1651464.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:出租车   计划   neo4j

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!