{"id":51070670,"url":"https://github.com/code-shoily/yograph","last_synced_at":"2026-06-23T10:01:42.222Z","repository":{"id":361504951,"uuid":"1254704493","full_name":"code-shoily/yograph","owner":"code-shoily","description":"Graph and Network Analysis with Dart","archived":false,"fork":false,"pushed_at":"2026-05-31T00:23:16.000Z","size":11,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-31T01:09:40.196Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/code-shoily.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-05-30T22:50:30.000Z","updated_at":"2026-05-31T00:23:19.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/code-shoily/yograph","commit_stats":null,"previous_names":["code-shoily/yograph"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/code-shoily/yograph","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/code-shoily%2Fyograph","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/code-shoily%2Fyograph/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/code-shoily%2Fyograph/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/code-shoily%2Fyograph/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/code-shoily","download_url":"https://codeload.github.com/code-shoily/yograph/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/code-shoily%2Fyograph/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34684686,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-23T02:00:07.161Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-06-23T10:01:41.413Z","updated_at":"2026-06-23T10:01:42.213Z","avatar_url":"https://github.com/code-shoily.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Yograph 🌳\n\n\u003e **যোগ** • (*jōg*)\n\u003e *noun*\n\u003e 1. connection, link, union\n\u003e 2. addition, sum\n\n```text\n                    ★\n                   /|\\\n                  / | \\\n                 /  |  \\\n                Y   |   O--------G\n               /    |    \\      /\n              /     |     \\    /\n             /      |      \\  /\n            যো------+-------গ\n           / \\      |      / \\\n          /   \\     |     /   \\\n         /     \\    |    /     \\\n        ✦       ✦   |   ✦       ✦\n```\n\n[![pub package](https://img.shields.io/pub/v/yograph.svg)](https://pub.dev/packages/yograph)\n[![Dart CI](https://github.com/code-shoily/yograph/actions/workflows/dart.yml/badge.svg)](https://github.com/code-shoily/yograph/actions/workflows/dart.yml)\n\nYograph is a comprehensive graph theory library for Dart, providing classic and research-grade graph algorithms with a clean, capability-based API.\n\n**[YogEx](https://github.com/code-shoily/yog_ex)** — Elixir implementation with a superset of features.  \n**[Yog](https://github.com/code-shoily/yog)** — Gleam implementation with a functional API.\n\n## Features\n\nYograph provides balanced graph algorithms across multiple domains:\n\n### Pathfinding \u0026 Shortest Paths\n\n**Dijkstra** — `Dijkstra.shortestPath()`, `Dijkstra.singleSourceDistances()`  \n**A\\*** — `AStar.aStar()`, `AStar.implicitAStar()`, `AStar.implicitAStarBy()`  \n**Bellman-Ford** — `BellmanFord.shortestPath()`, negative cycle detection  \n**Floyd-Warshall** — `FloydWarshall.allPairs()`, all-pairs shortest paths  \n**Widest Path** — `Dijkstra.widestPath()`, maximum bottleneck routing\n\nAll pathfinding algorithms support custom semirings via optional `add` and `compare` callbacks.\n\n### Traversal\n\n**BFS \u0026 DFS** — `walk()`, `walkUntil()`, `foldWalk()`  \n**Best-First** — `bestFirstWalk()`, `bestFirstFold()`  \n**Topological Sort** — `topologicalSort()`, `lexicographicalTopologicalSort()`  \n**Random Walk** — `randomWalk()` with seeded reproducibility\n\n### Connectivity \u0026 Structure\n\n**Connected Components** — `Components.connectedComponents()`, `Components.weaklyConnectedComponents()`  \n**Strongly Connected Components** — `SCC.tarjan()`, `SCC.kosaraju()`  \n**Bridge \u0026 Articulation Point Detection** — `Analysis.analyze()`  \n**K-Core Decomposition** — `KCore.detect()`, `KCore.coreNumbers()`, `KCore.degeneracy()`  \n**Reachability Counts** — `Reachability.counts()` with DAG fast-path + SCC condensation fallback  \n**Structural Predicates** — `Structure.isTree()`, `Structure.isChordal()`, `Structure.isArborescence()`, `Structure.isComplete()`, `Structure.isRegular()`\n\n### Centrality\n\n**Degree** — `Centrality.degree()` with `DegreeMode` (in / out / total)  \n**Distance-Based** — `Centrality.closeness()`, `Centrality.harmonic()`, `Centrality.betweenness()` (Brandes' algorithm)  \n**Spectral / Iterative** — `Centrality.pageRank()`, `Centrality.eigenvector()`, `Centrality.katz()`, `Centrality.alpha()`  \n**Link-Analysis** — `Centrality.hits()` (hub \u0026 authority scores)\n\n### Health \u0026 Quality Metrics\n\n**Distance Metrics** — `Health.diameter()`, `Health.radius()`, `Health.eccentricity()`  \n**Structural** — `Health.assortativity()` (Pearson degree correlation)  \n**Path Metrics** — `Health.averagePathLength()`  \n**Efficiency** — `Health.globalEfficiency()`, `Health.localEfficiency()`, `Health.averageLocalEfficiency()`\n\n### Minimum Spanning Tree\n\n**Kruskal** — `MST.kruskal()`, `MST.kruskalMax()`  \n**Prim** — `MST.prim()`, `MST.primMax()`\n\n### Developer Experience\n\n**Capability-Based Interfaces** — `Traversable`, `Queryable`, `Mutable`, `Reversible` compose into role interfaces like `Walkable`, `WeightedWalkable`, `Bidirectional`  \n**Labeled Builder** — `LabeledBuilder` bridges ergonomic string/enum labels to internal `int` node IDs  \n**Strategy Pattern** — `Pathfinding.shortestPath()` accepts pluggable `PointToPointStrategy` implementations  \n**Disjoint Set** — `DisjointSet` with path compression and union by rank\n\n## Installation\n\nAdd yograph to your `pubspec.yaml`:\n\n```yaml\ndependencies:\n  yograph: ^0.1.0\n```\n\nOr via command line:\n\n```sh\ndart pub add yograph\n```\n\n## Quick Start\n\n```dart\nimport 'package:yograph/yograph.dart';\n\nvoid main() {\n  // Create a directed graph with String labels on nodes, int weights on edges\n  final graph = SimpleGraph\u003cString, int\u003e.directed()\n    ..addEdge(0, 1, data: 4)\n    ..addEdge(0, 2, data: 2)\n    ..addEdge(2, 1, data: 1)\n    ..addEdge(1, 3, data: 5)\n    ..addEdge(2, 3, data: 8);\n\n  // Find shortest path (default: Dijkstra)\n  final path = Pathfinding.shortestPath(graph, 0, 3);\n  print(path); // Path(0 -\u003e 2 -\u003e 1 -\u003e 3, weight: 8.0)\n\n  // Use A* with a heuristic\n  final astarPath = Pathfinding.shortestPath(\n    graph,\n    0,\n    3,\n    strategy: AStar(heuristic: (node, goal) =\u003e (goal - node).abs().toDouble()),\n  );\n  print(astarPath); // Path(0 -\u003e 2 -\u003e 1 -\u003e 3, weight: 8.0)\n\n  // Bellman-Ford handles negative weights\n  final bfGraph = SimpleGraph\u003cString, int\u003e.directed()\n    ..addEdge(0, 1, data: 4)\n    ..addEdge(0, 2, data: 3)\n    ..addEdge(1, 2, data: -2)\n    ..addEdge(2, 3, data: -3);\n\n  final result = BellmanFord.shortestPath(bfGraph, 0, 3);\n  if (result.isSuccess) {\n    print(result.path); // Path(0 -\u003e 1 -\u003e 2 -\u003e 3, weight: -1.0)\n  } else if (result.hasNegativeCycle) {\n    print('Negative cycle detected!');\n  }\n\n  // All-pairs shortest paths\n  final fw = FloydWarshall.allPairs(graph);\n  print(fw.distance(0, 3)); // 8.0\n\n  // Minimum spanning tree (undirected only)\n  final undirected = SimpleGraph\u003cString, int\u003e.undirected()\n    ..addEdge(0, 1, data: 4)\n    ..addEdge(0, 2, data: 1)\n    ..addEdge(1, 2, data: 3);\n\n  final mst = MST.kruskal(undirected);\n  print(mst.totalWeight); // 4.0\n\n  // Centrality\n  final scores = Centrality.betweenness(undirected);\n  print(scores); // {0: 0.0, 1: 0.0, 2: 0.0}\n\n  // Health metrics\n  print(Health.diameter(undirected)); // 1.0\n  print(Health.assortativity(undirected)); // 0.0 (all same degree)\n\n  // Connectivity\n  print(Components.connectedComponents(undirected)); // [[0, 1, 2]]\n  print(Structure.isTree(undirected)); // false (has a cycle)\n}\n```\n\n### Using Labels Instead of Integer IDs\n\n```dart\nfinal builder = LabeledBuilder\u003cString, int\u003e.directed()\n  ..addEdge('A', 'B', data: 4)\n  ..addEdge('A', 'C', data: 2)\n  ..addEdge('C', 'B', data: 1);\n\nfinal graph = builder.toGraph();\nfinal path = Pathfinding.shortestPath(graph, builder.getId('A')!, builder.getId('B')!);\nprint(path); // Path(0 -\u003e 2 -\u003e 1, weight: 3.0)\n```\n\n### Connectivity \u0026 Structure\n\n```dart\nfinal graph = SimpleGraph\u003cString, void\u003e.undirected()\n  ..addEdge(0, 1)\n  ..addEdge(1, 2)\n  ..addEdge(2, 0)\n  ..addEdge(0, 3);\n\n// Bridges and articulation points\nfinal analysis = Analysis.analyze(graph);\nprint(analysis.bridges);       // [(0, 3)]\nprint(analysis.articulationPoints); // {0}\n\n// Strongly connected components (directed)\nfinal directed = SimpleGraph\u003cString, void\u003e.directed()\n  ..addEdge(0, 1)\n  ..addEdge(1, 2)\n  ..addEdge(2, 0)\n  ..addEdge(2, 3);\n\nprint(SCC.tarjan(directed)); // [[3], [0, 1, 2]]\n\n// K-core decomposition\nprint(KCore.coreNumbers(graph)); // {0: 2, 1: 2, 2: 2, 3: 1}\n\n// Structural predicates\nprint(Structure.isChordal(graph)); // true\nprint(Structure.isComplete(graph)); // false\n```\n\n## Development\n\n### Running Tests\n\n```sh\n# Full test suite\ndart test\n\n# With coverage\ndart test --coverage=coverage\n\n# Analyze\ndart analyze --fatal-infos\n\n# Format check\ndart format --output=none --set-exit-if-changed .\n```\n\n### Git Pre-Commit Hook\n\nThis repository includes a shared Git pre-commit hook that automatically formats all staged `.dart` files and runs `dart analyze` before allowing any commit to succeed.\n\nTo enable the pre-commit hook in your local clone, run:\n\n```sh\ngit config core.hooksPath .githooks\n```\n\n### Project Structure\n\n- `lib/src/model/` — Capability interfaces (`Traversable`, `Queryable`, `Mutable`, `Reversible`, `Bidirectional`)\n- `lib/src/pathfinding/` — Dijkstra, A*, Bellman-Ford, Floyd-Warshall\n- `lib/src/traversal/` — BFS, DFS, topological sort, random walk\n- `lib/src/mst/` — Kruskal's and Prim's MST algorithms\n- `lib/src/centrality/` — Brandes' algorithm + degree, closeness, harmonic, betweenness, PageRank, eigenvector, Katz, alpha, HITS\n- `lib/src/property/` — Health metrics (`Health`) and structural predicates (`Structure`)\n- `lib/src/connectivity/` — Components, SCC (Tarjan / Kosaraju), bridge/articulation-point analysis, K-core, reachability\n- `lib/src/builder/` — `LabeledBuilder` for ergonomic graph construction\n- `lib/src/internal/` — Shared utilities (`PriorityQueue`)\n\n## Algorithm Catalog\n\n| Category | Algorithms | Complexity |\n|----------|-----------|------------|\n| **SSSP** | Dijkstra, A*, Bellman-Ford | O((V+E) log V), O(V×E) |\n| **APSP** | Floyd-Warshall | O(V³) |\n| **MST** | Kruskal, Prim | O(E log E), O(E log V) |\n| **Traversal** | BFS, DFS, best-first, random walk | O(V+E) |\n| **DAG** | Topological sort (Kahn's) | O(V+E) |\n| **Union-Find** | Disjoint Set | O(α(V)) amortized |\n| **Centrality** | Degree, closeness, harmonic, betweenness (Brandes), PageRank, eigenvector, Katz, alpha, HITS | O(V×E) – O(V³) |\n| **Health** | Diameter, radius, eccentricity, assortativity, APL, global/local efficiency | O(V×(V+E) log V) |\n| **Components** | Connected, weakly connected | O(V+E) |\n| **SCC** | Tarjan, Kosaraju | O(V+E) |\n| **Analysis** | Bridges, articulation points | O(V+E) |\n| **K-Core** | Core numbers, degeneracy, shell decomposition | O(V+E) |\n| **Reachability** | Ancestor/descendant counts (exact) | O(V+E) |\n| **Structure** | Tree, forest, arborescence, complete, regular, chordal | O(V+E) |\n\n## Related Projects\n\n- **[YogEx](https://github.com/code-shoily/yog_ex)** — Elixir graph library (superset of features)\n- **[Yog](https://github.com/code-shoily/yog)** — Gleam graph library (functional API)\n\n## License\n\nMIT\n\n---\n\n**Yograph** — Graph algorithms for Dart\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcode-shoily%2Fyograph","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcode-shoily%2Fyograph","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcode-shoily%2Fyograph/lists"}