To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/320cf50b-c33e-45da-be73-9d46b3fa586b%40googlegroups.com.
Hi, Daniel!
I`m trying to use this query in my project
g.V().repeat(__.outE("tsw").has("speed", P.within(speeds)).as("e").inV().simplePath()).emit(__.loops().is(P.lt(21)))
.map(__.union(__.select("e").unfold().values("speed").dedup().fold(), __.path()).fold())
.filter(__.limit(Scope.local, 1).count(Scope.local).is(1));in groovy this code working fine, but in java I get error:
Error:(45, 56) java: method union in class org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__ cannot be applied to given types; required: org.apache.tinkerpop.gremlin.process.traversal.Traversal<?,B>[] found: org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal<java.lang.Object,java.util.List<java.lang.Object>>,org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal<java.lang.Object,org.apache.tinkerpop.gremlin.process.traversal.Path> reason: inferred type does not conform to equality constraint(s) inferred: org.apache.tinkerpop.gremlin.process.traversal.Path equality constraints(s): org.apache.tinkerpop.gremlin.process.traversal.Path,java.util.List<java.lang.Object>
How to avoid this error?
One of solution is use __.path().unfold() in union:
.map(__.union(__.select("e").unfold().values("speed").dedup().fold(), __.path().unfold()).fold())May be there is best solution?Regards, Sergei.
One of solution is use __.path().unfold() in union
.map(__.union((Traversal) __.select("e").unfold().values("speed").dedup().fold(),(Traversal) __.path()).fold())
--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/2ad69d56-4456-4eeb-a5ce-c0a5485b83fa%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-user...@googlegroups.com.
//When i try use TinkerGraph - all is ok
gremlin> graph = TinkerGraph.open()
==>tinkergraph[vertices:0 edges:0]
gremlin> graph.io(IoCore.gryo()).readGraph('/mnt/data/graph/59f79cd3-0e27-498f-a15f-5d4b62dab387_graph.kryo')
==>null
gremlin> g = graph.traversal()
==>graphtraversalsource[tinkergraph[vertices:4 edges:28], standard]
gremlin> g.V().repeat(__.outE("tsw").as("e").inV().simplePath()).emit(__.loops().is(P.lt(21))).map(__.union((Traversal) __.select("e").unfold().values("speed").dedup().fold(), (Traversal) __.path()).fold())
==>[[1],[v[0],e[0][0-tsw->1],v[1]]]
==>[[1],[v[0],e[0][0-tsw->1],v[1],e[14][1-tsw->3],v[3]]]
==>[[1],[v[1],e[14][1-tsw->3],v[3]]]
==>[[2],[v[2],e[21][2-tsw->0],v[0]]]
==>[[1],[v[2],e[7][2-tsw->0],v[0]]]
==>[[2,1],[v[2],e[21][2-tsw->0],v[0],e[0][0-tsw->1],v[1]]]
==>[[1],[v[2],e[7][2-tsw->0],v[0],e[0][0-tsw->1],v[1]]]
==>[[2,1],[v[2],e[21][2-tsw->0],v[0],e[0][0-tsw->1],v[1],e[14][1-tsw->3],v[3]]]
==>[[1],[v[2],e[7][2-tsw->0],v[0],e[0][0-tsw->1],v[1],e[14][1-tsw->3],v[3]]]
//When i try use SparkGraphComputer - i get a problem
gremlin> graph = GraphFactory.open('conf/hadoop/hadoop-gryo.properties')
==>hadoopgraph[gryoinputformat->gryooutputformat]
gremlin> g = graph.traversal().withComputer(SparkGraphComputer)
==>graphtraversalsource[hadoopgraph[gryoinputformat->gryooutputformat], sparkgraphcomputer]
gremlin> g.V().count()
==>4
gremlin> g.V().repeat(__.outE("tsw").as("e").inV().simplePath()).emit(__.loops().is(P.lt(21))).map(__.union((Traversal) __.select("e").unfold().values("speed").dedup().fold(), (Traversal) __.path()).fold())
==>[[],[v[2],e[21][2-tsw->0],v[0]]]
==>[[],[v[2],e[7][2-tsw->0],v[0]]]
==>[[],[v[0],e[0][0-tsw->1],v[1]]]
==>[[],[v[1],e[14][1-tsw->3],v[3]]]
==>[[],[v[2],e[21][2-tsw->0],v[0],e[0][0-tsw->1],v[1]]]
==>[[],[v[2],e[7][2-tsw->0],v[0],e[0][0-tsw->1],v[1]]]
==>[[],[v[0],e[0][0-tsw->1],v[1],e[14][1-tsw->3],v[3]]]
==>[[],[v[2],e[21][2-tsw->0],v[0],e[0][0-tsw->1],v[1],e[14][1-tsw->3],v[3]]]
==>[[],[v[2],e[7][2-tsw->0],v[0],e[0][0-tsw->1],v[1],e[14][1-tsw->3],v[3]]]
g.V().sideEffect(outE("tsw").group("x").by().by("speed")).repeat(__.outE("tsw").as("e").inV().simplePath()).emit(__.loops().is(P.lt(21))).map(union((Traversal) __.select("e").unfold().as("edge").select("x").unfold().where(select(keys).as("edge")).select(values).unfold().dedup().fold(),(Traversal) __.path()).fold())
gremlin> graph = GraphFactory.open("conf/hadoop/hadoop-gryo.properties")==>hadoopgraph[gryoinputformat->gryooutputformat]gremlin> g = graph.traversal().withComputer(SparkGraphComputer)==>graphtraversalsource[hadoopgraph[gryoinputformat->gryooutputformat], sparkgraphcomputer]
// original traversal: values not available
gremlin> g.V().sideEffect(outE().group("x").by().by("weight")).repeat(bothE().as("e").otherV().simplePath()).emit(__.loops().is(lt(3))).map(union(select("e").unfold().select("weight").dedup().fold(), path()).fold())==>[[],[v[1],e[8][1-knows->4],v[4]]]==>[[],[v[3],e[11][4-created->3],v[4]]]==>[[],[v[5],e[10][4-created->5],v[4]]]==>[[],[v[2],e[7][1-knows->2],v[1]]]==>[[],[v[3],e[9][1-created->3],v[1]]]==>[[],[v[4],e[8][1-knows->4],v[1]]]==>[[],[v[3],e[12][6-created->3],v[6]]]==>[[],[v[1],e[9][1-created->3],v[3]]]==>[[],[v[4],e[11][4-created->3],v[3]]]==>[[],[v[6],e[12][6-created->3],v[3]]]==>[[],[v[4],e[10][4-created->5],v[5]]]==>[[],[v[1],e[7][1-knows->2],v[2]]]==>[[],[v[2],e[7][1-knows->2],v[1],e[8][1-knows->4],v[4]]]==>[[],[v[3],e[9][1-created->3],v[1],e[8][1-knows->4],v[4]]]==>[[],[v[1],e[9][1-created->3],v[3],e[11][4-created->3],v[4]]]==>[[],[v[6],e[12][6-created->3],v[3],e[11][4-created->3],v[4]]]==>[[],[v[3],e[11][4-created->3],v[4],e[8][1-knows->4],v[1]]]==>[[],[v[5],e[10][4-created->5],v[4],e[8][1-knows->4],v[1]]]==>[[],[v[4],e[11][4-created->3],v[3],e[9][1-created->3],v[1]]]==>[[],[v[6],e[12][6-created->3],v[3],e[9][1-created->3],v[1]]]==>[[],[v[1],e[9][1-created->3],v[3],e[12][6-created->3],v[6]]]==>[[],[v[4],e[11][4-created->3],v[3],e[12][6-created->3],v[6]]]==>[[],[v[1],e[8][1-knows->4],v[4],e[11][4-created->3],v[3]]]==>[[],[v[5],e[10][4-created->5],v[4],e[11][4-created->3],v[3]]]==>[[],[v[2],e[7][1-knows->2],v[1],e[9][1-created->3],v[3]]]==>[[],[v[4],e[8][1-knows->4],v[1],e[9][1-created->3],v[3]]]==>[[],[v[1],e[8][1-knows->4],v[4],e[10][4-created->5],v[5]]]==>[[],[v[3],e[11][4-created->3],v[4],e[10][4-created->5],v[5]]]==>[[],[v[3],e[9][1-created->3],v[1],e[7][1-knows->2],v[2]]]==>[[],[v[4],e[8][1-knows->4],v[1],e[7][1-knows->2],v[2]]]
// tweaked traversal: values available
gremlin> g.V().sideEffect(outE().group("x").by().by("weight")).repeat(bothE().as("e").otherV().simplePath()).emit(__.loops().is(lt(3))).map(union(select("e").unfold().as("edge").select("x").unfold().where(select(keys).as("edge")).select(values).unfold().dedup().fold(), path()).fold())==>[[1.0],[v[1],e[8][1-knows->4],v[4]]]==>[[0.4],[v[3],e[11][4-created->3],v[4]]]==>[[1.0],[v[5],e[10][4-created->5],v[4]]]==>[[0.5],[v[2],e[7][1-knows->2],v[1]]]==>[[0.4],[v[3],e[9][1-created->3],v[1]]]==>[[1.0],[v[4],e[8][1-knows->4],v[1]]]==>[[0.2],[v[3],e[12][6-created->3],v[6]]]==>[[0.4],[v[1],e[9][1-created->3],v[3]]]==>[[0.4],[v[4],e[11][4-created->3],v[3]]]==>[[0.2],[v[6],e[12][6-created->3],v[3]]]==>[[1.0],[v[4],e[10][4-created->5],v[5]]]==>[[0.5],[v[1],e[7][1-knows->2],v[2]]]==>[[0.5,1.0],[v[2],e[7][1-knows->2],v[1],e[8][1-knows->4],v[4]]]==>[[0.4,1.0],[v[3],e[9][1-created->3],v[1],e[8][1-knows->4],v[4]]]==>[[0.4,0.4],[v[1],e[9][1-created->3],v[3],e[11][4-created->3],v[4]]]==>[[0.2,0.4],[v[6],e[12][6-created->3],v[3],e[11][4-created->3],v[4]]]==>[[0.4,1.0],[v[3],e[11][4-created->3],v[4],e[8][1-knows->4],v[1]]]==>[[1.0,1.0],[v[5],e[10][4-created->5],v[4],e[8][1-knows->4],v[1]]]==>[[0.4,0.4],[v[4],e[11][4-created->3],v[3],e[9][1-created->3],v[1]]]==>[[0.2,0.4],[v[6],e[12][6-created->3],v[3],e[9][1-created->3],v[1]]]==>[[0.4,0.2],[v[1],e[9][1-created->3],v[3],e[12][6-created->3],v[6]]]==>[[0.4,0.2],[v[4],e[11][4-created->3],v[3],e[12][6-created->3],v[6]]]==>[[1.0,0.4],[v[1],e[8][1-knows->4],v[4],e[11][4-created->3],v[3]]]==>[[1.0,0.4],[v[5],e[10][4-created->5],v[4],e[11][4-created->3],v[3]]]==>[[0.5,0.4],[v[2],e[7][1-knows->2],v[1],e[9][1-created->3],v[3]]]==>[[1.0,0.4],[v[4],e[8][1-knows->4],v[1],e[9][1-created->3],v[3]]]==>[[1.0,1.0],[v[1],e[8][1-knows->4],v[4],e[10][4-created->5],v[5]]]==>[[0.4,1.0],[v[3],e[11][4-created->3],v[4],e[10][4-created->5],v[5]]]==>[[0.4,0.5],[v[3],e[9][1-created->3],v[1],e[7][1-knows->2],v[2]]]==>[[1.0,0.5],[v[4],e[8][1-knows->4],v[1],e[7][1-knows->2],v[2]]]
--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/62f0c537-6cd2-4c1a-96e3-0b820a51f66b%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-user...@googlegroups.com.
Seems now dedup() step not working on both OLTP and OLAP: [[1.0,1.0],[v[1],e[8][1-knows->4],v[4],e[10][4-created->5],v[5]]]
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/ccd0b896-86f6-4c62-a4d0-d5be290f5840%40googlegroups.com.
g.V().sideEffect(__.outE("tsw").project("key","value").by().by("speed").aggregate("x")).barrier().repeat(__.outE("tsw").as("e").inV().simplePath()).emit(__.loops().is(P.lt(21))).map(__.union((Traversal) __.select("e").unfold().as("edge").select("x").unfold().where(__.select("key").as("edge")).select("value").unfold().dedup().fold(),(Traversal) __.path()).fold()).filter(__.limit(Scope.local, 1).count(Scope.local).is(1)).count()
--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/ab95ffbf-d527-4de3-9cd1-9db30b593f74%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-user...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/f1deda8d-f3f3-4704-aca9-7bdc2e0762dc%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/0c1d0648-a269-4ab4-ac93-3e86675a1814%40googlegroups.com.
Last query is perfect)
But previous query not working on SparkGraphComputer. Symptoms are the same as on TinkerGraph (long running time).
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/89ce600d-2514-4ca6-a1dd-935d85107848%40googlegroups.com.
Hi, Daniel!
Please, can You help to solve more complex problem:
Vertex v0 = graph.addVertex("code", "0");
Vertex v1 = graph.addVertex("code", "1");
Vertex v2 = graph.addVertex("code", "2");
v0.addEdge("tsw", v1, "speed", "1", "dayOfWeek", 1, "depTime", 10, "arrTime", 20 ); e[3]
v0.addEdge("tsw", v1, "speed", "1", "dayOfWeek", 1, "depTime", 15, "arrTime", 25 ); e[4]
v1.addEdge("tsw", v2, "speed", "1", "dayOfWeek", 1, "depTime", 35, "arrTime", 45 ); e[5]
v1.addEdge("tsw", v2, "speed", "1", "dayOfWeek", 1, "depTime", 40, "arrTime", 50 ); e[6]
g.V().repeat(__.outE("tsw").or(__.not(__.select("e")),
__.values("speed").as("s").select(Pop.last, "e").by("speed").where(P.eq("s"))).as("e").inV().simplePath()).emit().times(20).
map(__.union((Traversal) __.select(Pop.last, "e").by("speed").fold(),(Traversal) __.path()).fold());
This query give result:
[[1], [v[0], e[3][0-tsw->1], v[1]]]
[[1], [v[0], e[4][0-tsw->1], v[1]]]
[[1], [v[0], e[3][0-tsw->1], v[1], e[5][1-tsw->2], v[2]]]
[[1], [v[0], e[3][0-tsw->1], v[1], e[6][1-tsw->2], v[2]]]
[[1], [v[0], e[4][0-tsw->1], v[1], e[5][1-tsw->2], v[2]]]
[[1], [v[0], e[4][0-tsw->1], v[1], e[6][1-tsw->2], v[2]]]
[[1], [v[1], e[5][1-tsw->2], v[2]]]
[[1], [v[1], e[6][1-tsw->2], v[2]]]
Can I remove from result red lines?
I need check not only Ej.speed = Ej+1.speed
But take only one edge with minimal value of function:
timeAtWarehouse(Ej.dayOfWeek, Ej.arrTime, Ej+1.dayOfWeek, Ej+1.depTime)
So my condition for Ej+1 looks like:
Ej.speed = Ej+1.speed AND (timeAtWarehouse(Ej.dayOfWeek, Ej.arrTime, Ej+1.dayOfWeek, Ej+1.depTime) is minimal)
Where
timeAtWarehouse(Ej.dayOfWeek, Ej.arrTime, Ej+1.dayOfWeek, Ej+1.depTime) is function that return long value - in my case: time during that cargo stay at warehouse.
timeAtWarehouse(Ej.dayOfWeek, Ej.arrTime, Ej+1.dayOfWeek, Ej+1.depTime) for simplicity:
if(Ej.dayOfWeek == Ej+1.dayOfWeek && Ej.arrTime <= Ej+1.depTime) {
return Ej+1.depTime - Ej.arrTime;
}else{
return 99999;
}
Seems I need on each step take Edges with the same speed and after that prepare this structure
[
[timeAtWarehouse1, Edge1],
[timeAtWarehouse2, Edge2],
[timeAtWarehouse3, Edge3]
]
Sort it by timeAtWarehouse DESC and take first?if(Ej.dayOfWeek == Ej+1.dayOfWeek && Ej.arrTime <= Ej+1.depTime) {
return Ej+1.depTime - Ej.arrTime;
--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/07c6090a-8081-450e-9fa5-d268293b638a%40googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/86ec24b4-c43a-4bf8-9e73-09af6124cd49%40googlegroups.com.
Hi, Daniel!
First model with DayOfWeek and Time working but with one problem - may be reason is .times(20) - step. Because some paths (with length < 20) disappear from result if I add many Edges to graph (if i remove some Edges, this old paths come back).
I need get all paths with length <= 20, but seems it working different way.
I do some modification of timeAtWarehouse - for test it working ok, and do some changes in ot.
Function timeAtWarehouse = {
def m = it.get()
(m["dow0"] <= m["dow1"]) ? ((m["dow1"] - m["dow0"])*100 +(m["dt"] - m["at"])) : Integer.MAX_VALUE
}
Traversal ot = __.as("edge").values("dayOfWeek").as("dow1").
select(Pop.last, "e").by("dayOfWeek").as("dow0").
select("edge").values("depTime").as("dt").
select(Pop.last, "e").by("arrTime").as("at").
select("dow0","dow1","at","dt").map(timeAtWarehouse);
And also I modify sorting order: order().by(ot, Order.incr)
About second model that You advise:
I need both models
1. DayOfWeek and Time
2. Real DateTime.
Because we set up schedules by "days of week" and "time of a day" without real (Calendar DateTime).
For example Truck #1 departure: Monday 12:00 arrival Tuesday:16:00 (but there is no real DateTime).
And I need to see all paths in terms of Day Of Week and Time.
And after that I need second model where I will store real dateTime (i will calculate real DateTime for 30 days forward) - as You specified
I need chek that I can go forward only if DepTime >= ArrTime. So i need filter by negative values in timeAtWarehouse function - but it only for second model with real dateTime.
Daniel, I` wrong with my suggestion that problem in .times(20) - step
After removing .limit(1) from .order().by(ot, Order.incr).limit(1) - I get all needed paths but with many others.
Regards, Sergei.
Cheers,
Daniel
--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/d9249934-95de-4ff9-a0ac-526916568010%40googlegroups.com.
timeAtWarehouse = { def pc ->def at = pc.get("curr").value("arrTime")def dt = pc.get("prev").property("depTime")// I think departure time will always be available on the previous edge, otherwise there// wouldn't be a new out-edge, right? If so, feel free to remove the isPresent() check.return dt.isPresent() ? dt.value() - at : Integer.MAX_VALUE}g.V().outE("tsw").as("e").inV().emit().repeat( /* Note, that there's no restriction for the first edge, as there's no previous edge with a reference departure time */flatMap(outE("tsw").filter(__.as("edge").select(last, "e").where(eq("edge")).by("speed")).group().by(inV()).by(project("curr","prev").by().by(select(last, "e"))).local(select(values).order(local).by(timeAtWarehouse).limit(local, 1).select("curr"))).as("e").inV().simplePath()).times(20).map(union(select(last, "e").by("speed"), path().by(id).by(valueMap("arrTime","depTime"))).fold())
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-user...@googlegroups.com.
GraphTraversal gp = g.V().outE("tsw").as("e").inV().emit().repeat( /* Note, that there's no restriction for the first edge, as there's no previous edge with a reference departure time */
__.flatMap(
__.outE("tsw").filter(__.as("edge").select(Pop.last, "e").where(P.eq("edge")).by("speed")).
group().by(__.inV()).by(__.project("curr","prev").by().by(__.select(Pop.last, "e"))).local(__.select(Column.values).order(Scope.local).by(timeAtWarehouse).limit(Scope.local, 1).select("curr"))
).as("e").inV().simplePath()
).times(20).map(__.union(__.select(Pop.last, "e").by("speed"), __.path().by(T.id).by(__.valueMap("arrTime","depTime"))).fold())
But in groovy shell all is ok.
Regards, Sergei.
--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/9ea8911d-90fa-4115-8514-a670baf665f7%40googlegroups.com.
Function timeAtWarehouse = new Function() {
@Override
public Long apply(Object o) {
Map m = (Map)((Traverser) o).get();
Long at = ((Edge)(m.get("curr"))).value("arrTime");
Long dt = ((Edge)(m.get("prev"))).value("depTime");
return dt!=null ? dt - at : Integer.MAX_VALUE;
}
};
GraphTraversal gp = g.V().outE("tsw").as("e").inV().emit().repeat( //* Note, that there's no restriction for the first edge, as there's no previous edge with a reference departure time *//*
__.flatMap(
__.outE("tsw").filter(__.as("edge").select(Pop.last, "e").where(P.eq("edge")).by("speed")).
group().by(__.inV()).
by(__.project("curr","prev").
by().by(__.select(Pop.last, "e"))).
local(__.select(Column.values).order(Scope.local).by(timeAtWarehouse).limit(Scope.local, 1).select("curr"))
).as("e").inV().simplePath()
).times(20).map(__.union((Traversal) __.select(Pop.last, "e").by("speed"), (Traversal) __.path().by(T.id).by(__.valueMap("arrTime","depTime"))).fold());result is:[1, [0, {depTime=20, arrTime=10}, 1]] [1, [0, {depTime=20, arrTime=10}, 1, {depTime=60, arrTime=50}, 3]] [2, [0, {depTime=30, arrTime=20}, 1]] [1, [0, {depTime=40, arrTime=20}, 1]] [1, [0, {depTime=40, arrTime=20}, 1, {depTime=60, arrTime=50}, 3]] [1, [0, {depTime=20, arrTime=10}, 2]] [1, [0, {depTime=20, arrTime=10}, 2, {depTime=50, arrTime=40}, 3]] [1, [1, {depTime=60, arrTime=50}, 3]] [1, [1, {arrTime=50}, 3]] [1, [2, {depTime=50, arrTime=40}, 3]]Regards, Sergei.
Function timeAtWarehouse = new Function() {
@Override
public Long apply(Object o) {
Map m = (Map) o;
Long at = ((Edge)(m.get("curr"))).value("arrTime");
Long dt = ((Edge)(m.get("prev"))).value("depTime");
return dt!=null ? at - dt : Integer.MAX_VALUE;
}
};
I put this edges to Graph:
v0.addEdge("tsw", v1, "speed", "1", "arrTime", 10l, "depTime", 20l);
v1.addEdge("tsw", v2, "speed", "1", "arrTime", 10l, "depTime", 20l);
v1.addEdge("tsw", v3, "speed", "1", "arrTime", 50l, "depTime", 60l);I get[1, [0, {depTime=20, arrTime=10}, 1]] [1, [0, {depTime=20, arrTime=10}, 1, {depTime=20, arrTime=10}, 2]] [1, [1, {depTime=20, arrTime=10}, 2]] [1, [1, {depTime=60, arrTime=50}, 3]]
But missing path: 0 -> 1 -> 3
Regards, Sergei.
--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/cf823a96-a5a9-47de-bb71-f563e4ad9898%40googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/6db1f721-1c2e-4cb8-86bb-3a51ab170cc3%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/CA%2Bf9seX5LrAJryCTy6GoBfNiA8y%3DPgfLTo82cbsfj5yamc0UVQ%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/CA%2Bf9seX5LrAJryCTy6GoBfNiA8y%3DPgfLTo82cbsfj5yamc0UVQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/C4C2756A-96D0-4A77-A1BA-CE92858C984D%40gmail.com.
Hi, Daniel !
It`s very interesting - using sack.
I have some comments for previous version of a query, so may be You will want to improve latest version (with sack) based on my comments.
1. Comments about graph model
My logic is:
Ej - Edge from airportJ to airportJ+1
Ej.depTime - it is departure time from airport J.
Ej.arrTime - it is arrive time to airport J+1.
Flight 1
departure from Berlin at 2016.10.20 10:00
arrival to Paris 2016.10.20 12:00
Flight2
departure from Paris at 2016.10.20 14:00
arrival to Milan 2016.10.20 15:40
Berlin -> Ebp -> Paris -> Epm->Milan
Ebp.depTime = 2016.10.20 10:00
Ebp.arrTime = 2016.10.20 12:00
Epm.depTime = 2016.10.20 14:00
Epm.arrTime = 2016.10.20 15:40
So there is conditions:
Cond0: depTime and arrTime - it is time in milliseconds by UTC.
Cond1: Ej.depTime < Ej.arrTime , fligth duration = Ej.arrTime - Ej.depTime
Cond2: Ej.arrTime <= Ej+1.depTime (I can go to next flight from Paris To Milan only if Ebp.arrTime <= Epm.depTime)
2.Comment about query:
For satisfy Cond2 we need filter all negative values Ej+1.depTime - Ej.arrTime
Ej -> AirportJ+1 -> Ej+1
I try to modify query to meet this condition:
Function timeAtWarehouse = new Function() {
@Override
public Long apply(Object o) {
Map m = (Map) o;
Long dt = ((Edge) (m.get("curr"))).value("depTime");
Long at = ((Edge) (m.get("prev"))).value("arrTime");
return (dt - at) >= 0? (dt - at) : Long.MAX_VALUE; // Negative values will be at the end
//of list after sorting
}
};
Predicate checkNegativeTime = new Predicate() {
@Override
public boolean test(Object o) {
Map m = (Map)(((Traverser) o).get());
Long dt = ((Edge) (m.get("curr"))).value("depTime");
Long at = ((Edge) (m.get("prev"))).value("arrTime");
return (dt - at) >= 0;
}
};
I put filter to query:
order(local).by(timeAtWarehouse).
limit(local, 1).
filter(checkNegativeTime).
select("curr")
I`m not sure that it`s right way, but seems it working.
v0.addEdge("tsw", v1, "speed", "1", "arrTime", 10l, "depTime", 5l);
v1.addEdge("tsw", v2, "speed", "1", "arrTime", 15l, "depTime", 9l); // will be ignored
v1.addEdge("tsw", v2, "speed", "1", "arrTime", 20l, "depTime", 17l); * will be used
v2.addEdge("tsw", v3, "speed", "1", "arrTime", 30l, "depTime", 25l);
Output:
[1, [0, {depTime=5, arrTime=10}, 1]]
[1, [0, {depTime=5, arrTime=10}, 1, {depTime=17, arrTime=20}, 2]] *
[1, [0, {depTime=5, arrTime=10}, 1, {depTime=17, arrTime=20}, 2, {depTime=25, arrTime=30}, 3]] *
[1, [1, {depTime=9, arrTime=15}, 2]]
[1, [1, {depTime=9, arrTime=15}, 2, {depTime=25, arrTime=30}, 3]]
[1, [1, {depTime=17, arrTime=20}, 2]]
[1, [1, {depTime=17, arrTime=20}, 2, {depTime=25, arrTime=30}, 3]]
[1, [2, {depTime=25, arrTime=30}, 3]]
--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/bf7b52d4-acc5-4b7d-80e8-065872feaf71%40googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/89858081-8a01-40b2-8de9-2d26ef195fbb%40googlegroups.com.