Weave Code
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

Graph Core Laravel Package

mbsoft31/graph-core

Lightweight, dependency-free graph library for PHP 8.2+. Build directed/undirected graphs with node and edge attributes, fast adjacency lookups, subgraph views, and export to Cytoscape.js JSON, GraphML, and GEXF (XML exports require ext-dom).

View on GitHub
Deep Wiki
Context7

Getting Started

Start by installing the package via Composer (composer require mbsoft31/graph-core). Since it's a core library with minimal surface area, the primary entry points are the Graph, Vertex, and Edge classes (or interfaces, depending on implementation). Begin by modeling a simple use case—like a dependency tree or routing hierarchy—by instantiating a Graph, adding Vertex instances, and connecting them with Edges. Check the included src/ folder for class signatures, as the library likely offers no external config files or service providers (being framework-agnostic and dependency-light).

Implementation Patterns

  • Domain Modeling: Embed graph primitives directly into your domain models (e.g., PermissionGraph, CatalogHierarchy) to enforce consistency across layers.
  • Algorithm Extension: Implement custom algorithms (e.g., TopologicalSort, Reachability) by extending base graph interfaces and injecting your graph instance—avoid forking the core.
  • Storage Abstraction: Plug in adapters (e.g., ArrayGraphStorage, DoctrineORMGraphStorage) to persist or hydrate graphs, keeping the business logic decoupled from persistence concerns.
  • Traversal Workflows: Use provided or custom traversal callbacks (e.g., BFS/DFS visitors) to process nodes incrementally—ideal for batch validation, serialization, or dependency resolution pipelines.

Gotchas and Tips

  • No Built-in Algorithms: This is only the foundation—do not expect ready-to-run shortest-path or cycle detection; you must build atop the primitives.
  • Immutability & Identity: Verify if vertices/edges are value objects or reference objects (especially regarding equality and hashing), as this affects reuse in collections.
  • Circular Dependencies: Because traversal utilities are minimal, implement cycle guards explicitly in custom DFS visitors to avoid infinite loops.
  • Interface Stability: With 0 stars and low score, prioritize type hints against interfaces (not concrete classes) to future-proof extensions—expect minor internal changes.
  • Testing Strategy: Write unit tests against your graph-based logic (not the core), using mockable interfaces; the small API surface makes mocking straightforward.
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.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport
twbs/bootstrap4