自我网重量计算的性能问题

时间:2018-01-16 02:50:21

标签: graph gremlin tinkerpop3 janusgraph

我们在下面有下面的图表数据。只有5个顶点,但我们有很多边。我如何处理以下Querys?我想从一个节点到另一个节点的路径。我只是想得到循环路径并计算自我权重的总和。循环将从一个到另一个,一个到它自己。我想过滤重量计算的总和。

suresh       = graph.addVertex(label,'person','uuid','7bff1bc0-cef1-1033-8f28-d99da6cfd8a9')
robin_niu    = graph.addVertex(label,'person','uuid','e3348740-d37f-1031-8b5b-89fbb6fdad64')
hujunjie     = graph.addVertex(label,'person','uuid','5e5139c0-dbe7-102e-8780-bedba724cbf7')
clintpollitt = graph.addVertex(label,'person','uuid','d92c6340-f98b-1035-85d7-bee5d5cc5ebe')
yanjuqi      = graph.addVertex(label,'person','uuid','2d9fba40-74c7-1033-8e84-d3a6c90ad2e9')

suresh.addEdge('Communication',robin_niu,'date','2017-11-01T00:00:00Z','weight',1)
suresh.addEdge('Communication',robin_niu,'date','2017-11-02T00:00:00Z','weight',1)
suresh.addEdge('Communication',robin_niu,'date','2017-11-03T00:00:00Z','weight',1)
suresh.addEdge('Communication',robin_niu,'date','2017-11-04T00:00:00Z','weight',1)
suresh.addEdge('Communication',robin_niu,'date','2017-11-05T00:00:00Z','weight',1)
suresh.addEdge('Communication',hujunjie,'date','2017-12-01T00:00:00Z','weight',1)
suresh.addEdge('Communication',hujunjie,'date','2017-12-02T00:00:00Z','weight',1)
suresh.addEdge('Communication',hujunjie,'date','2017-12-03T00:00:00Z','weight',1)
suresh.addEdge('Communication',hujunjie,'date','2017-12-04T00:00:00Z','weight',1)
suresh.addEdge('Communication',hujunjie,'date','2017-12-05T00:00:00Z','weight',1)
suresh.addEdge('Communication',yanjuqi,'date','2017-10-01T00:00:00Z','weight',1)
suresh.addEdge('Communication',yanjuqi,'date','2017-10-02T00:00:00Z','weight',1)
suresh.addEdge('Communication',yanjuqi,'date','2017-10-03T00:00:00Z','weight',1)
suresh.addEdge('Communication',yanjuqi,'date','2017-10-04T00:00:00Z','weight',1)
suresh.addEdge('Communication',yanjuqi,'date','2017-10-05T00:00:00Z','weight',1)
suresh.addEdge('Communication',yanjuqi,'date','2017-01-01T00:00:00Z','weight',1)
suresh.addEdge('Communication',yanjuqi,'date','2017-01-02T00:00:00Z','weight',1)
suresh.addEdge('Communication',yanjuqi,'date','2017-01-03T00:00:00Z','weight',1)
suresh.addEdge('Communication',yanjuqi,'date','2017-01-04T00:00:00Z','weight',1)
suresh.addEdge('Communication',yanjuqi,'date','2017-01-05T00:00:00Z','weight',1)
suresh.addEdge('Communication',yanjuqi,'date','2017-11-01T00:00:00Z','weight',1)
suresh.addEdge('Communication',yanjuqi,'date','2017-11-02T00:00:00Z','weight',1)
suresh.addEdge('Communication',yanjuqi,'date','2017-11-03T00:00:00Z','weight',1)
suresh.addEdge('Communication',yanjuqi,'date','2017-11-04T00:00:00Z','weight',1)
suresh.addEdge('Communication',yanjuqi,'date','2017-11-05T00:00:00Z','weight',1)
suresh.addEdge('Communication',yanjuqi,'date','2017-12-01T00:00:00Z','weight',1)
suresh.addEdge('Communication',yanjuqi,'date','2017-12-02T00:00:00Z','weight',1)
suresh.addEdge('Communication',yanjuqi,'date','2017-12-03T00:00:00Z','weight',1)
suresh.addEdge('Communication',yanjuqi,'date','2017-12-04T00:00:00Z','weight',1)
suresh.addEdge('Communication',yanjuqi,'date','2017-12-05T00:00:00Z','weight',1)
suresh.addEdge('Communication',yanjuqi,'date','2017-12-05T00:00:00Z','weight',1)
suresh.addEdge('ProfilesReportingToChain',clintpollitt,'date','2016-12-01T00:00:00Z','weight',5)
suresh.addEdge('Communication',clintpollitt,'date','2017-11-01T00:00:00Z','weight',1)
suresh.addEdge('Communication',clintpollitt,'date','2017-11-01T00:00:00Z','weight',1)
suresh.addEdge('Communication',clintpollitt,'date','2017-11-01T00:00:00Z','weight',1)
suresh.addEdge('Communication',clintpollitt,'date','2017-11-01T00:00:00Z','weight',1)
suresh.addEdge('Communication',clintpollitt,'date','2017-11-01T00:00:00Z','weight',1)
suresh.addEdge('Communication',clintpollitt,'date','2017-11-01T00:00:00Z','weight',1)
suresh.addEdge('Communication',clintpollitt,'date','2017-11-01T00:00:00Z','weight',1)
suresh.addEdge('Communication',clintpollitt,'date','2017-11-01T00:00:00Z','weight',1)
suresh.addEdge('Communication',clintpollitt,'date','2017-11-01T00:00:00Z','weight',1)
suresh.addEdge('Communication',clintpollitt,'date','2017-11-01T00:00:00Z','weight',1)
suresh.addEdge('Communication',clintpollitt,'date','2017-11-01T00:00:00Z','weight',1)
suresh.addEdge('Communication',clintpollitt,'date','2017-11-01T00:00:00Z','weight',1)
suresh.addEdge('Communication',clintpollitt,'date','2017-11-01T00:00:00Z','weight',1)
suresh.addEdge('Communication',clintpollitt,'date','2017-11-02T00:00:00Z','weight',1)
suresh.addEdge('Communication',clintpollitt,'date','2017-11-02T00:00:00Z','weight',1)
suresh.addEdge('Communication',clintpollitt,'date','2017-11-02T00:00:00Z','weight',1)
suresh.addEdge('Communication',clintpollitt,'date','2017-11-02T00:00:00Z','weight',1)
suresh.addEdge('Communication',clintpollitt,'date','2017-11-02T00:00:00Z','weight',1)
suresh.addEdge('Communication',clintpollitt,'date','2017-11-02T00:00:00Z','weight',1)
suresh.addEdge('Communication',clintpollitt,'date','2017-11-02T00:00:00Z','weight',1)
suresh.addEdge('Communication',clintpollitt,'date','2017-11-02T00:00:00Z','weight',1)
suresh.addEdge('Communication',clintpollitt,'date','2017-11-02T00:00:00Z','weight',1)
suresh.addEdge('Communication',clintpollitt,'date','2017-11-02T00:00:00Z','weight',1)
suresh.addEdge('Communication',clintpollitt,'date','2017-11-02T00:00:00Z','weight',1)
suresh.addEdge('Communication',clintpollitt,'date','2017-11-02T00:00:00Z','weight',1)
suresh.addEdge('Communication',clintpollitt,'date','2017-11-02T00:00:00Z','weight',1)
suresh.addEdge('Communication',clintpollitt,'date','2017-11-02T00:00:00Z','weight',1)
suresh.addEdge('Communication',clintpollitt,'date','2017-11-02T00:00:00Z','weight',1)
suresh.addEdge('Communication',clintpollitt,'date','2017-11-02T00:00:00Z','weight',1)
suresh.addEdge('Communication',clintpollitt,'date','2017-11-02T00:00:00Z','weight',1)
suresh.addEdge('Communication',clintpollitt,'date','2017-11-02T00:00:00Z','weight',1)
suresh.addEdge('Communication',clintpollitt,'date','2017-11-02T00:00:00Z','weight',1)
suresh.addEdge('Communication',clintpollitt,'date','2017-11-02T00:00:00Z','weight',1)
suresh.addEdge('Communication',clintpollitt,'date','2017-11-02T00:00:00Z','weight',1)
suresh.addEdge('Communication',clintpollitt,'date','2017-11-02T00:00:00Z','weight',1)
suresh.addEdge('Communication',clintpollitt,'date','2017-11-02T00:00:00Z','weight',1)
suresh.addEdge('Communication',clintpollitt,'date','2017-11-02T00:00:00Z','weight',1)
suresh.addEdge('Communication',clintpollitt,'date','2017-11-11T00:00:00Z','weight',1)
suresh.addEdge('Communication',clintpollitt,'date','2017-11-11T00:00:00Z','weight',1)
suresh.addEdge('Communication',clintpollitt,'date','2017-11-11T00:00:00Z','weight',1)
suresh.addEdge('Communication',clintpollitt,'date','2017-11-11T00:00:00Z','weight',1)
suresh.addEdge('Communication',clintpollitt,'date','2017-11-11T00:00:00Z','weight',1)
suresh.addEdge('Communication',clintpollitt,'date','2017-11-11T00:00:00Z','weight',1)
suresh.addEdge('Communication',clintpollitt,'date','2017-11-11T00:00:00Z','weight',1)
suresh.addEdge('Communication',clintpollitt,'date','2017-11-11T00:00:00Z','weight',1)
suresh.addEdge('Communication',clintpollitt,'date','2017-11-11T00:00:00Z','weight',1)
suresh.addEdge('Communication',clintpollitt,'date','2017-11-11T00:00:00Z','weight',1)
suresh.addEdge('Communication',clintpollitt,'date','2017-11-11T00:00:00Z','weight',1)
suresh.addEdge('Communication',clintpollitt,'date','2017-11-11T00:00:00Z','weight',1)
suresh.addEdge('Communication',clintpollitt,'date','2017-11-11T00:00:00Z','weight',1)
suresh.addEdge('Communication',clintpollitt,'date','2017-11-11T00:00:00Z','weight',1)
suresh.addEdge('Communication',clintpollitt,'date','2017-11-11T00:00:00Z','weight',1)
suresh.addEdge('Communication',clintpollitt,'date','2017-11-11T00:00:00Z','weight',1)
suresh.addEdge('Communication',clintpollitt,'date','2017-11-11T00:00:00Z','weight',1)
suresh.addEdge('Communication',clintpollitt,'date','2017-11-11T00:00:00Z','weight',1)
suresh.addEdge('Communication',clintpollitt,'date','2017-11-11T00:00:00Z','weight',1)
suresh.addEdge('Communication',clintpollitt,'date','2017-11-11T00:00:00Z','weight',1)
suresh.addEdge('Communication',clintpollitt,'date','2017-11-11T00:00:00Z','weight',1)
suresh.addEdge('Communication',clintpollitt,'date','2017-11-11T00:00:00Z','weight',1)
suresh.addEdge('Communication',clintpollitt,'date','2017-11-11T00:00:00Z','weight',1)

clintpollitt.addEdge('Communication',robin_niu,'date','2017-12-01T00:00:00Z','weight',1)
clintpollitt.addEdge('Communication',robin_niu,'date','2017-12-02T00:00:00Z','weight',1)
clintpollitt.addEdge('Communication',robin_niu,'date','2017-12-03T00:00:00Z','weight',1)
clintpollitt.addEdge('Communication',hujunjie,'date','2017-11-01T00:00:00Z','weight',1)
clintpollitt.addEdge('Communication',hujunjie,'date','2017-12-02T00:00:00Z','weight',1)
clintpollitt.addEdge('Communication',hujunjie,'date','2017-10-03T00:00:00Z','weight',1)
clintpollitt.addEdge('Communication',hujunjie,'date','2017-12-04T00:00:00Z','weight',1)
clintpollitt.addEdge('Communication',hujunjie,'date','2017-12-05T00:00:00Z','weight',1)
clintpollitt.addEdge('Communication',yanjuqi,'date','2017-10-01T00:00:00Z','weight',1)
clintpollitt.addEdge('Communication',yanjuqi,'date','2017-10-02T00:00:00Z','weight',1)
clintpollitt.addEdge('Communication',yanjuqi,'date','2017-10-03T00:00:00Z','weight',1)
clintpollitt.addEdge('Communication',yanjuqi,'date','2017-10-04T00:00:00Z','weight',1)
clintpollitt.addEdge('Communication',yanjuqi,'date','2017-10-05T00:00:00Z','weight',1)
clintpollitt.addEdge('Communication',yanjuqi,'date','2017-01-01T00:00:00Z','weight',1)
clintpollitt.addEdge('Communication',yanjuqi,'date','2017-01-02T00:00:00Z','weight',1)
clintpollitt.addEdge('Communication',yanjuqi,'date','2017-01-03T00:00:00Z','weight',1)
clintpollitt.addEdge('Communication',yanjuqi,'date','2017-01-04T00:00:00Z','weight',1)
clintpollitt.addEdge('Communication',yanjuqi,'date','2017-01-05T00:00:00Z','weight',1)
clintpollitt.addEdge('Communication',yanjuqi,'date','2017-11-01T00:00:00Z','weight',1)
clintpollitt.addEdge('Communication',yanjuqi,'date','2017-11-02T00:00:00Z','weight',1)
clintpollitt.addEdge('Communication',yanjuqi,'date','2017-11-03T00:00:00Z','weight',1)
clintpollitt.addEdge('Communication',yanjuqi,'date','2017-11-04T00:00:00Z','weight',1)
clintpollitt.addEdge('Communication',yanjuqi,'date','2017-11-05T00:00:00Z','weight',1)
clintpollitt.addEdge('Communication',suresh,'date','2017-11-01T00:00:00Z','weight',1)
clintpollitt.addEdge('Communication',suresh,'date','2017-11-01T00:00:00Z','weight',1)
clintpollitt.addEdge('Communication',suresh,'date','2017-11-01T00:00:00Z','weight',1)
clintpollitt.addEdge('Communication',suresh,'date','2017-11-01T00:00:00Z','weight',1)
clintpollitt.addEdge('Communication',suresh,'date','2017-11-01T00:00:00Z','weight',1)
clintpollitt.addEdge('Communication',suresh,'date','2017-11-02T00:00:00Z','weight',1)
clintpollitt.addEdge('Communication',suresh,'date','2017-11-02T00:00:00Z','weight',1)
clintpollitt.addEdge('Communication',suresh,'date','2017-11-02T00:00:00Z','weight',1)
clintpollitt.addEdge('Communication',suresh,'date','2017-11-02T00:00:00Z','weight',1)
clintpollitt.addEdge('Communication',suresh,'date','2017-11-02T00:00:00Z','weight',1)
clintpollitt.addEdge('Communication',suresh,'date','2017-11-02T00:00:00Z','weight',1)
clintpollitt.addEdge('Communication',suresh,'date','2017-11-02T00:00:00Z','weight',1)
clintpollitt.addEdge('Communication',suresh,'date','2017-11-02T00:00:00Z','weight',1)
clintpollitt.addEdge('Communication',suresh,'date','2017-11-02T00:00:00Z','weight',1)
clintpollitt.addEdge('Communication',suresh,'date','2017-11-02T00:00:00Z','weight',1)
clintpollitt.addEdge('Communication',suresh,'date','2017-11-02T00:00:00Z','weight',1)
clintpollitt.addEdge('Communication',suresh,'date','2017-11-02T00:00:00Z','weight',1)
clintpollitt.addEdge('Communication',suresh,'date','2017-11-11T00:00:00Z','weight',1)
clintpollitt.addEdge('Communication',suresh,'date','2017-11-11T00:00:00Z','weight',1)
clintpollitt.addEdge('Communication',suresh,'date','2017-11-11T00:00:00Z','weight',1)

yanjuqi.addEdge('Communication',robin_niu,'date','2017-12-11T00:00:00Z','weight',1)
yanjuqi.addEdge('Communication',robin_niu,'date','2017-12-12T00:00:00Z','weight',1)
yanjuqi.addEdge('Communication',robin_niu,'date','2017-12-13T00:00:00Z','weight',1)
yanjuqi.addEdge('Communication',hujunjie,'date','2017-11-11T00:00:00Z','weight',1)
yanjuqi.addEdge('Communication',hujunjie,'date','2017-12-12T00:00:00Z','weight',1)
yanjuqi.addEdge('Communication',hujunjie,'date','2017-10-13T00:00:00Z','weight',1)
yanjuqi.addEdge('Communication',hujunjie,'date','2017-12-14T00:00:00Z','weight',1)
yanjuqi.addEdge('Communication',hujunjie,'date','2017-12-15T00:00:00Z','weight',1)
yanjuqi.addEdge('Communication',clintpollitt,'date','2017-10-01T00:00:00Z','weight',1)
yanjuqi.addEdge('Communication',clintpollitt,'date','2017-10-02T00:00:00Z','weight',1)
yanjuqi.addEdge('Communication',clintpollitt,'date','2017-10-03T00:00:00Z','weight',1)
yanjuqi.addEdge('Communication',clintpollitt,'date','2017-10-04T00:00:00Z','weight',1)
yanjuqi.addEdge('Communication',suresh,'date','2017-10-05T00:00:00Z','weight',1)
yanjuqi.addEdge('Communication',suresh,'date','2017-01-01T00:00:00Z','weight',1)

robin_niu.addEdge('Communication',hujunjie,'date','2017-12-11T00:00:00Z','weight',1)
robin_niu.addEdge('Communication',hujunjie,'date','2017-12-12T00:00:00Z','weight',1)
robin_niu.addEdge('Communication',hujunjie,'date','2017-12-13T00:00:00Z','weight',1)
robin_niu.addEdge('Communication',hujunjie,'date','2017-11-11T00:00:00Z','weight',1)
robin_niu.addEdge('Communication',hujunjie,'date','2017-12-12T00:00:00Z','weight',1)
robin_niu.addEdge('Communication',hujunjie,'date','2017-10-13T00:00:00Z','weight',1)
robin_niu.addEdge('Communication',yanjuqi,'date','2017-12-14T00:00:00Z','weight',1)
robin_niu.addEdge('Communication',yanjuqi,'date','2017-12-15T00:00:00Z','weight',1)
robin_niu.addEdge('Communication',clintpollitt,'date','2017-10-01T00:00:00Z','weight',1)
robin_niu.addEdge('Communication',suresh,'date','2017-11-01T00:00:00Z','weight',1)
robin_niu.addEdge('Communication',suresh,'date','2017-01-01T00:00:00Z','weight',1)
robin_niu.addEdge('ProfilesReportingToChain',yanjuqi,'date','2017-10-02T00:00:00Z','weight',5)
robin_niu.addEdge('ProfilesColleague',hujunjie,'date','2017-10-03T00:00:00Z','weight',2)

hujunjie.addEdge('Communication',robin_niu,'date','2017-12-11T00:00:00Z','weight',1)
hujunjie.addEdge('Communication',robin_niu,'date','2017-12-12T00:00:00Z','weight',1)
hujunjie.addEdge('Communication',clintpollitt,'date','2017-12-13T00:00:00Z','weight',1)
hujunjie.addEdge('Communication',clintpollitt,'date','2017-11-11T00:00:00Z','weight',1)
hujunjie.addEdge('Communication',clintpollitt,'date','2017-12-12T00:00:00Z','weight',1)
hujunjie.addEdge('Communication',suresh,'date','2017-10-13T00:00:00Z','weight',1)
hujunjie.addEdge('Communication',suresh,'date','2017-11-01T00:00:00Z','weight',1)
hujunjie.addEdge('Communication',suresh,'date','2017-01-01T00:00:00Z','weight',1)
hujunjie.addEdge('Communication',yanjuqi,'date','2017-12-14T00:00:00Z','weight',1)
hujunjie.addEdge('Communication',yanjuqi,'date','2017-12-15T00:00:00Z','weight',1)
hujunjie.addEdge('Communication',yanjuqi,'date','2017-10-01T00:00:00Z','weight',1)
hujunjie.addEdge('ProfilesReportingToChain',yanjuqi,'date','2016-10-02T00:00:00Z','weight',5)
hujunjie.addEdge('ProfilesColleague',robin_niu,'date','2017-10-03T00:00:00Z','weight',2)

以下查询无法正常工作。我该如何解决这个问题?

g.V().has('uuid','e3348740-d37f-1031-8b5b-89fbb6fdad64').as('v').
  repeat(outE().as('e').inV().as('v')).
    until(has('uuid','2d9fba40-74c7-1033-8e84-d3a6c90ad2e9')).
  store('a').
    by('uuid').
  store('a').
    by(select(all, 'v').unfold().values('uuid').fold()).
  store('a').
    by(select(all, 'e').unfold().
       store('x').
         by(union(values('weight'),
                  select('x').count(local)).fold()).
       cap('x').
       store('a').
         by(unfold().limit(local, 1).fold()).unfold().
       sack(assign).
         by(constant(1d)).
       sack(div).
         by(union(constant(1d),
                  tail(local, 1)).sum()).
       sack(mult).
         by(limit(local, 1)).
       sack().sum()).
  cap('a')

1 个答案:

答案 0 :(得分:2)

此查询将永远运行,因为您的图表包含循环路径,您的查询不会考虑这些路径。我假设你只关心最短的路径(否则填写FormGroup集合IMO没有多大意义)。一个简单的更改将修复您的查询:

a