azjezz/psl
PSL is a modern, well-typed standard library for PHP 8.4+, inspired by HHVM’s HSL. It offers safer, predictable APIs for async, collections, networking, I/O, crypto, terminal UI, and robust data validation—replacing brittle built-ins with consistent alternatives.
The Graph component provides immutable graph data structures and algorithms for working with directed and undirected graphs.
Graphs are fundamental data structures for modeling relationships and networks. This component supports directed and undirected graphs, weighted and unweighted edges, traversal (BFS, DFS), shortest path finding, topological sorting, and cycle detection. All operations are immutable and return new graph instances.
The Graph component uses an adjacency list representation:
DirectedGraph<TNode, TWeight>: Directed graph with edges from node A to node BUndirectedGraph<TNode, TWeight>: Undirected graph with bidirectional edgesEdge<TNode, TWeight>: Represents an edge with optional weight@example('collections/graph-building.php')
@example('collections/graph-traversal.php')
For unweighted graphs, BFS is used. For weighted graphs, Dijkstra's algorithm is used.
@example('collections/graph-shortest-path.php')
@example('collections/graph-cycle-detection.php')
Nodes can be any type, including objects:
@example('collections/graph-object-nodes.php')
See src/Psl/Graph/ for the full API.
How can I help you explore Laravel packages today?