图模型的约束 [英] Constraints for graph models

查看:110
本文介绍了图模型的约束的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有四个可能的链,它们可以由6个不同的链节形成:

I have four possible chains that can be formed with 6 different chain links:

 G0 -> G1 -> G2
 E0 -> E1 -> E2
 G0 -> E1 -> G2
 E0 -> G1 -> G2

现在,我想使用一个图形模型来表达这四个链,如下图所示:

Now I want to express this four chains using a graph model which would look like the following picture:

如果我使用图查询语言询问例如给我所有具有G0作为第一个顶点而E2作为最后一个顶点的路径,则我会得到一条路径G0-> E1-> E2,它不是有效的路径或链出四个...

If I use a graph query language to ask eg give me all paths having G0 as first vertex and E2 as last vertex, I would get a path G0 -> E1 -> E2 which is not a valid path or chain out of the four...

所以我的问题是是否有可能表达这样的约束,使得我只收到有效"路径?

So my question is is there a possibility to express such constraints such that I only receive "valid" paths?

推荐答案

我不明白为什么您说路径G0 -> E1 -> E2无效.根据您的定义,它应该是唯一有效的路径.该查询应返回期望的结果:

I don't understand why you say that the path G0 -> E1 -> E2 is not valid. By your definition, it should be the only valid path. This query should return the desired result:

g.V(G0).               /* G0 as first vertex */
  repeat(out()).
    until(__.is(E2)).  /* E2 as last vertex  */
  path()               /* all paths          */

这篇关于图模型的约束的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆