A compute query executes a Pregel algorithm to determine information about the knowledge graph in parallel. Called within the Graql shell or dashboard, the general syntax is:
compute [goal] [subgraph]; (using [strategy] where [modifiers];)
goalcan be any of the available statistics or graph queries.
subgraphis a comma separated list of types to be visited by the Pregel algorithm.
Additionally, for graph queries
strategyis actual algorithm used
modifiersare different depending on the specific query and algorithm.
The simplest query
count can be executed using the following:
The following query compute the clusters, in the subgraph containing only person and marriage, using connected component, and return the members of each cluster.
compute cluster in person, marriage; using connected-component where members = true;
The subgraph syntax is provided to control the types that a chosen algorithm operates upon.
By default, the compute methods include instances of every type in the calculation.
in keyword followed by a comma separated list of types will restrict the calculations to instances of those types only.
compute count in person;
will return just the number of instances of the concept type person.
Subgraphs can be applied to all compute queries and therefore are different to
The specific compute queries fall into two main categories and more information is given in the sections below.
Available Statistics Methods
The following methods are available to perform simple statistics computations. A summary of the statistics algorithms is given in the table below.
||Count the number of instances.|
||Compute the maximum value of an attribute.|
||Compute the minimum value of an attribute.|
||Compute the mean value of an attribute.|
||Compute the median value of an attribute.|
||Compute the standard deviation of an attribute.|
||Compute the sum of an attribute.|
For further information see the
Available Graph Queries
The following algorithms all compute values based on the structure of the graph. A summary of the graph algorithms is given in the table below.
||Find the clusters of instances.|
||Compute the centrality of each instance in the graph.|
||Find the shortest path(s) between two instances.|
For further information see the individual sections.