为了快速开始,让我们看更多基础的例子:只是统计出现的次数和东西的分布,但是比本书最开始的例子复杂一点点。
To get things started, let’s look at a few more examples that basically just count occurrences and
distributions of things but are a little more complex than the examples we looked at earlier in the
book.
5.1.1. 哪些国家没有机场 Which countries have no airports?
第一条查询是找出哪个国家顶占没有出边。这就是说在图中那些没有机场的国家。
This first query looks for any country vertices that have no outgoing edges. This indicates that there
are no airports in the graph for those countries.

所以看起来有6个国定没有机场。
So it seems there are six countries for which no airports were found.

前边的查询是下面两个查询的简短的形式,它们都得到了同样的结果。注意在第二个查询中not步骤前用到的下划线前缀。这是因为not是Groovy中的保留字。可没有直接与前一步骤用点号连接时,可以使用这样的前缀。
The previous query is a slightly shorter form of the two queries below which would both yield the
same results. Note the use of the "__" prefix in front of the not step in the second query. This is
because not is a reserved word in Groovy and has to be prefixed in this way when not directly
connected to a prior step by a dot.

5.1.2哪个机场没有路径 Which airports have no routes?
在图中有一些机场现在没有商用的航线。这或者是因为它们过去提供过服务,已经不再服务了,或者是因为它们是新的机场还待开始提供服务。我们写了一个查询很容易找到这些孤立的机场。注意在这个查询是基于0.77版的航线图air-routes.graphml。
There are a few airports in the graph that currently have no commercial routes. This is either
because they used to have service and it was discontinued or they are new airports still awaiting
service to start. We can write a query to easily find these "orphan" airports. Note that this is query
based on the version 0.77 release of air-routes.graphml.
您总可以找到本书中所用到的航线图的版本,绝大数最新的数据集在样例代码文件中,位置是https://github.com/krlawrence/graph/tree/master/sample-data . 在最近更新的数据集中,有一些机场现在已经有了商用的航线服务。
You can always find the version of the air-routes.graphml file used for the
examples in the book and also the most recent data set in the sample-data folder
located at https://github.com/krlawrence/graph/tree/master/sample-data .
In more recent updates of the data set, some of these airports do now have commercial airline
service.

当我们运行这个查询,您可以看到找到了一些孤立的机场顶点,它们没有出边或者没有入边。
When we run the query, you can see we find quite a few orphan airport nodes that have no
outgoing or incoming routes。

5.1.3跑道的分布是什么?What is the distribution of runways?
我们很容易统计出每个机场跑道的分布情况。我们可以从运行查询的结果观察到:图中大多数的机场有或一个或两条跑道。
We can easily count the distribution per airport of runways. We can observe from the results of
running the query that the vast majority of airports in the graph have either one or two runways.
