Skip to content

A comprehensive Java project benchmarking classical graph algorithms (BFS, DFS, Dijkstra, Bellman-Ford, A*, Max Flow, Bipartite Check) on various graph sizes and densities. Includes result analysis with Python plots and an interactive Streamlit dashboard to visualize algorithm performance.

Notifications You must be signed in to change notification settings

harsharajkumar/graph-algorithms-benchmark

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

39 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Graph Algorithms Benchmark

Java Python Streamlit License

πŸ“Š Overview

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.

πŸš€ Features

Implemented Algorithms

  • Traversal Algorithms: BFS, DFS
  • Shortest Path Algorithms: Dijkstra, Bellman-Ford, A* Search
  • Flow Algorithms: Maximum Flow (Edmonds-Karp)
  • Graph Property Algorithms: Bipartite Graph Check

Benchmarking Capabilities

  • 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

Visualization & Analysis

  • Python analysis scripts with Matplotlib/Seaborn
  • Interactive Streamlit dashboard
  • Comparative performance charts
  • Scalability analysis across graph sizes
  • Memory-Runtime tradeoff visualizations

πŸ›  Installation

Prerequisites

  • Java 17 or higher
  • Python 3.8 or higher
  • Maven (for dependency management)

Clone the Repository

git clone https://github.com/harsharajkumar/graph-algorithms-benchmark.git
cd graph-algorithms-benchmark

Java Setup

Compile the Java source files:

javac -d bin src/algorithms/*.java src/utils/*.java src/experiments/*.java

Alternatively, use Maven to build the project:

mvn clean compile

Python Dependencies

Install required Python packages for analysis:

pip install -r analysis/requirements.txt

πŸ“– Usage

Running Java Benchmarks

Execute the comprehensive benchmark suite:

java -cp bin experiments.GraphAlgorithmBenchmarkVerbose

Run specific algorithm tests:

# Test BFS performance
java -cp bin experiments.BFSBenchmark

# Test Dijkstra performance
java -cp bin experiments.DijkstraBenchmark

Configuration Options

Modify config/benchmark.properties to customize:

  • Graph sizes (number of nodes)
  • Graph densities (edge probabilities)
  • Number of test iterations
  • Output file locations

Python Analysis

Generate performance visualizations:

python analysis/bench_analysis.py

Streamlit Dashboard

Launch the interactive dashboard:

streamlit run analysis/streamlit_app.py

πŸ“ˆ Results & Visualizations

Performance Analysis

maxflow_flow_vs_runtime memory_vs_runtime runtime_vs_density runtime_vs_nodes

Key Findings

  • 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

πŸŽ› Streamlit Dashboard

The interactive dashboard provides real-time exploration of algorithm performance metrics.

Screenshot 2025-08-20 at 3 35 31β€―PM

Interactive dashboard for exploring algorithm performance

Dashboard Features

  • Dynamic filtering by algorithm and graph type
  • Interactive performance charts
  • Side-by-side algorithm comparisons
  • Export functionality for results
  • Configurable display options

πŸ“ Project Structure

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

πŸ”§ Advanced Configuration

Custom Graph Generation

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);

Adding New Algorithms

  1. Implement the algorithm in src/algorithms/
  2. Create a benchmark class in src/experiments/
  3. Add to the main benchmark suite in GraphAlgorithmBenchmarkVerbose.java
  4. Update visualization scripts to include the new algorithm

Memory Profiling

Enable detailed memory tracking by setting:

PerformanceMetrics.setDetailedMemoryTracking(true);

🀝 Contributing

We welcome contributions to enhance this benchmark suite!

How to Contribute

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Areas for Contribution

  • Additional graph algorithms (e.g., Floyd-Warshall, Kruskal's)
  • New graph generation models
  • Enhanced visualization techniques
  • Performance optimization
  • Documentation improvements

Reporting Issues

Please use the GitHub issue tracker to report bugs or suggest enhancements.

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.# graph-algorithms-benchmark

About

A comprehensive Java project benchmarking classical graph algorithms (BFS, DFS, Dijkstra, Bellman-Ford, A*, Max Flow, Bipartite Check) on various graph sizes and densities. Includes result analysis with Python plots and an interactive Streamlit dashboard to visualize algorithm performance.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published