Example Graphs
Below is the listing of the graph create&load command files and data files to generate the six example graphs used in this document: workNet , socialNet , friendNet , computerNet , minimalNet , andinvestmentNet . The tar-gzip file gsql_ref_examples_2.0.gz contains all of these files. Each graph has its own folder. To create a particular graph, go in its folder and run the following command: gsql graph_create.gsql
gsql_ref_examples_2.0.gz
66KB
Binary
gsql_ref_examples_2.0.gz

workNet

graph_create.gsql for workNet
1
# Updated 5/1/18 for v2.0
2
DROP ALL
3
CREATE VERTEX person(PRIMARY_ID personId STRING, id STRING, locationId STRING, skillSet SET<INT>, skillList LIST<INT>, interestSet SET<STRING COMPRESS>, interestList LIST<STRING COMPRESS>)
4
CREATE VERTEX company(PRIMARY_ID clientId STRING, id STRING, country STRING)
5
CREATE UNDIRECTED EDGE worksFor(FROM person, TO company, startYear INT, startMonth INT, fullTime BOOL)
6
CREATE GRAPH workNet(*)
7
8
USE GRAPH workNet // v1.2
9
CREATE LOADING JOB loadMember FOR GRAPH workNet {
10
DEFINE FILENAME f;
11
LOAD f
12
TO VERTEX person VALUES($0, $0, $1, _, _, SPLIT($3,"|"), SPLIT($3,"|") ),
13
TO TEMP_TABLE t2(id, skill) VALUES ($0, flatten($2,"|",1));
14
15
LOAD TEMP_TABLE t2
16
TO VERTEX person VALUES($0, _, _, $"skill", $"skill", _, _);
17
}
18
19
CREATE LOADING JOB loadCompany FOR GRAPH workNet {
20
DEFINE FILENAME f;
21
LOAD f TO VERTEX company VALUES($0, $0, $1);
22
}
23
24
CREATE LOADING JOB loadMemberCompany FOR GRAPH workNet {
25
DEFINE FILENAME f;
26
LOAD f TO EDGE worksFor VALUES($0, $1, $2, $3, $4);
27
}
28
29
RUN LOADING JOB loadMember USING f="./persons"
30
RUN LOADING JOB loadCompany USING f="./companies"
31
RUN LOADING JOB loadMemberCompany USING f="./person_company"
Copied!
file: persons (vertices)
1
person1,us,1|2|3,management|financial
2
person2,chn,2|3|5|6,engineering
3
person3,jp,4|1|6,teaching
4
person4,us,4|1|10,football
5
person5,can,|8|2|5,sport|financial|engineering
6
person6,jp,7|10,music|art
7
person7,us,8|6,art|sport
8
person8,chn,1|5|2,management
9
person9,us,4|7|2,financial|teaching
10
person10,us,3,football|sport
11
person11,can,10,sport|football
12
person12,jp,1|5|2|2|2,music|engineering|teaching|teaching|teaching
Copied!
file: company (vertices)
1
company1,us
2
company2,chn
3
company3,jp
4
company4,us
5
company5,can
Copied!
file: person_company (edges)
1
person1,company1,2016,1,1
2
person1,company2,2014,3,0
3
person2,company1,2015,7,1
4
person2,company2,2012,6,0
5
person3,company1,2016,6,1
6
person4,company2,2013,2,1
7
person5,company2,2016,4,0
8
person6,company1,2015,1,1
9
person7,company2,2016,3,0
10
person7,company3,2014,1,0
11
person8,company1,2013,2,1
12
person9,company2,2015,12,1
13
person9,company3,2016,11,1
14
person10,company1,2016,2,1
15
person10,company3,2014,5,0
16
person11,company5,2016,5,1
17
person12,company4,2014,1,1
Copied!

socialNet

graph_create.gsql for socialNet
1
# Updated 5/1/18 for v2.0
2
DROP ALL
3
CREATE VERTEX person(PRIMARY_ID personId UINT, id STRING, gender STRING) WITH STATS="OUTDEGREE_BY_EDGETYPE"
4
CREATE UNDIRECTED EDGE friend(FROM person, TO person)
5
CREATE VERTEX post(PRIMARY_ID postId UINT, subject STRING, postTime DATETIME)
6
CREATE DIRECTED EDGE posted(FROM person, TO post)
7
CREATE DIRECTED EDGE liked(FROM person, TO post, actionTime DATETIME)
8
CREATE GRAPH socialNet(*)
9
10
USE GRAPH socialNet // v1.2
11
CREATE LOADING JOB loadMember FOR GRAPH socialNet {
12
DEFINE FILENAME f;
13
LOAD f TO VERTEX person VALUES($0, $0, $1) ;
14
}
15
16
CREATE LOADING JOB loadFriend FOR GRAPH socialNet {
17
DEFINE FILENAME f;
18
LOAD f TO EDGE friend VALUES($0, $1) ;
19
}
20
21
CREATE LOADING JOB loadPost FOR GRAPH socialNet {
22
DEFINE FILENAME f;
23
LOAD f TO VERTEX post VALUES($0, $1, $2);
24
}
25
26
CREATE LOADING JOB loadPosted FOR GRAPH socialNet {
27
DEFINE FILENAME f;
28
LOAD f TO EDGE posted VALUES($0, $1) ;
29
}
30
31
CREATE LOADING JOB loadLiked FOR GRAPH socialNet {
32
DEFINE FILENAME f;
33
LOAD f TO EDGE liked VALUES($0, $1, $2) ;
34
}
35
36
RUN LOADING JOB loadMember USING f="./persons"
37
RUN LOADING JOB loadFriend USING f="./friends"
38
RUN LOADING JOB loadPost USING f="./posts"
39
RUN LOADING JOB loadPosted USING f="./posted"
40
RUN LOADING JOB loadLiked USING f="./liked"
Copied!
file: persons (vertices)
1
person1,Male
2
person2,Female
3
person3,Male
4
person4,Female
5
person5,Female
6
person6,Male
7
person7,Male
8
person8,Male
Copied!
file: friends (edges)
1
person1,person2
2
person2,person3
3
person3,person4
4
person4,person5
5
person4,person6
6
person5,person7
7
person6,person8
8
person7,person8
9
person8,person1
Copied!
file: posts (vertices)
1
0,Graphs,2010-01-12 11:22:05
2
1,tigergraph,2011-03-03 23:02:00
3
2,query languages,2011-02-03 01:02:42
4
3,cats,2011-02-05 01:02:44
5
4,coffee,2011-02-07 05:02:51
6
5,tigergraph,2011-02-06 01:02:02
7
6,tigergraph,2011-02-05 02:02:05
8
7,Graphs,2011-02-04 17:02:41
9
8,cats,2011-02-03 17:05:52
10
9,cats,2011-02-05 23:12:42
11
10,cats,2011-02-04 03:02:31
12
11,cats,2011-02-03 01:02:21
Copied!
file: posted (edges)
1
person1,0
2
person2,1
3
person3,2
4
person4,3
5
person5,4
6
person5,11
7
person6,5
8
person6,10
9
person7,6
10
person7,9
11
person8,7
12
person8,8
Copied!
file: liked (edges)
1
person1,0,2010-01-11 11:32:00
2
person2,0,2010-01-12 10:52:15
3
person2,3,2010-01-11 16:02:26
4
person3,0,2010-01-16 05:15:53
5
person4,4,2010-01-13 03:16:05
6
person5,6,2010-01-12 21:12:05
7
person6,8,2010-01-14 11:23:05
8
person7,10,2010-01-12 11:22:05
9
person8,4,2010-01-11 03:26:05
Copied!

friendNet

graph_create.gsql for friendNet
1
# Updated 5/1/18 for v2.0
2
DROP ALL
3
CREATE VERTEX person(PRIMARY_ID personId UINT, id STRING)
4
CREATE UNDIRECTED EDGE friend(FROM person, TO person)
5
CREATE UNDIRECTED EDGE coworker(FROM person, TO person)
6
CREATE GRAPH friendNet(*)
7
8
USE GRAPH friendNet // v1.2
9
CREATE LOADING JOB loadMember FOR GRAPH friendNet {
10
DEFINE FILENAME f;
11
LOAD f TO VERTEX person VALUES($0, $0);
12
}
13
14
CREATE LOADING JOB loadFriend FOR GRAPH friendNet {
15
DEFINE FILENAME f;
16
LOAD f TO EDGE friend VALUES($0, $1);
17
}
18
19
CREATE LOADING JOB loadCoworker FOR GRAPH friendNet {
20
DEFINE FILENAME f;
21
LOAD f TO EDGE coworker VALUES($0, $1);
22
}
23
24
RUN LOADING JOB loadMember USING f="./persons"
25
RUN LOADING JOB loadFriend USING f="./friends"
26
RUN LOADING JOB loadCoworker USING f="./coworkers"
Copied!
file: persons (vertices)
1
person1
2
person2
3
person3
4
person4
5
person5
6
person6
7
person7
8
person8
9
person9
10
person10
11
person11
12
person12
Copied!
file: friends (edges)
1
person1,person2
2
person1,person3
3
person1,person4
4
person2,person8
5
person3,person9
6
person4,person6
7
person5,person6
8
person6,person9
9
person7,person9
10
person8,person10
11
person9,person8
12
person10,person12
13
person11,person12
14
person12,person8
15
person12,person9
Copied!
file: coworkers (edges)
1
person1,person4
2
person1,person5
3
person1,person6
4
person2,person3
5
person2,person4
6
person3,person5
7
person3,person6
8
person4,person5
9
person4,person6
10
person5,person6
11
person6,person5
12
person7,person9
13
person7,person5
14
person7,person4
15
person8,person9
16
person9,person2
17
person10,person7
18
person11,person7
19
person12,person7
Copied!

computerNet

graph_create.gsql for computerNet
1
# Updated 5/1/18 for v2.0
2
DROP ALL
3
CREATE VERTEX computer(PRIMARY_ID compID UINT, id STRING)
4
CREATE DIRECTED EDGE connected(FROM computer, TO computer, connectionSpeed DOUBLE, securityLevel INT)
5
CREATE GRAPH computerNet(*)
6
7
USE GRAPH computerNet // v1.2
8
CREATE LOADING JOB loadComputer FOR GRAPH computerNet {
9
DEFINE FILENAME f;
10
LOAD f TO VERTEX computer VALUES($0, $0);
11
}
12
CREATE LOADING JOB loadConnection FOR GRAPH computerNet {
13
DEFINE FILENAME f;
14
LOAD f TO EDGE connected VALUES($0, $1, $2, $3);
15
}
16
17
RUN LOADING JOB loadComputer USING f="./computers"
18
RUN LOADING JOB loadConnection USING f="./connections"
Copied!
file: computers (vertices)
1
c1
2
c2
3
c3
4
c4
5
c5
6
c6
7
c7
8
c8
9
c9
10
c10
11
c11
12
c12
13
c13
14
c14
15
c15
16
c16
17
c17
18
c18
19
c19
20
c20
21
c21
22
c22
23
c23
24
c24
25
c25
26
c26
27
c27
28
c28
29
c29
30
c30
31
c31
Copied!
file: connections (edges)
1
c1,c2,16.0,3
2
c1,c3,64.0,3
3
c1,c4,64.0,2
4
c1,c5,16.5,3
5
c1,c6,64.3,3
6
c1,c7,3.2,3
7
c1,c8,-3.5,3
8
c1,c9,-5.1,1
9
c1,c10,15.5,3
10
c1,c10,.5,1
11
c1,c10,126,3
12
c10,c11,16,3
13
c11,c12,.5,3
14
c12,c13,-0.5,3
15
c12,c14,0.16,4
16
c12,c15,1e2,3
17
c12,c16,3.516e3,3
18
c12,c17,5.12e-3,2
19
c12,c18,-2.34e-5,1
20
c12,c19,-0.000000000234,5
21
c12,c20,0.000123e-5,4
22
c12,c21,1000e3,1
23
c12,c22,0.000123e10,1
24
c14,c23,123456e-6,1
25
c14,c24,123456e5,3
26
c23,c24,64,2
27
c23,c25,16,2
28
c23,c26,32,2
29
c23,c27,16,2
30
c23,c28,3,1
31
c23,c29,32,2
32
c23,c30,16,2
33
c23,c25,3,2
34
c23,c26,3,2
35
c23,c27,64,2
36
c23,c28,32,2
37
c23,c29,3,2
38
c23,c30,3,2
39
c23,c31,32,2
40
c4,c23,16,2
41
c4,c23,32,2
42
c4,c23,64,2
43
c4,c23,3,2
Copied!

minimalNet

graph_create.gsql for minimalNet
1
DROP ALL
2
CREATE VERTEX testV(PRIMARY_ID id STRING)
3
CREATE UNDIRECTED EDGE testE(FROM testV, TO testV)
4
CREATE GRAPH minimalNet(*)
Copied!
There is no loading job or data for minimalNet (hence, "minimal.")

investmentNet

graph_create.gsql for investmentNet
1
# Updated 5/1/18 for v2.0
2
DROP ALL
3
TYPEDEF TUPLE <age UINT (4), mothersName STRING(20) > SECRET_INFO
4
CREATE VERTEX person(PRIMARY_ID personId STRING, portfolio MAP<STRING, DOUBLE>, secretInfo SECRET_INFO)
5
CREATE VERTEX stockOrder(PRIMARY_ID orderId STRING, ticker STRING, orderSize UINT, price FLOAT)
6
CREATE UNDIRECTED EDGE makeOrder(FROM person, TO stockOrder, orderTime DATETIME)
7
CREATE GRAPH investmentNet (*)
8
9
USE GRAPH investmentNet // v1.2
10
CREATE LOADING JOB loadPerson FOR GRAPH investmentNet {
11
DEFINE FILENAME f;
12
LOAD f
13
TO VERTEX person VALUES($0, SPLIT($1, ":", ";"), SECRET_INFO( $2, $3 ) );
14
}
15
16
CREATE LOADING JOB loadOrder FOR GRAPH investmentNet {
17
DEFINE FILENAME f;
18
LOAD f
19
TO VERTEX stockOrder VALUES($1, $3, $4, $5),
20
TO EDGE makeOrder VALUES($0, $1, $2);
21
}
22
23
RUN LOADING JOB loadPerson USING f="./persons"
24
RUN LOADING JOB loadOrder USING f="./orders"
Copied!
file: persons (vertices)
1
person1,AAPL:3142.24;G:6112.23;MS:5000.00,25,JAMES
2
person2,A:5242.62;GCI:5331.21;BAH:3200.00,67,SMITH
3
person3,AA:5223.73;P:7935.00;BAK:6923.52,45,WILLIAMS
4
person4,ACH:3542.62;S:6521.55;BABA:4030.52,51,ANTHONY
Copied!
file: orders (vertices and edges)
1
person1,0,1488566548,AAPL,500,34.42
2
person1,1,1488566549,A,210,50.55
3
person1,2,1488566550,B,211,202.32
4
person2,3,1488566555,S,2,42.44
5
person3,4,1488566155,ABC,2,52.44
6
person4,5,1488566255,Z,2,62.34
7
person4,6,1488566655,S,2,10.01
Copied!
Last modified 2yr ago