我们看到了很多的例子,它们表明了顶点和边都有唯一的ID。然而不是特别明显的是,属性也有ID。与顶点和边的ID不同,属性的ID在整个图中不能保证是唯一的。当然在廷克图中,我们遇到了一些情况,顶点和属性共享同一个ID。这实际上不是一个问题,因为它们被用在了访问与它们相关的图元素的不同的方法中。下面的查询返回了图包含值London中任一属性的顶点属性对象(vp)
We have seen many examples already that show how both vertices and edges have a unique ID.
What may not have been obvious however is that properties also have an ID. Unlike vertex and
edge IDs property IDs are not guaranteed to be unique across the graph. Certainly with
TinkerGraph I have encountered cases where a vertex and a property share the same ID. This is not
really an issue because they are used in different ways to access their associated graph element.
The query below returns the vertex property object (vp) for any property in the graph that has a
value of London.
 

 

这个查询找到了一些London值。

The query finds several London values.
 

 

乍一看,上面返回的每个值都是一样的。然而让我们再来查看一下它们各自的ID值。

At first glance, each of the values returned above looks identical. However, let’s now query their ID
values.
 

 

如您所见每个属性都有不同的、唯一的ID。

As you can see each property has a different, and unique, ID.
 

 

就像在前边的一些例子中使用顶点和属性那样,以同样的方式我们在其它的查询中使用这些ID值。

We can use these ID values in other queries in the same way as we have for vertices and edges in
some of our earlier examples.
 

 

如您所料,我们可以查询这些属性的值。

We can query the value of this property as you would expect.
 

 

像下面这样,我们可以获取属性键的名称

We can retrieve the name of the property key as follows.
 

 

我们也可以使用标签而不是键。

We could also have used label instead of key
 

 

我们也可以找出来这个属性归属的是哪个元素(顶点或边)

We can also find out which element (vertex or edge) that this property belongs to.

 我们也可以找到属性ID是583的元素的其它的属性的值。
We can also look at other property values of the element containing our property with an ID of 583.
 

 

只要您需要,您就可以找到这个属性是图的哪个部分。在这个例子中,它是廷克图的一部分。

Should you need to you can also find out which graph this property is part of. In this case it is part
of a TinkerGraph.
 

 

为了进一步的展示每个属性有一个ID,下面的代码是获取与顶点V(3)相关的所有顶点属性的列表,打印输出属性的键和它的ID。

To further show that each property has an ID the following code retrieves a list of all the vertex
properties associated with vertex V(3) and prints out the property key along with its corresponding
ID.
 

 

如果您更新一个属性,它的ID值也会改变,因为本质上是用一个新的属性,它有新的ID,代替了原来的属性。

If you update a property, its ID value will also be changed as you have in reality
replaced the property with a new one which is allocated a new ID.
看下面这个例子,首先找到的顶点4的city属性的ID,接着我们改变它的值,重新命名,然后再查询属性的ID。注意ID已经改变了。就像上面提到的一样,顶点的属性是不可以改变的。当您使用property步骤更新一个属性的ID,一个新的属性对象会创建,并替代了前一个。
Take a look at the example below. First of all we query the ID of the city property from vertex V(4).
Next we change its value to be newname and then query the property ID again. Note that the ID has
changed. As mentioned above, vertex properties are immutable. When you update a property value
using the property step, a new property object is created that replaces the prior one.
 

 

图中的每个属性都有一个ID,这可以提高访问属性的性能,特别是在大型的图中。

The fact that every property in a graph has an ID can improve performance of accessing properties,
especially in large graphs.
posted on 2022-04-22 16:13  bokeyuannicheng0000  阅读(36)  评论(0)    收藏  举报