// vim: set cindent
// vim: ts=4 sw=4 et tw=0 wm=0
#include "shortest_paths.h"
#include <float.h>
#include <cassert>
#include <iostream>
using namespace std;
namespace shortest_paths {
// O(n^3) time. Slow, but fool proof. Use for testing.
void floyd_warshall(
unsigned n,
double** D,
double* eweights)
{
for(unsigned i=0;i<n;i++) {
for(unsigned j=0;j<n;j++) {
if(i==j) D[i][j]=0;
else D[i][j]=DBL_MAX;
}
}
assert(u<n&&v<n);
D[u][v]=D[v][u]=eweights[i];
}
for(unsigned k=0; k<n; k++) {
for(unsigned i=0; i<n; i++) {
for(unsigned j=0; j<n; j++) {
D[i][j]=min(D[i][j],D[i][k]+D[k][j]);
}
}
}
}
}
}
static void dijkstra(
unsigned s,
unsigned n,
double* d)
{
assert(s<n);
for(unsigned i=0;i<n;i++) {
}
vs[s].d=0;
for(unsigned i=0;i<n;i++) {
}
while(!Q.isEmpty()) {
Node *u=Q.extractMin();
d[u->id]=u->d;
for(unsigned i=0;i<u->neighbours.size();i++) {
Node *v=u->neighbours[i];
double w=u->nweights[i];
if(v->d>u->d+w) {
v->p=u;
v->d=u->d+w;
Q.decreaseKey(v->qnode,v);
}
}
}
}
void dijkstra(
unsigned s,
unsigned n,
double* d,
double* eweights)
{
assert(s < n);
}
void johnsons(
unsigned n,
double** D,
double* eweights)
{
for (unsigned k = 0; k < n; k++) {
}
}
}