Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Algorithms Laravel Package

graphp/algorithms

Common graph algorithms for PHP, built on graphp/graph. Includes shortest paths, Dijkstra, Floyd-Warshall, topological sorting, connected components, and more, with a clean API for working with directed and undirected graphs.

Deep Wiki
Context7

Product Decisions This Supports

Feature scoping — what becomes cheap to build

  • Dependency and ordering features: topological sort and cycle detection make it practical to ship "publish this workflow only if no circular dependencies exist," migration/rollback ordering, onboarding task sequencing, or curriculum prerequisites without a bespoke implementation.
  • Routing and cost optimization: Dijkstra / Bellman-Ford / Floyd-Warshall support shipping-route selection, cheapest-path through a pricing or approval matrix, or "cheapest way to reach tier X" logic.
  • Grouping and segmentation: connected components and bipartite checks support feature like "find isolated accounts," "detect incompatible pairings," or clustering records by relationship without a data-science workstream.
  • Relationship-aware UX: BFS/DFS traversal for org charts, category trees, referral chains, and "how are these two entities connected" support tooling.

Roadmap decisions

  • This package makes graph-shaped roadmap items viable on a PHP budget with no new infrastructure. It does not justify committing to a graph-heavy product surface (recommendation engines, social graph feeds, fraud ring detection at scale) — those need a graph store or a dedicated service.
  • It is a good de-risking tool for a discovery spike: a one-to-two sprint prototype can validate whether a graph feature moves a metric before anyone funds a Neo4j or pgRouting decision.

Build vs. buy vs. adopt

  • Many of these algorithms are 50–200 lines to hand-write. The honest framing is adopt vs. reimplement, not buy: the package's value is breadth and already-debugged edge cases (negative weights, disconnected graphs), not deep technology.
  • The real build-vs-buy question it should trigger is "do we need a graph database at all?" If your graphs fit in memory and results can be computed offline, this dependency can defer that purchase indefinitely.

Use cases where the payoff is clearest: approval-chain resolution, RBAC/permission inheritance, warehouse slotting, delivery batching, referral or affiliate attribution paths, and data-integrity jobs that hunt for cycles and orphans.

When to Consider This Package

Adopt when:

  • The stack is PHP/Laravel and introducing a JVM/Python service or graph database is disproportionate to the feature's value.
  • Graph size is bounded and known — roughly thousands of nodes/edges, computed in batch, queued jobs, or nightly, not per-request on the hot path.
  • You need several classical algorithms rather than one, so breadth offsets the dependency cost.
  • You can pin the version and are willing to own a small adapter layer plus, if necessary, a fork.

Look elsewhere when:

  • Scale or latency matters: pure-PHP adjacency traversal has real memory and CPU overhead; interactive queries over 10k+ edges will disappoint regardless of algorithm quality.
  • Maintenance risk is unacceptable: last release was February 2020, the maintainer surface is thin, and the project has a small audience. Verify PHP 8.x compatibility in your own test suite before committing — do not assume it.
  • You need graph persistence, query language, or incremental updates — this is an in-memory computation library, not a store.
  • You need modern algorithms the package predates or omits: PageRank-style ranking, community detection, weighted matching variants, or approximate nearest-neighbor work.
  • You need a support contract, CVE response, or SLA. MIT and volunteer-maintained means you are the support tier.

Mitigation that should accompany adoption: wrap it behind a narrow internal interface (PathFinder, DependencyResolver) so the library is swappable, and keep a fork-or-reimplement exit in your back pocket. The algorithms are textbook; the lock-in is near zero if the seam is right.

How to Pitch It (Stakeholders)

To executives: This is a free, permissively licensed PHP library that lets us ship dependency-ordering, path-finding, and relationship-grouping features without new infrastructure or a new hire. The decision it unlocks is a cheap one — a short spike tells us whether a graph-flavored feature is worth funding, before we spend on a graph database. The risk is contained: the package is small, unmaintained since 2020, and solves well-understood textbook problems, so our exposure is a bounded engineering effort behind an interface we control, not a platform bet. Recommendation: adopt for internal and batch use cases, not for customer-facing real-time scale, and revisit if the graph surface becomes core to the product.

To engineering: One dependency, MIT, PSR-friendly, built on graphp/graph. Treat it as a utility, not a platform: pin the version, verify on your PHP target in CI, benchmark with realistic data volumes before promising any latency numbers, and isolate it behind our own interfaces so replacing it is a one-file change. Budget a day for compatibility checks and a day for the adapter. If a required algorithm is missing or too slow, the fork cost is low — flag it early rather than designing around it.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
coleus/frame
thtg88/journalism
filagora/filagora-ai-forums
rlacerda83/query-parser
socialdept/atp-orm
cboxdk/laravel-assistant-client
socialdept/atp-resolver
socialdept/tenant-domains
tautvydasr/blade-class-names
socialdept/color-scales
maherelgamil/controller
coleus/widgets
coleus/table
coleus/users
coleus/music
coleus/health
coleus/calendar
coleus/notes
coleus/support
coleus/settings