# Define a constraint to match all vertices with IPs that start with '128.55.12'
%start_ip_constraint = * like '128.55.12.%'
# Find vertices of interest using the constraint defined above
$start_ip = $base.getVertex(%start_ip_constraint);
# Find vertices of interest using the constraint directly
$elevate_me = $base.getVertex(* like '%elevateme%');
# Find paths from $elevate_me to $start_ip of length at most 4
$paths = $base.getPath($elevate_me, $start_ip, 4);
# Print subgraph in query client
dump $paths;
# Output subgraph to file
export > /tmp/paths.dot
dump all $paths
- Integer Literals
- e.g.
1234
- e.g.
- String Literals
- e.g.
'abc','%127.0.0.1%'
- e.g.
- Name
- e.g.
dump,type,*(yes "star" is a name..),"a name with space and double quotes"
- e.g.
- Operators
- e.g.
=,+,+=,-,-=,&,&=
- e.g.
- Graph Variables
- Variable name format:
$[a-zA-Z0-9_]+- e.g.
$ip,$1 $baseis a special immutable variable that represents the whole graph
- e.g.
- Variable name format:
- Constraint Variables
- Variable name format:
%[a-zA-Z0-9_]+- e.g.
%ip,%1
- e.g.
- Variable name format:
- Graph Expressions
- graph ::= graph-variable
- graph ::= graph
.graph-method(argument-list) - graph ::= graph (
+|-|&) graph
- Constraint Expressions
- constraint-name ::= %[a-zA-Z0-9_]+
- constraint-comparison-expression ::= name (
==|!=|>|<|>=|<=|like) string-literal - constraint-expression ::= [
not] constraint-comparison-expression | [not] constraint-name - constraint ::= constraint-expression [
and|orconstraint-expression ]
- List existing graphs, constraints, and environment variables
listto see alllist graphfor variables bound to graphslist constraintfor constraints that have been definedlist envfor current enviroment variables
- Set, unset, and print environment variables
env setvariable_name integerenv unsetvariable_nameenv printvariable_name
- Print graph statistics
- Print vertex count and edge count (in specified graph)
statgraph
- Print mean value of vertex/edge annotation key (in specified graph)
stat vertex|edge <key> meangraph
- Print standard deviation of values for vertex/edge annotation key (in specified graph)
stat vertex|edge <key> stdgraph
- Print histogram of values of vertex/edge annotation key (in specified graph)
stat vertex|edge <key> histogramgraph
- Print distribution of values of vertex/edge annotation key (in specified graph)
stat vertex|edge <key> distribution <number of bins>graph- distribution divides the values from minimum to maximum into specified number of sub-range bins
- Print vertex count and edge count (in specified graph)
- Print graph as a SPADE
Graphdumpgraph- using
allprints entire graph, even if it exceeds limit inexportLimitenvironment variable
- Print constraint
dumpconstraint
- Remove a list of variables (graph or constraint)
erase(graph)+
- Remove all variables
reset workspace
- Execute query directly in the underlying storage's language
native'query_in_single_quotes'
return-type method-name ( argument-type formal-argument, ... )
- graph getVertex ( )
- Get all the vertices
- e.g.
$2 = $1.getVertex()
- e.g.
- Get all the vertices
- graph getVertex ( constraint constraint )
- Get all vertices that match a constraint
- e.g.
$2 = $1.getVertex(* LIKE '%firefox%')
- e.g.
- Get all vertices that match a constraint
- graph getMatch ( graph otherGraph, string annotation, ... )
- Get vertices in operand and
otherGraphthat have allannotationkeys specified and the values of those keys match- e.g.
$3 = $1.getMatch($2, 'pid', 'ppid')returns all vertices in$1or$2if a vertex in the other graph had the same values for annotation keyspidandppid
- e.g.
- NOTE: Experimental
- Get vertices in operand and
- graph getEdge ( )
- Get all the edges
- e.g.
$2 = $1.getEdge()
- e.g.
- Get all the edges
- graph getEdge ( constraint constraint )
- Get all the edges that match a constraint
- e.g.
$2 = $1.getEdge(operation = 'write')
- e.g.
- Get all the edges that match a constraint
- graph collapseEdge ( string annotation, ... )
- Collapse edges with regard to the annotations
- e.g.
$2 = $1.collapseEdge('type', 'operation')
- e.g.
- Collapse edges with regard to the annotations
- graph getEdgeEndpoints ( )
- Get all the vertices that are endpoints of edges
- e.g.
$2 = $1.getEdgeEndpoints()
- e.g.
- Get all the vertices that are endpoints of edges
- graph getEdgeSource ( )
- Get all the vertices that are source endpoints of edges
- e.g.
$2 = $1.getEdgeSource()
- e.g.
- Get all the vertices that are source endpoints of edges
- graph getEdgeDestination ( )
- Get all the vertices that are destination endpoints of edges
- e.g.
$2 = $1.getEdgeDestination()
- e.g.
- Get all the vertices that are destination endpoints of edges
- graph getLineage ( graph sourceVertices [ , int maxDepth ] , string direction )
- Get lineage of a set of source vertices
- direction can be
'ancestor'(or'a') /'descendant'(or'd') /'both'(or'b').- e.g.
$2 = $base.getLineage($1, 3, 'b')or$2 = $base.getLineage($1, 'b')to implicitly usemaxDepthenvironment variable
- e.g.
- graph getPath ( graph sourceVertices, ( graph destinationVertices [ , int maxDepth ] )+ )
- Get paths from a set of source vertices to a set of destination vertices, restricted to those that pass through specified intermediate vertices
- e.g.
$3 = $base.getPath($1, $2, 5) - e.g.
$4 = $base.getPath($1, $2, 9, $3)with a maximum path length between$1and$2of 9, and maximum path length between$2and$3implicitly defined bymaxDepthenvironment variable
- e.g.
- Get paths from a set of source vertices to a set of destination vertices, restricted to those that pass through specified intermediate vertices
- graph getShortestPath ( graph sourceVertices, graph destinationVertices[, int maxDepth] )
- Get the shortest path from a set of source vertices to a set of destination vertices
- NOTE: Currently this finds a short path, but not the shortest path
- e.g.
$3 = $somePath.getShortestPath($1, $2, 5)or$3 = $somePath.getShortestPath($1, $2)to implicitly usemaxDepthenvironment variable
- e.g.
- graph getSubgraph ( graph skeletonGraph )
- Get all vertices and edges that are spanned by
skeletonGraph- e.g.
$2 = $base.getSubgraph($1)
- e.g.
- Get all vertices and edges that are spanned by
-
graph vertexSubset ( int from, int to )
- Get the vertex subset (ordered by id) between
from(inclusive), andto(exclusive)
- Get the vertex subset (ordered by id) between
-
graph edgeSubset ( int from, int to )
- Get the edge subset (ordered by id) between
from(inclusive), andto(exclusive)
- Get the edge subset (ordered by id) between
-
graph vertexSample ( int sampleSize )
- Get the randomly sampled vertex subset of size
sampleSize
- Get the randomly sampled vertex subset of size
-
graph edgeSample ( int sampleSize )
- Get the randomly sampled edge subset of size
sampleSize
- Get the randomly sampled edge subset of size
-
graph transform ( name transformer, string initializationArgument[, argument]*)
- Use a pre-defined transformer to return a rewritten version of the graph.
- Arguments can be graph variables, integers, or strings.
- e.g.
$2 = $1.transform(DropKeys, 'keys=uid,gid')copies the vertices and edges in$1to$2, droppping annotations withuidorgidas the key. - e.g.
$3 = $2.transform(Prune, '', $1, 10, 'both')prunes graph$1from$2upto max depth10inbothdirections.
- e.g.
- graph vertices ( string vertexHash, ... )
- Get all vertices specified by their hashes
- e.g.
$1 = vertices('815fd285f16cce9ab398b5b2ce5d2d03', '087b22992d4d871dc8c9ccd837132c6a')
- e.g.
- Get all vertices specified by their hashes
- graph edges ( string edgeHash, ... )
- Get all edges specified by their hashes
- e.g.
$1 = edges('b161b03a4365faf44d8cdd3713f811e9', 'b161b03a4365faf44d8cdd3713f811e0')
- e.g.
- Get all edges specified by their hashes
- Graph Union
+,+=- e.g.
$3 = $1 + $2 - e.g.
$b += $a
- e.g.
- Graph Intersection
&,&=- e.g.
$3 = $1 & $2 - e.g.
$b &= $a
- e.g.
- Graph Difference
-,-=- e.g.
$3 = $1 - $2 - e.g.
$b -= $a
- e.g.