# Core Concepts
> The vocabulary and mental model behind CGraph — from extraction to the graph an agent queries.
[Source](https://open.nxtsoft.io/docs/cgraph/core-concepts)

CGraph has a small set of concepts that recur throughout the docs. This page is
the mental model; later pages go deep on each stage.

## The core idea

A codebase is already a graph — files import files, functions call functions,
symbols reference symbols. That graph is just implicit in the text. CGraph makes
it explicit and queryable: it extracts the structure once into a deterministic
graph, then serves that graph to tools and agents so they reason over
relationships instead of re-deriving them from string search.

## The pipeline

Everything flows through three stages. Extraction reads the source; graph
post-processing turns raw extraction into a resolved graph; enrichment layers
optional semantic detail on top.

_Source to a resolved, queryable graph_

```text
Source tree
   |  detection + extraction   (tree-sitter / regex)
   v
Raw graph
   |  resolution + analysis    (imports, calls, relations, dedup, communities)
   v
Resolved graph
   |  semantic enrichment       (optional, host-driven)
   v
Queryable graph  ->  exports + daemon + MCP
```

## Terminology

| Term | What it means |
| --- | --- |
| **Extraction** | Deterministic parse of the source tree into nodes and links — tree-sitter for supported languages, regex/structured for the rest. |
| **Resolution** | Post-processing that connects the raw graph: import resolution, raw call resolution, and relation resolution. |
| **Semantic deduplication** | A post-processing step that merges duplicate semantic nodes. |
| **Community detection** | Graph analysis that groups related nodes into communities. |
| **Enrichment** | An optional, host-driven step that adds semantic fragments (chunk planning, validated before they mutate the graph). |
| **Gather** | How a query collects a neighborhood — `fixed` packs the whole k-hop neighborhood; `adaptive` keeps the full 2-hop core and expands the third hop only along query-relevant nodes. |
| **Context packing** | Fitting the gathered neighborhood into a token budget (a knapsack-style pack) for an agent. |
| **Blast radius** | The transitive set of nodes reachable from a change — the basis of impact analysis. |

## Determinism

Extraction is **deterministic**: the same source tree produces the same graph.
That matters because an agent's answers should not drift run to run, and because
a deterministic graph can be diffed — the same property that lets the daemon fold
edits in incrementally rather than rebuilding from scratch.

## How it compares

| | CGraph | grep | LSP |
| --- | --- | --- | --- |
| Persistent, queryable model | ✓ | ✕ | ✓ |
| Cross-file impact / blast radius | ✓ | ✕ | partial |
| Budgeted context for agents | ✓ | ✕ | ✕ |
| Language-agnostic graph | ✓ | ✓ | ✕ |

CGraph is not a replacement for full-text search or a language server — it
answers a different question: how the pieces relate, and what a change touches.

## Where to go next

- [Graph Model](/docs/cgraph/graph-model) — what the nodes and links actually are.
- [Memory](/docs/cgraph/memory) — how the graph persists and stays warm.
