# Graph of Thoughts

> Reason as a graph — merge, backtrack, and recombine thought branches.

- **Category**: Agentic AI
- **Subcategory**: Reasoning
- **Canonical URL**: https://designpattern.fyi/patterns/graph_of_thoughts/

---

## Description
**Intent**: Model reasoning as a directed graph where partial solutions can be merged, thoughts revisited, and successful sub-paths recombined across branches.

**Context**: Tree of Thoughts forces a branching structure where each path is independent. Real problem-solving often discovers that two separate lines of reasoning converge on the same insight, or that a dead branch contains a useful sub-result. GoT enables that recombination.

**Solution**: Represent the reasoning state as a graph of thought nodes. At each step, the model can: generate new child thoughts (expand), evaluate existing nodes (score), merge two nodes into a combined thought (aggregate), or backtrack to an earlier node. Use a graph traversal policy (beam search, BFS, heuristic scoring) to manage exploration. Computationally heavier than ToT — scope carefully. See also: tree-of-thoughts, chain-of-thought, adaptive-compute-allocation.



## Use Cases
- Complex planning tasks where sub-goals from different branches need to be combined.
- Creative or compositional tasks where partial solutions from multiple directions are valuable.
- Research-style reasoning where multiple hypotheses need to be compared and synthesized.






## Trade-offs


### Advantages

- More expressive than tree or chain structures — captures real reasoning topology.

- Partial-solution merging can find answers that pure tree search would miss.

- Backtracking and revisiting nodes avoids getting trapped in dead branches.




### Considerations & Drawbacks

- High computational cost — graph traversal multiplies LLM calls quickly.

- Graph state management is complex to implement correctly.

- Marginal improvement over ToT on most practical tasks; overkill for well-scoped problems.







---
**Reference**: [Original Source](https://www.agentpatternscatalog.org/patterns/graph-of-thoughts/)

