JanusGraph中文翻译文档
图模式与建模

      每个JanusGraph图都有一个由边标签、属性键或顶点标签组成的图模式。 可以显式或隐式定义JanusGraph图模式。 鼓励用户在应用程序开发期间明确定义图模式。 明确定义的图模式是健壮的图形应用程序的重要组成部分,并极大地改进了协作软件开发。 请注意,JanusGraph图模式可以不断的调整,而不需要中断正常的数据库操作。 修改图模式不会减慢查询应答速度,也不需要数据库停机。

       模式类型(即边标签、属性键或顶点标签)在首次创建时分配给图中的元素(即边,属性或顶点 )。 元素的模式类型一旦创建不能修改。 这确保模式类型的稳定性。

      除了本节中介绍的模式定义选项之外,模式类型还提供了第30章高级模式中讨论的性能调优选项。

5.1. 定义边标签

     连接两个顶点的每条边都有一个标签,用于定义关系的语义。 例如,在顶点A和B之间的标签表示两个人之间的朋友关系。

     要定义边标签,请在打开的图或管理事务上调用makeEdgeLabel(String),并提供边标签的名称作为参数。 边标签名称在图表中必须是唯一的。 此方法返回边标签的构建器,允许定义其多重性。 边标签的多重性在该标签的所有边上定义了多重性约束,即,顶点对之间的最大边数。 JanusGraph有以下几种多重性设置。

5.1.1. 边标签的多重性

Multiplicity设置

  • MULTI: Allows multiple edges of the same label between any pair of vertices. In other words, the graph is a multi graph with respect to such edge label. There is no constraint on edge multiplicity.
  • SIMPLE: Allows at most one edge of such label between any pair of vertices. In other words, the graph is a simple graph with respect to the label. Ensures that edges are unique for a given label and pairs of vertices.
  • MANY2ONE: Allows at most one outgoing edge of such label on any vertex in the graph but places no constraint on incoming edges. The edge label mother is an example with MANY2ONE multiplicity since each person has at most one mother but mothers can have multiple children.
  • ONE2MANY: Allows at most one incoming edge of such label on any vertex in the graph but places no constraint on outgoing edges. The edge label winnerOf is an example with ONE2MANY multiplicity since each contest is won by at most one person but a person can win multiple contests.
  • ONE2ONE: Allows at most one incoming and one outgoing edge of such label on any vertex in the graph. The edge label marriedTo is an example with ONE2ONE multiplicity since a person is married to exactly one other person.


标签: edge、标签、多重性、multiplicity、graph
一个创业中的苦逼程序员
  • 回复
隐藏