DROP ALL
command.WITH REVERSE_EDGE
clause means that for every two vertices (x,y) connected by a Liked type of edge, the system will automatically generate a corresponding edge of type Liked_By pointing from y to x, and both edges will have the same edge attributes.CREATE GRAPH gsql_demo(*)
as a separate command after creating all the vertex and edge types. If you decide you want to modify the schema after running CREATE GRAPH, you can create and run a SCHEMA_CHANGE JOB.cf_model.gsql
, and then run the command file. From within the shell, you would run
@cf_model.gsql
From outside the shell, you would run
>
gsql cf_model.gsql
ls
command from within the GSQL shell to see a report as below:DROP
command. Use the help
command to see a summary of available GSQL commands.User
vertices, one edge type of Liked
, and one edge type of Liked_By
. For the second row, however, only one new vertex will be created since id2
has been seen already. Two edges will be created for the second row.SELECT count(*) FROM User
SELECT count(*) FROM User-(Liked)->User
SELECT approx_count(*) FROM User
SELECT approx_count(*) FROM User-(Liked)->User
SELECT * FROM User LIMIT 3
SELECT * FROM User WHERE primary_id=="id2"
SELECT * FROM User-(ANY)->ANY WHERE from_id=="id1"
SELECT *
displays information in JSON format. Below is an example of query output.input_user
parameter. Suppose the input user is id1
. Next, the L1 statement starts from every vertex in the set L0, traverses every connected edge of type Liked_By and returns every target vertex (that is, the other ends of the connected edges). As a result, L1 is the set of all users who liked the input user. Referring to the graph in Figure 2, the query travels backwards along every Liked edge which points to id1
, arriving at id2
, id3
, and id5
. These three vertices form L1. Next, the L2 statement starts from each user in L1, travels to every user liked by that starting user (via the Liked type of edges), and increments the count for each User reached. That is, the algorithm counts how many times each vertex is visited by a query path. The WHERE condition makes sure the original input user will not be returned in the result.ORDER BY and LIMIT have the same meaning as in SQL. Below, we show how the L2 step tallies the counts for each vertex encountered:INSTALL QUERY
command): localhost
and port
is 9000
.ADD VERTEX | DIRECTED EDGE | UNDIRECTED EDGE
DROP VERTEX | DIRECTED EDGE | UNDIRECTED EDGE
ALTER VERTEX vertex_type | EDGE edge_type ADD ATTRIBUTE (name type)
ALTER VERTEX vertex_type | EDGE edge_type DROP ATTRIBUTE (name)
localhost
) and data/cf_mod3_input.json is a text file containing the following JSON-encoded data:gsql commands.gsql
@commands.gsql
gsql 'DROP ALL'
DROP ALL
CREATE GRAPH gsql_demo(*)
' as a separate command after you have created all your vertex and edge types.->
in the FROM
clause used to represent the direction of a directed edge.