Does this code look like a proper dijkstra's algorithm and what am I doing wrong?
Code:
/* dijkstra's algorithm in in c language */
#include <stdio.h>
#include <cstdlib.h>
#include <graph.h>
#include <math.h>
#define IN=1000000
#define N 6
int main() {
int i, j, w;
cost[i][j];
cost[u][j]-cost[i][j]=e;
cost[i+1][j+1]-cost[i][j]=w
cost();
/* edge 0-1 */
cost[0].i= 0
cost[0].u=1
cost[0].w=1
/* edge 1-2 */
cost[1[.i=1
cost[1].u=2
cost[1].w=3
/* edge 1-3 */
cost[2].i=1
cost[2].u=3
cost[2].w=4
/* edge 2-4 */
cost[3].i=2
cost[3].u=4
cost[3].w=1
/* edge 3-5 */
cost[4].i=3
cost[4].u=5
cost[4].w=2
/* edge 4-6 */
cost[5].i=4
cost[5].u=6
cost[5].w=6
/* edge 3-4 */
cost[6].i=3
cost[6].u=4
cost[6].w=5
return cost;
}
int deletingfromqueue(){
adjacent();
if(visited>0){
u=visited[u];
visited=visited[i]-visited[u]
visited[i]=dist[i][j]
compare();
show();
if(cost[u]-cost[i]=w){
for(i=1; i<=N-1; i++){
for(j=1; j<=N; j++)
cost[i][j]=cost[i+1][j+1];
}
N--
}
}
typedef struct{
int i, u
int w
}e;
bool compare(const void *i, const void *u){
x=i
x1=u
if(i -> w < u ->w)
return -1;
if(i-> w < u-> w)
return 1;
return (0);
}
int cost(){
dist();
int visited[N], memset(visited, 0, sizeof(visited));
cost[i][j]=cost[6][6]
int i, j;
adjacent();
printf("Enter the elements\n", i+1, j+1);
scanf("%d", &cost[i][j])
printf("Enter number of nodes\n")
scanf("%d", &N)
counter=malloc(sizeof(int*) *N);
visited=malloc(sizeof(int*) *deletingfromqueue);
for(i=0; i<N; N++){
for(j=0; j<N; j++){
scanf("%d", &cost[i][j])
if(cost[i][j]=0){
cost[i][j]= IN
visited[i]=0
}
}
}
if(N>0; N++){
counter++
}
int dist(){
dist[i]= IN
prior[i]= -1
printf("Enter starting node\n")
scanf("%d", &u);
cost();
if(cost[i][j]=cost[i+1][j]){
N= N-1
}
startnode=u;
for(i=0; i<N; i++){
for(j=0; j<N; j++){
dist[i]=0
adjacent();
cost[i][j]= adjacent(u,i)
N--
prio[i]= prior[i+1];
counter++;
for (p=0; p<N; p++){
if(cost[i][p] > cost[i][j]){
cost[i][p]= cost[i][j] + w
}
}
}
int adjacent(){
int i=0;
for(i=0; i<N; i++){
if(!visited[i]&&dist[i] > dist[u]){
dist[i]+cost[v][i]=dist[i]
}
if(dist>dist[i]&&visited[i]){
dist=dist[i]
prior=1
visited[i]=1
}
if(cost[0][i]&&!visited[i]{
if(dist[v]+dist[i]<dist[i]+w){
if(!dist[v]=prior++&&dist[i]+w){
if(dist[v] < dist[w]){
dist[w]= dist[i]+cost[w];
dist[w]=dist[i];
deletingfromqueue();
qsort();
}
}
}
}
int qsort(cost, N, sizeof(int), (*compare), (const void *i, const void *u)){
cost[u][j]>cost[i][j]
e=edge
h=0
if(e->i < h->i)
return -1;
else if(e->i > h->i)
return 1;
else if(e->u < h->u)
return -1;
else
return(e->u > h->u)
show();
}
int show(){
int i, j;
for(i=1; i<N=N; i++){
for(j=1; j<=N; j++){
printf("%d", cost[i][j]);
}
}
return dist;