GitHunt
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.js

Usage

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 output

How It Works

  1. Fetch word transitions from LLM API
  2. Build directed graph (words = nodes, transitions = edges)
  3. Find shortest path of target length via Dijkstra
  4. Return path as sentence

License

MIT

Languages

JavaScript100.0%

Contributors

Created December 27, 2025
Updated March 9, 2026