在图上我们最常做的事情就是统计图中有多少个某物。在下一节中我们会学用另一种方法来统计成组的实体,但是我们先来看一些统计的例子:如何用count步骤来统计航线图里某类实体的个数。首先我们一起找一下图中代表机场的顶点有多少个。
A common need when working with graphs is to be able to count how "many of something" there
are in the graph. We will look in the next section at other ways to count groups of things but first of
all let’s look at some examples of using the count step to count how many of various things there
are in our air-routes graph. First of all lets find out how many vertices in the graph represent
airports.

 

现在,看一看有路径标签的边,我们一起找一下图中存储了多少条航线。outE步骤用于查看出边。我们也可用用out 步骤来代替它。查看入边和出边的方式是多种多样的,这些内容很快会在“开始遍历图”这节中出现的。

Now, looking at edges that have a route label, let’s find out how many flight routes are stored in the
graph. Note that the outE step looks at outgoing edges. In this case we could also have used the out
step instead. The various ways that you can look at outgoing and incoming edges is discussed in the
"Starting to walk the graph" section that is coming up soon.

 

您要以像下面一样缩短上面的查询,不过这样可能需要查看更多的边,因为我们一开始没有过滤掉所有不是机场的顶点。

You could shorten the above a little as follows but this would cause more edges to get looked at as
we do not first filter out all vertices that are not airports.

 

您可以这么做,不过通常我们认边查看图中所有的边是一个糟糕的方法,因为属性图中通常边的数量大于顶点的数量。

You could also do it this way but generally starting by looking at all the Edges in the graph is
considered bad form as property graphs tend to have a lot more edges than vertices.
 

 

我们还没来得及看outE步骤的用法。在“开始遍历图”一节中,我们很快就会学习到这些知识的。

We have not yet looked at the outE step used above. We will look at it very soon however in the
"Starting to walk the graph" section.
posted on 2022-04-05 15:05  bokeyuannicheng0000  阅读(76)  评论(0)    收藏  举报