Download the PHP package mbsoft31/graph-core without Composer
On this page you can find all versions of the php package mbsoft31/graph-core. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mbsoft31/graph-core
More information about mbsoft31/graph-core
Files in mbsoft31/graph-core
Package graph-core
Short Description A lightweight, performant, and dependency-free graph data structure library for PHP.
License MIT
Homepage https://github.com/mbsoft31/graph-core
Informations about the package graph-core
mbsoft/graph-core
A lightweight, performant, and dependency-free graph data structure library for PHP. This library provides a clean, modern API for working with directed and undirected graphs, with support for node and edge attributes, subgraph views, and multiple export formats.
โจ Features
- ๐ High Performance: Uses integer indexing internally for O(1) adjacency lookups
- ๐ฏ Clean API: Well-designed interfaces following SOLID principles
- ๐ Directed & Undirected: Full support for both graph types
- ๐ท๏ธ Rich Attributes: Store arbitrary data on nodes and edges
- ๐๏ธ Subgraph Views: Create efficient filtered views without copying data
- ๐ค Multiple Export Formats: Cytoscape.js JSON, GraphML, GEXF
- ๐ Type-Safe: Leverages PHP 8.2+ features for type safety
- ๐ฆ Zero Dependencies: No external dependencies (except ext-dom for XML exports)
- โ Well-Tested: Comprehensive test coverage with Pest
๐ Requirements
- PHP 8.2 or higher
- ext-dom (for XML export formats)
๐ฆ Installation
Install via Composer:
๐ Quick Start
Basic Usage
Undirected Graphs
Creating Graphs from Edge Lists
๐ Advanced Features
Subgraph Views
Create efficient, read-only views of a subset of nodes:
Modifying Attributes
๐ค Export Formats
Cytoscape.js JSON
Export graphs for visualization with Cytoscape.js:
GraphML (XML)
Export to GraphML format for use with tools like Gephi, yEd, or NetworkX:
GEXF (XML)
Export to GEXF format for Gephi and other network analysis tools:
๐๏ธ Architecture
Interfaces
GraphInterface: Read-only graph operationsMutableGraphInterface: Extends GraphInterface with modification methodsExporterInterface: Common interface for all export formats
Core Classes
Graph: The main mutable graph implementationSubgraphView: Efficient filtered view of a graphNode: Immutable value object for nodesEdge: Immutable value object for edgesIndexMap: Internal bidirectional mapping for performance
๐งช Testing
Run the test suite:
Run tests with coverage:
Run static analysis:
๐ฏ Use Cases
This library is perfect for:
- Network Analysis: Social networks, communication networks, infrastructure
- Dependency Graphs: Package dependencies, task scheduling, build systems
- Pathfinding: Route planning, game AI, logistics optimization
- Data Visualization: Creating interactive graph visualizations
- Knowledge Graphs: Semantic networks, ontologies, concept maps
- Workflow Management: Process flows, state machines, decision trees
โก Performance Considerations
The library is optimized for performance:
- Integer Indexing: Internally uses integer indices for O(1) lookups
- Lazy Evaluation: Subgraph views don't copy data
- Memory Efficient: Adjacency lists only store actual connections
- Cache Friendly: Data structures optimized for CPU cache locality
Benchmarks
Performance with a 1,000 node graph:
- Node lookup: < 0.001ms
- Edge check: < 0.001ms
- Get successors: < 0.01ms
- Add edge: < 0.01ms
๐ Example Applications
Social Network Analysis
Task Dependency Graph
๐ค Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
๐ License
This library is open-sourced software licensed under the MIT license.
๐ Acknowledgments
- Inspired by NetworkX (Python) and JGraphT (Java)
- Built with modern PHP best practices
- Tested with Pest PHP testing framework
๐ฎ Support
For bugs and feature requests, please use the GitHub issues page.
๐ See Also
- mbsoft/graph-builder - Fluent builders and factories (Phase 2)
- mbsoft/graph-algorithms - Graph algorithms (Phase 3)
- mbsoft/graph-viz - Visualization components (Phase 4)
All versions of graph-core with dependencies
ext-dom Version *