mbsoft31/graph-algorithms
PHP package of graph algorithms built on graph-core: PageRank and degree centrality, Dijkstra and A* pathfinding, BFS/DFS traversal, Tarjan SCCs, topological sort with cycle detection, and minimum spanning trees for citation-network analysis. Requires PHP 8.2+.
Architecture fit. The package is a plain PHP library with no Laravel coupling — no service provider required, no facade, no config publishing. That is a feature, not a gap: it binds cleanly into the Laravel container as a singleton or is resolved per-job, and it keeps the graph layer out of the framework's upgrade blast radius (the same code survives Laravel 10 → 11 → 12). The real architectural commitment is the transitive dependency on nexus-scholar/graph-core and its data model (GraphInterface, string node IDs, array edge attributes) plus the AlgorithmGraph integer-indexed proxy used at execution time. Adopting this package means standardizing on that model, so the decision is broader than "add a Composer line." That portability risk belongs in the product risk register, not only in engineering's backlog.
Integration feasibility. High for a pilot. The public surface is small and typed: CentralityAlgorithmInterface, PathfindingAlgorithmInterface, TraversalAlgorithmInterface, and immutable PathResult/MstResult value objects. That makes the package cheap to wrap behind a first-party adapter and cheap to stub in tests — the classic precondition for a reversible spike. Three friction points are known up front:
Technical risk. The dominant risk is not code quality, it is supply chain and bus factor. One star, zero dependents, a single maintainer, and a recent Composer rename from mbsoft31/graph-algorithms to nexus-scholar/graph-algorithms. The v1.2.0 replace bridge keeps existing consumers satisfied and PHP namespaces remain Mbsoft\Graph\Algorithms, which means the rename is survivable but confusing — documentation, internal references, and security scanning will disagree about the package name for a while. Secondary risks:
AlgorithmGraph conversion at 10k–100k nodes is the specific unknown to measure.Key questions to answer before a build/buy decision:
nexus-scholar/graph-core acceptable as a permanent transitive dependency, including its data model constraints?Stack fit. Laravel + PHP 8.2/8.3 is squarely in scope; the package's own CI covers both. There is no framework integration to maintain, which is the ideal shape for a Laravel dependency: composer require nexus-scholar/graph-algorithms, optionally bind a small first-party GraphService in a service provider, and keep the vendor namespace out of controllers and models. Isolate it behind our own interface so a fork or replacement is a one-file swap.
Migration path. Two distinct migrations, and they should not be conflated:
nexus-scholar/graph-algorithms directly. Do not install mbsoft31/graph-algorithms — the replace bridge means both cannot coexist meaningfully, and installing the old name imports the same code under a confusing label.require line deliberately, pin an exact version, run composer validate --strict, and grep for stale references in docs, Dockerfiles, and SBOM tooling. Expect the rename to surface in security scanners as a package identity change even though the code did not move.Compatibility. Verify PHP floor, Composer version, and any existing graph dependency in the lockfile (a competing graph library will conflict, not compose). Because the algorithms are stateless and closure-configured, they are safe to instantiate per job — no shared mutable state to reason about across queue workers.
Sequencing. Sequence by feature value, not by package surface:
AlgorithmGraph conversion and the algorithm itself at the 10k / 50k / 100k node tiers. If it fails the latency budget, stop here; the information cost was one engineer-week.Maintenance. Low ongoing code maintenance, higher-than-usual governance maintenance. Pin exact versions, watch the repository directly (not just Packagist), and keep a fork branch warm. The codebase is readable in an afternoon — that readability is the real mitigation and should be stated explicitly in the risk acceptance. Do not let a transitive rename quietly change what we think we depend on.
Support. No commercial support, no SLA, issues via GitHub only. Escalation path is the fork. That is acceptable for a pilot and unacceptable for a revenue-critical path without the fork contingency documented first.
Scaling. The cost model is memory-bound and batch-shaped, not request-shaped. AlgorithmGraph builds an integer-indexed proxy plus an IndexMap, so peak memory scales with node and edge counts beyond the raw graph itself. Practical guidance: run heavy computation in queued jobs, chunk or sample large graphs, cache computed scores with an explicit TTL, and never invoke PageRank iteration on a synchronous web request. PageRank's maxIterations/tolerance are the levers for trading accuracy against wall time — set them deliberately rather than accepting defaults.
Failure modes to design for. The package surfaces failure honestly, which is good, but each state needs a product decision:
null when no path exists → a normal product state, not an error; the UI must handle it.Add observability around all five: log graph size, algorithm, elapsed time, and outcome per invocation.
Ramp-up. Genuinely cheap. Typed interfaces and immutable results mean a mid-level Laravel engineer can integrate an algorithm in a day and read the entire library in an afternoon. The non-obvious learning curve is the graph model (graph-core semantics, attribute conventions, AlgorithmGraph conversion), not the algorithms — so the onboarding doc should focus there, plus one worked example of "our data → graph → algorithm → persisted result."
Operational verdict. Adopt for a scoped pilot with an explicit fork trigger and a benchmark gate; do not adopt as core infrastructure on day one. The opportunity-to-adoption gap (high capability value, near-zero external adoption) is whitespace for a cheap, reversible experiment — not a mandate.
How can I help you explore Laravel packages today?