Shortest Path in an unweighted DAG between 2 nodes
int shortestPath(int i, int j) {
	if (i == j) 
		shortest_path[i][j] = 1;	
	if (!shortest_path[i][j]) {
		int min_path = 10e6;
		for (auto vertice : graph[i])
			min_path = min(min_path, shortestPath(vertice, j) + 1);
		shortest_path[i][j] = min_path;
	}
	return shortest_path[i][j];
}

The above function computes the shortest paths between two nodes in DAG.
Can someone help me calculate the complexity ?

Comments (0)