Skip to main content

Posts

Bellmanford Algorithm C++ Program

The  Bellman–Ford algorithm  is an  algorithm  that computes  shortest paths  from a single source  vertex  to all of the other vertices in a  weighted digraph . It is slower than  Dijkstra's algorithm  for the same problem, but more versatile, as it is capable of handling graphs in which some of the edge weights are negative numbers. Here is the Source Code: #include<iostream> #include<stdio.h> using namespace std; #include<conio.h> #define INFINITY 999 struct node {     int cost;     int value;     int from; }a[5]; void addEdge(int am[][5],int src,int dest,int cost) {      am[src][dest] = cost;      return; } void bell(int am[][5]) {     int i, j, k, c = 0, temp;     a[0].cost = 0;     a[0].from = 0;     a[0].value = 0;     for (i = 1; i < 5; i++)     {         a[i].from = 0;         a[i].cost = INFINITY;         a[i].value = 0;     }     while (c < 5)     {         int min = 999;         for (i = 0; i < 5; i+
Recent posts

C++ Program for Circular Doubly Linked List

Today we are gonna tell you the C++ Program to demonstrate circular doubly linked list. The C++ program is successfully compiled and runs on any system.  Here is the code : #include<iostream> #include<cstdio> #include<cstdlib> using namespace std ;   /*  * Node Declaration  */ struct node { int info ; struct node * next ; struct node * prev ; } * start, * last ; int counter = 0 ; /*  * Class Declaration  */ class double_clist { public : node * create_node ( int ) ; void insert_begin ( ) ; void insert_last ( ) ; void insert_pos ( ) ; void delete_pos ( ) ; void search ( ) ; void update ( ) ; void display ( ) ; void reverse ( ) ; void sort ( ) ; double_clist ( ) { start = NULL ; last = NULL ; } } ;   /*  * Main: