
CREATE PROCEDURE "TripRoutingSP" (IN airportCodeOrigin NVARCHAR(3), IN airportCodeDestination NVARCHAR(3), OUT totalSegments BigInt, OUT totalDistance Int, OUT totalDuration Int, OUT routing "TripRoutingTT")
LANGUAGE GRAPH READS SQL DATA AS
BEGIN
Graph g = Graph("TRAVEL", "Flights");
Vertex sourceVertex = Vertex(:g, :airportCodeOrigin);
Vertex targetVertex = Vertex(:g, :airportCodeDestination);
WeightedPath<BigInt> p = SHORTEST_PATH(:g, :sourceVertex, :targetVertex);
totalSegments = Length(:p);
FOREACH e IN Edges(:p) {
totalDistance = :totalDistance + :e."distance";
totalDuration = :totalDuration + :e."duration";
}
routing = SELECT :segment, :e."airportCodeOrigin", :e."airportCodeDestination", :e."airlineName", :e."distance", :e."duration" FOREACH e in Edges(:p) WITH ORDINALITY AS segment;
END;
CREATE PROCEDURE "AirportDestinations" (IN airportCode NVARCHAR(3), OUT direct Int, OUT oneTransfer Int, OUT twoTransfers Int)
LANGUAGE GRAPH READS SQL DATA AS
BEGIN
Graph g = Graph("TRAVEL", "Flights");
TRAVERSE BFS :g
FROM {
Vertex(:g, :airportCode)
}
ON VISIT VERTEX (Vertex v, BigInt lvl) {
IF (:lvl == 1L) {
direct = :direct + 1;
}
ELSE {
IF (:lvl == 2L) {
oneTransfer = :oneTransfer + 1;
}
ELSE {
IF (:lvl == 3L) {
twoTransfers = :twoTransfers + 1;
}
}
}
}
;
END;
MATCH (a)-[e]->(b)
WHERE e.airlineName STARTS WITH 'KLM'
RETURN a.airportCode AS airportCodeFrom, b.airportCode AS airportCodeTo, e.distance AS distance
MATCH (a)-[e]->(b)
WHERE e.airlineName ENDS WITH 'lines'
RETURN a.airportCode AS airportCodeFrom, b.airportCode AS airportCodeTo, e.distance AS distance
MATCH (a)-[e]->(b)
WHERE e.airlineName SYS.TEXT_CONTAINS(e.airlineName, 'Airline', 'FUZZY(0.4)')
RETURN a.airportCode AS airportCodeFrom, b.airportCode AS airportCodeTo, e.distance AS distance
MATCH (a)-[e1]->(b)
MATCH (b)-[e2]->(c)
MATCH (c)-[e3]->(d)
WHERE a.airportCode = ''$$airportCodeFrom$$'' AND d.airportCode = ''$$airportCodeTo$$'' $$customFilter$$
RETURN e1.airlineName AS airlineName1, b.airportCode AS transferAirportCode1, e2.airlineName AS airlineName2, c.airportCode AS transferAirportCode2, e3.airlineName AS airlineName3
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
27 | |
12 | |
12 | |
11 | |
10 | |
9 | |
9 | |
7 | |
7 | |
7 |