我正在为Neo4j开发路线规划器用于教育目的。我开发了一些关于它的算法,我在我的项目中使用了cypher查询和Rest API.Bu有一个问题是我没有修复的。我是试图通过dijkstra,shortestPath和我自己的算法计算neo4j的不同路线。
例如,有一些无意义的路由从neo4j计算。输出多次转移到另一个总线给用户,当我在neo4j中使用dijsktra算法时,它也与shortestPath类似。我想给5次转移最大值。如何防止这个问题?
此外,neo4j在以下代码段中给出输出;
0 => array(
'Stop' => '1',
'StopID' => '163',
'StopName' => 'KALIHI-PALAMA BUS FACILITY',
'RouteID' => (int) **132**,
'RouteName' => 'Kalihi via School Street Express',
'RouteShortName' => 'W3',
'Relationship' => array(
'RouteID' => (int) 79,
'RouteType' => 'ROUTE',
'EndNode' => '1'
)
),
(int) 1 => array(
'Stop' => '0',
'StopID' => '4523',
'StopName' => 'KALIHI TRANSIT CENTER',
'RouteID' => (int) 1,
'RouteName' => 'Kaimuki-Kalihi',
'RouteShortName' => '**132**',
'Relationship' => array(
'RouteID' => (int) 1,
'RouteType' => 'ROUTE',
'EndNode' => '54'
)
),
(int) 2 => array(
'Stop' => '54',
'StopID' => '38',
'StopName' => 'S BERETANIA ST + OPP KALAKAUA AVE',
'RouteID' => (int) **2**,
'RouteName' => 'Waikiki-School-Middle',
'RouteShortName' => '2',
'Relationship' => array(
'RouteID' => (int) 2,
'RouteType' => 'ROUTE',
'EndNode' => '54'
)
),
(int) 3 => array(
'Stop' => '53',
'StopID' => '37',
'StopName' => 'KALAKAUA AVE + S KING ST',
'RouteID' => (int) **132**,
'RouteName' => 'Waikiki-School-Middle Limited',
'RouteShortName' => '2L',
'Relationship' => array(
'RouteID' => (int) 132,
'RouteType' => 'ROUTE',
'EndNode' => '53'
)
) ...
给RouteID = 2 Bus是没有意义的。因为,当你下车时,你可以再次上同车。这不是很聪明。我怎么能防止这种情况?
我通常使用以下细分中的代码;
START n=node(5), m=node(45)
MATCH p=shortestPath(n-[r:ROUTE*..100]-m)
RETURN p
谢谢,最诚挚的问候