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];)
```

`goal`

can be any of the available statistics or graph queries.`subgraph`

is a comma separated list of types to be visited by the Pregel algorithm.

Additionally, for graph queries

`strategy`

is actual algorithm used`modifiers`

are different depending on the specific query and algorithm.

The simplest query `count`

can be executed using the following:

```
compute count;
```

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;
```

## Subgraph

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.
Using the `in`

keyword followed by a comma separated list of types will restrict the calculations to instances of those types only.

For example,

```
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 `strategy`

and `modifiers`

.

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.

Algorithm | Description |
---|---|

`count` |
Count the number of instances. |

`max` |
Compute the maximum value of an attribute. |

`min` |
Compute the minimum value of an attribute. |

`mean` |
Compute the mean value of an attribute. |

`median` |
Compute the median value of an attribute. |

`std` |
Compute the standard deviation of an attribute. |

`sum` |
Compute the sum of an attribute. |

For further information see the `statistics queries`

.

## 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.

Algorithm | Description |
---|---|

`cluster` |
Find the clusters of instances. |

`centrality` |
Compute the centrality of each instance in the graph. |

`path` |
Find the shortest path(s) between two instances. |

For further information see the individual sections.