ayns01 / dijkstra-algorithm

Dijkstra Algorithm using LinkedList in C

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Dijkstra Algorithm using Data Structure in C

Implementing a solution for the shortest path problem using Dijkstra algorithm

Condition

a.The node of the graph is not going to be more than 20.

b.The names of the nodes are Englishalphabets (Uppercase) like A,B,...

c.The distance between two nodes is greater than Zero.

d.Use 3200 as the infinity number.

Getting Input

It assumes these input below

int getNumberOfNodes()
{ 
    return 6;
}
int getNumberOfEdges()
{ 
    return 9; 
}
char* getNodes()
{ 
    return "A,B,C,D,E,F"; //these are the nodes of the graph!
}
char* getEdges()
{ 
    return "A_B_1,A_C_2,B_C_4,B_D_5,C_E_3,D_E_2,D_F_4,E_B_2,E_F_6"; 
}

ImgDijkstra

Defining Structure

struct Edge
{
    int distance;
    struct Node *to;
    struct Edge *next;
};

struct Node
{
    int visited;
    char name;
    int cost;
    struct Node *from;
    struct Edge *edge;
    struct Node *next;
};

struct Node

structure-Node

structure-Node-next

struct Edge

structure-Edge

About

Dijkstra Algorithm using LinkedList in C


Languages

Language:C 100.0%