This project systematically evaluates the performance of fundamental graph algorithms across different graph structures, providing insights into their time complexity, memory usage, and scalability characteristics. The benchmark generates comprehensive datasets and visualizations to help researchers and developers understand algorithm behavior in practical scenarios.
- Traversal Algorithms: BFS, DFS
- Shortest Path Algorithms: Dijkstra, Bellman-Ford, A* Search
- Flow Algorithms: Maximum Flow (Edmonds-Karp)
- Graph Property Algorithms: Bipartite Graph Check
- Generate graphs of arbitrary size and density
- Measure execution time with nanosecond precision
- Track memory usage during algorithm execution
- Support for both weighted and unweighted graphs
- Customizable graph generation parameters
- Python analysis scripts with Matplotlib/Seaborn
- Interactive Streamlit dashboard
- Comparative performance charts
- Scalability analysis across graph sizes
- Memory-Runtime tradeoff visualizations
- Java 17 or higher
- Python 3.8 or higher
- Maven (for dependency management)
git clone https://github.com/harsharajkumar/graph-algorithms-benchmark.git
cd graph-algorithms-benchmarkCompile the Java source files:
javac -d bin src/algorithms/*.java src/utils/*.java src/experiments/*.javaAlternatively, use Maven to build the project:
mvn clean compileInstall required Python packages for analysis:
pip install -r analysis/requirements.txtExecute the comprehensive benchmark suite:
java -cp bin experiments.GraphAlgorithmBenchmarkVerboseRun specific algorithm tests:
# Test BFS performance
java -cp bin experiments.BFSBenchmark
# Test Dijkstra performance
java -cp bin experiments.DijkstraBenchmarkModify config/benchmark.properties to customize:
- Graph sizes (number of nodes)
- Graph densities (edge probabilities)
- Number of test iterations
- Output file locations
Generate performance visualizations:
python analysis/bench_analysis.pyLaunch the interactive dashboard:
streamlit run analysis/streamlit_app.py
- Dijkstra outperforms Bellman-Ford on sparse graphs but has similar complexity on dense graphs
- A* shows significant improvement over Dijkstra with good heuristics
- BFS/DFS have linear complexity with respect to graph size
- Edmonds-Karp demonstrates cubic complexity in worst-case scenarios
- Memory usage correlates strongly with algorithm time complexity
The interactive dashboard provides real-time exploration of algorithm performance metrics.
Interactive dashboard for exploring algorithm performance
- Dynamic filtering by algorithm and graph type
- Interactive performance charts
- Side-by-side algorithm comparisons
- Export functionality for results
- Configurable display options
graph-algorithms-benchmark/
βββ src/ # Java source code
β βββ algorithms/ # Algorithm implementations
β β βββ BFS.java
β β βββ DFS.java
β β βββ Dijkstra.java
β β βββ BellmanFord.java
β β βββ AStar.java
β β βββ EdmondsKarp.java
β β βββ BipartiteCheck.java
β βββ experiments/ # Benchmarking code
β β βββ GraphAlgorithmBenchmarkVerbose.java
β β βββ BFSBenchmark.java
β β βββ ...
β βββ utils/ # Utility classes
β β βββ GraphGenerator.java
β β βββ PerformanceMetrics.java
β β βββ ResultLogger.java
β βββ main/ # Main application class
β βββ Main.java
βββ analysis/ # Python analysis code
β βββ bench_analysis.py # Main analysis script
β βββ streamlit_app.py # Streamlit dashboard
β βββ requirements.txt # Python dependencies
β βββ figures/ # Generated visualizations
βββ results/ # Benchmark results (CSV format)
βββ config/ # Configuration files
β βββ benchmark.properties
βββ docs/ # Additional documentation
βββ pom.xml # Maven configuration
βββ README.md
Modify GraphGenerator.java to create specialized graph structures:
// Generate scale-free network
Graph scaleFreeGraph = GraphGenerator.generateScaleFreeGraph(1000, 3);
// Generate small-world network
Graph smallWorldGraph = GraphGenerator.generateSmallWorldGraph(500, 10, 0.1);- Implement the algorithm in
src/algorithms/ - Create a benchmark class in
src/experiments/ - Add to the main benchmark suite in
GraphAlgorithmBenchmarkVerbose.java - Update visualization scripts to include the new algorithm
Enable detailed memory tracking by setting:
PerformanceMetrics.setDetailedMemoryTracking(true);We welcome contributions to enhance this benchmark suite!
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Additional graph algorithms (e.g., Floyd-Warshall, Kruskal's)
- New graph generation models
- Enhanced visualization techniques
- Performance optimization
- Documentation improvements
Please use the GitHub issue tracker to report bugs or suggest enhancements.
This project is licensed under the MIT License - see the LICENSE file for details.# graph-algorithms-benchmark