SK
skorotkiewicz/dijkstra-text-generator
Word Wizardry - Dijkstra-powered sentences, crafted from LLM magic
Dijkstra Text Generator
Generate sentences by finding the shortest path through a word-graph using Dijkstra's Algorithm.
Topic → LLM → Word Graph → Dijkstra → Sentence
Quick Start
node examples/simple.jsUsage
const { TextGenerator } = require("./index.js");
const gen = new TextGenerator({
baseURL: "http://localhost:8888/v1",
startWord: "The"
});
const result = await gen.generate("animals", 5);
console.log(result.sentence); // "The quick brown fox jumps"Examples
| Example | Description |
|---|---|
simple.js |
Basic usage with verbose output |
game_mechanic.js |
Spell casting system using path distance as mana cost |
seo_strategy.js |
Internal linking structure for SEO topic clusters |
visualizer.js |
Export word graph to GraphViz DOT format |
node examples/game_mechanic.js # ⚔️ Mana-based spell casting
node examples/seo_strategy.js # 🔗 SEO link clusters
node examples/visualizer.js # 👁️ GraphViz outputHow It Works
- Fetch word transitions from LLM API
- Build directed graph (words = nodes, transitions = edges)
- Find shortest path of target length via Dijkstra
- Return path as sentence
License
MIT