pear/structures_graph
PEAR Structures_Graph is a lightweight PHP library for creating and working with graphs (nodes and edges). It provides common graph data structures and algorithms for traversal and analysis, useful for dependency graphs, routing, and other graph-based problems.
This is a minimal, standalone library for basic graph manipulation (nodes, edges, adjacency lists). Given its low star count and archived status, assume it's stable but no longer actively developed. Start by examining Pear\Structures_Graph class methods: addNode(), addEdge(), getNeighbors(), hasNode(), and dfs()/bfs() traversals. First use case: modeling simple directed/undirected relationships (e.g., dependency trees, category hierarchies) where heavy graph libraries like webmozart/graph would be overkill.
Pear\Structures_Graph::setNodeType() and setEdgeType() to define node/edge metadata (e.g., 'type' => 'category').getNeighbors()) for custom path logic instead of built-in dfs()/bfs(), as they return only node IDs and lack early-exit hooks.toArray() for caching or export; reconstruct with Pear\Structures_Graph::loadFromArray().Pear\Structures_Graph, not Pear_Structures_Graph (notice underscore vs backslash). Autoloading must match the PSR-0 legacy structure.setDirected(true) to enforce directionality—forgot this and your adjacency lists will surprise you.weight in edge data require manual handling during traversal.printGraph() (not a PHP method—use var_dump() on the internal nodes array) since the class lacks a pretty-printer.findLongestPath() or topologicalSort()—the minimal core makes subclassing straightforward.How can I help you explore Laravel packages today?