GraphGists

国际航班数据库

引言

作为引言,我使用了全球国际航班的开源数据。这些数据非常庞大且复杂,但在我查看数据及其图模型时受到了启发。尽管我进行了很多修改以使其达到当前形式,现在它已完全焕然一新并处于可工作状态。图谱显示,近年来所有国家和城市之间的航班相互连接,另一方面,全球的航空公司和航班数量有所增加。理解航空公司和航班之间差异的方法是查看不同国家的人们如何前往不同的国家和城市进行工作、会议等。

通过使用可用数据,我创建了如下所述的图模型。每个航班和机场都由一个节点表示。节点上的标签显示了相关信息。此示例仅包含航空公司所在国家和城市之间的航班,因此我可以看到许多连接。

本练习的目的是学习如何使用图数据库 Neo4j 以及一些技术工具和概念,使用 Neo4j 国家和城市以及航空公司和航班数据。这些是旅行中我需要解决的具体问题。

ydftT5g

设置

检索所有国家。

MATCH (country:Country) return country.countryName ORDER BY country.countryName

检索所有城市。

MATCH (city:City) return city.cityName ORDER BY city.cityName

检索所有机场。

MATCH (airport:Airport) return airport.airportName ORDER BY airport.airportName

检索所有航空公司。

MATCH (airline:Airline) return airline.airlineName ORDER BY airline.airlineName

最繁忙的 2 个机场。

MATCH (airport:Airport)<-[r]-(f:Flight)  WITH airport, count(r) AS flight_count order by flight_count desc  return  airport.airportName  , flight_count limit 2

最繁忙的 2 个城市(航班最多)。

MATCH (city1:City)<-[:IS_IN]- (airport1:Airport)<-[r]-(flight1:Flight) WITH city1, count(DISTINCT flight1) as flight_count order by flight_count desc return city1.cityName,flight_count limit 2

航班最多的 2 家航空公司。

MATCH (airline:Airline)<-[r]-(f:Flight)  WITH airline, count(r) AS flight_count order by flight_count desc  return airline.airlineName, flight_count limit 2

机场最多的 2 个城市。

MATCH (city:City)<-[r]-(airport:Airport)  WITH city, count(r) AS airport_count order by airport_count desc  return city.cityName, airport_count limit 2

航空公司最多的 2 个国家。

MATCH (country:Country )<-[:BELONGS_TO]-(airline:Airline)  WITH country,count(DISTINCT airline) as airline_count order by airline_count desc  return  country.countryName,airline_count limit 2

结论

结论:本练习为我们提供了从 A 点到 B 点的最佳路径,并告知是否存在替代方案、捷径、长路线以及中途的多个停靠点,这有助于根据个人或旅行者的需求安排行程,满足其旅行需求,同时还告知哪种方式最快或最长。此解决方案帮助人们能够按其意愿行事。

© . All rights reserved.