Multi-Language Graph Algorithms Suite (C++, Java, Python)
Comprehensive tri-lingual implementation of fundamental graph structures, benchmarking traversal, topological sorting, and shortest paths in C++, Java, and Python.
Project Overview & Architecture
An in-depth comparative software project that implements equivalent graph data structures and algorithmic operations across three distinct programming paradigms: low-level compiled C++17, object-oriented Java 11, and dynamic Python 3. The suite parses unweighted graphs, weighted networks, and Directed Acyclic Graphs (DAGs) from benchmark files to test traversal performance.
Key Implementation Highlights
- ✓Engineered equivalent graph classes across C++ (Graph.cpp), Java (Graph.java), and Python (graph.py).
- ✓Automated file ingestion testing sample1_unweighted.txt, sample2_weighted.txt, and sample3_dag.txt.
- ✓Algorithms implemented: Depth-First Search (DFS), Breadth-First Search (BFS), and DAG topological ordering.
- ✓Comparative runtime profiling and memory allocation analysis across language paradigms.
Implementation Source Code
3 Files123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354#include "Graph.h"
#include <iostream>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
Graph::Graph() {}
Graph::~Graph() {
for (auto& pair : vertices) {
delete pair.second;
}
}
void Graph::addVertex(const string& name) {
if (vertices.find(name) == vertices.end()) {
vertices[name] = new Vertex(name);
}
}
void Graph::addEdge(const string& from, const string& to, int weight) {
if (vertices.find(from) == vertices.end()) addVertex(from);
if (vertices.find(to) == vertices.end()) addVertex(to);
vertices[from]->adjacencyList.push_back(Edge(to, weight));
}
vector<string> Graph::bfs(const string& start, const string& end) {
if (vertices.find(start) == vertices.end() || vertices.find(end) == vertices.end())
return {};
unordered_set<string> visited;
queue<vector<string>> q;
q.push({start});
visited.insert(start);
while (!q.empty()) {
vector<string> path = q.front();
q.pop();
string current = path.back();
if (current == end) return path;
for (const Edge& edge : vertices[current]->adjacencyList) {
if (visited.find(edge.destination) == visited.end()) {
visited.insert(edge.destination);
vector<string> newPath = path;
newPath.push_back(edge.destination);
q.push(newPath);
}
}
}
return {};
}Technologies & Tools
Academic Classification
More in Data Structures, Algorithms & Small Lab Projects
View all in categoryEmergency Room Triage Priority Queue Simulator
Hospital emergency room triage intake simulation that dynamically orders and dispatches patients by clinical acuity scores rather than arrival order.
Shunting-Yard Infix to Postfix Converter & Stack Calculator
Mathematical expression parsing engine that converts standard human-readable arithmetic into Reverse Polish Notation (RPN) and computes results via operand stacks.
Ordered Binary Search Tree (BST) Engine
Self-contained binary search tree data structure supporting logarithmic insertions, key lookups, in-order successor deletions, and recursive traversals.