Skip to content

feat(core): integrate ternary-types crate with route module#7

Merged
SuperInstance merged 2 commits into
mainfrom
integrate-ternary-types
Jun 5, 2026
Merged

feat(core): integrate ternary-types crate with route module#7
SuperInstance merged 2 commits into
mainfrom
integrate-ternary-types

Conversation

@SuperInstance
Copy link
Copy Markdown
Owner

Summary

Integrates the ternary-types crate (v0.1.0) into pincher-core, providing a full route/graph module built on top of the Ternary enum.

Changes

  • Depends on ternary-types — a lightweight Ternary enum with serde support (Positive, Neutral, Negative)
  • TernaryGraph — ternary-weighted adjacency-list graph supporting both directed and undirected modes
  • Shortest paths — Bellman-Ford with negative cycle detection
  • All-pairs shortest paths — Floyd-Warshall (O(V³))
  • Community detection — signed label propagation
  • Connected components — using only positive (trusted) edges
  • Spectral clustering — power iteration on signed Laplacian + k-means
  • Signed modularity — quality scoring for community assignments
  • RoomGraph — high-level named-room wrapper with routing, next-hop, and matrix methods
  • 13 tests covering all algorithms

Usage

use pincher_core::route::{RoomGraph, build_routing_graph};

let mut rg = build_routing_graph(&["lobby", "dev", "staging"]);
rg.add_trusted_route(0, 1);
rg.add_trusted_route(1, 2);
let dist = rg.distances_from(0);
assert_eq!(dist[2], Some(2.0));

Notes

  • Uses a path dependency for ternary-types until it's published to crates.io
  • After publishing, the path dep can be changed to a registry dep

@SuperInstance SuperInstance force-pushed the integrate-ternary-types branch from 0640928 to 509df71 Compare June 5, 2026 07:40
@SuperInstance SuperInstance merged commit 89d80fc into main Jun 5, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant