Program Shortest Path using Kruskal algorithm in cpp

The following program illustrates Kruskal algorithm in cpp to find Shortest Path.   #include <iostream.h> #include <graphics.h> #include <string.h> #include <stdlib.h> #include <conio.h> #define MAX_VERTICES 10 #define MAX_EDGES 15 /*************************************************************************/ //——————————- Vertex ——————————// /*************************************************************************/ class Vertex { public: int x; int y; int label; private: char Label[5]; public: Vertex( ) { } ~Vertex( ) { … Read more

Program for Shortest path using Dijkstra Algorithm in c++

The following program illustrates the Shortest Path using Dijkstra Algorithm in C++:   #include <iostream.h> #include <conio.h> #define MAX_NODE 50 struct node{ int vertex; int weight; node *next; }; struct fringe_node{ int vertex; fringe_node *next; }; node *adj[MAX_NODE]; //For storing Adjacency list of totNodes; //No. of Nodes in Graph.constint UNSEEN=1,FRINGE=2,INTREE=3; //status of status[MAX_NODE];//status … Read more

Program to implement Breadth First Search C++

What is Breadth First Search? Breadth first search (BFS) is an algorithm for traversing or searching tree or graph data structures. It starts at the tree root (or some arbitrary node of a graph) and explores the neighbor nodes first, before moving to the next level neighbors. Compare BFS with the equivalent, but more memory-efficient … Read more