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. 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.
gremlin> a = graph.addVertex("name", "a") ==>v[4152] gremlin> b = graph.addVertex("name", "b") ==>v[8248] gremlin> c = graph.addVertex("name", "c") ==>v[4128] gremlin> d = graph.addVertex("name", "d") ==>v[4328]
先分别创建 multiplicity 为 SIMPLE 和 ONE2ONE 的 Edge Label,然后创建 a b c d 四个点。
首先来验证 SIMPLE:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
gremlin> a.addEdge("simple", b) ==>e[1zb-37c-t1-6d4][4152-simple->8248] gremlin> a.addEdge("simple", b) An edge with the given label already exists between the pair of vertices and the label [simple] is simple Display stack trace? [yN] n gremlin> b.addEdge("simple", a) ==>e[2dj-6d4-t1-37c][8248-simple->4152] gremlin> a.addEdge("simple", c) ==>e[2rr-37c-t1-36o][4152-simple->4128] gremlin> a.addEdge("simple", d) ==>e[35z-37c-t1-3c8][4152-simple->4328] gremlin> a.addEdge("simple", c) An edge with the given label already exists between the pair of vertices and the label [simple] is simple Display stack trace? [yN] n gremlin> c.addEdge("simple", b) ==>e[16s-36o-t1-6d4][4128-simple->8248]
得到的结论是,只要两点之间不存在相同方向的 SIMPLE 边就可以。
然后验证 ONE2ONE
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
gremlin> a.addEdge("one2one", b) ==>e[3k7-37c-1lh-6d4][4152-one2one->8248] gremlin> a.addEdge("one2one", c) An edge with the given label already exists on the out-vertex and the label [one2one] is out-unique Display stack trace? [yN] n gremlin> a.addEdge("one2one", d) An edge with the given label already exists on the out-vertex and the label [one2one] is out-unique Display stack trace? [yN] n gremlin> d.addEdge("one2one", a) ==>e[17h-3c8-1lh-37c][4328-one2one->4152] gremlin> d.addEdge("one2one", b) An edge with the given label already exists on the out-vertex and the label [one2one] is out-unique Display stack trace? [yN] n gremlin> b.addEdge("one2one", c) ==>e[3yf-6d4-1lh-36o][8248-one2one->4128]