Tx,

So it seems my implementation is wrong... can you have a glance at some peave of code ?

Code:

#define INF 1000000001

Code:

dijkstra_graph::dijkstra_graph(int i)
: graph(i)
{
d=new unsigned long[i];
pop=new int[i];
D=new bool[i];
D_size=0;
for(int y=0;y<i;y++)
{
pop[y]=-1;
D[y]=false;
d[y]=INF;
}
}

Code:

int dijkstra_graph::shortest_way(int initial_vertex)
{
d[initial_vertex]=0; // step 1
unsigned long min=INF,vertex; // for step 3 (extra)
while(D_size<vertex_number) // step 2
{
for(int i=0;i<vertex_number;i++) // step 3
{
if(D[i]==false)
{
if(d[i]<=min)
{
vertex=i;
min=d[i];
}
}
} // end of step 3
D[vertex]=true; // step 4
increase_D();
for(int i=0;i<vertex_number;i++) // step 5
{
if(edge_u_v(vertex,i)!=-1) // check if edge bettwen vertex and i exists.
{
if( d[i] > d[vertex] + edge_u_v(vertex,i) ) // step 6
{
d[i]=d[vertex] + edge_u_v(vertex,i); // step 7
pop[i]=vertex; // step 8
}
}
} // end of step 5
}
return 0;
}