# Graph reasoning

Graph reasoning helps you define a graph from part of your semantic model, run graph algorithms, and use their results in downstream logic and analysis.
Use this overview to decide when graph reasoning fits your question and to choose the right next guide.

## What graph reasoning is

Graph reasoning is a workflow for answering structure-focused questions by building a *graph* from part of your model.
A graph represents a set of things called *nodes* and the connections between them called *edges*.

In PyRel, you typically:

- Define what counts as a node and what counts as an edge for your question.
- Choose whether the graph is directed or undirected, and weighted or unweighted.
- Run an algorithm to compute a result.
- Join the algorithm result back into your model as a relationship you can query and reuse.

Graph reasoning does not turn your entire semantic model into "the graph".
Instead, you build a graph for a specific question by choosing what counts as a node and what counts as an edge.

## When to use graph reasoning

Use graph reasoning when your question is about connectivity, ranking, similarity, or communities.
If your question is a straightforward filter, join, or aggregate, it is usually clearer to answer it with [rules-based reasoning](/build/guides/reasoning/rules-based/index.md) instead.

| If you need to…                           | Use a…                                                                                                                                                                                                      | To get…                                                                                                         |
| ----------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- |
| Answer reachability or distance questions | [Connectivity algorithm](/build/guides/reasoning/graph/run-an-algorithm/index.md#connectivity) or [distance algorithm](/build/guides/reasoning/graph/run-an-algorithm/index.md#distance)                    | A relationship that pairs nodes with nodes they can reach, and optionally how far apart they are                |
| Find important or influential nodes       | [Centrality algorithm](/build/guides/reasoning/graph/run-an-algorithm/index.md#centrality-measures)                                                                                                         | A relationship that assigns a score to each node, so you can see which ones matter most                         |
| Find similar nodes or candidate links     | [Similarity algorithm](/build/guides/reasoning/graph/run-an-algorithm/index.md#similarity-measures) or [link prediction algorithm](/build/guides/reasoning/graph/run-an-algorithm/index.md#link-prediction) | A relationship that assigns a similarity score to pairs of nodes, so you can find close matches or likely links |
| Group nodes into clusters                 | [Community detection algorithm](/build/guides/reasoning/graph/run-an-algorithm/index.md#community-detection)                                                                                                | A relationship that assigns a group label to each node, so you can find clusters of related nodes               |

## Where to go next

Follow the links below to learn more about graph reasoning in PyRel.

- [Create a graph](/build/guides/reasoning/graph/create-a-graph/index.md): Define a graph from existing concepts and relationships in your semantic model.
- [Run an algorithm](/build/guides/reasoning/graph/run-an-algorithm/index.md): Run a graph algorithm and use its results in downstream queries and definitions.
