graphs_basics README.md (Markdown)
This repository contains clean and minimal implementations of classical graph algorithms in Java:
- BFS / DFS — basic graph traversals (
graphs_algorithms/) - Dijkstra's Algorithm — shortest path from a single source (
dijkstra_shortest_path/) - Kruskal's Algorithm — Minimum Spanning Tree (
KruskalMST/)
- JDK 17+ (the project uses plain Java, no build tools required)
# 1. Compile all .java files into the out/ folder
mkdir -p out
find src -name "*.java" > sources.txt
javac -encoding UTF-8 -d out @sources.txt
# 2. Run a specific class with a main() method
# Example:
# java -cp out dijkstra_shortest_path.DijkstraNote: Replace the class name above with whichever algorithm’s entry point you want to test (e.g.
graphs_algorithms.BFSGraph).
src/
├─ dijkstra_shortest_path/
│ ├─ Dijkstra.java
│ └─ Node.java
├─ graphs_algorithms/
│ ├─ BFSGraph.java
│ └─ DFSGraph.java
└─ KruskalMST/
├─ Disjointset.java
├─ Edge.java
└─ Kruskal.java
| Algorithm | Time Complexity | Space Complexity |
|---|---|---|
| BFS / DFS | O(V + E) | O(V) |
| Dijkstra (naive) | O(V²) | O(V) |
| Kruskal (Union-Find) | O(E log E) | O(V) |
V = number of vertices, E = number of edges
- Add priority queue implementation for Dijkstra (O((V+E) log V))
- Add other MST algorithms (e.g. Prim)
- Add unit tests and visualization examples
✨ Author: CellaIoana
This project is licensed under the MIT License.
You are free to use, modify, and distribute this code as long as the original copyright notice is included.