forked from motrom/fastmurty
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sspSparse.h
42 lines (33 loc) · 1.01 KB
/
sspSparse.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/**
Michael Motro github.com/motrom/fastmurty 4/2/19
*/
#ifdef SPARSE
#include "subproblem.h"
#include "sparsematrix.h" // cs_di
typedef cs_di inputmatrixtype;
typedef struct Pathtype{
double val;
int i;
int j;
} Pathtype;
typedef struct WorkvarsforSSP {
Pathtype* Q;
int* pathback;
int m;
int n;
} WorkvarsforSSP;
WorkvarsforSSP allocateWorkvarsforSSP(int m, int n);
void deallocateWorkvarsforSSP(WorkvarsforSSP workvars);
/*
Runs the successive shortest paths algorithm to find the best association for a problem.
Returns the total cost of the association.
*/
double SSP(cs_di c, Subproblem* prb, WorkvarsforSSP* workvars);
/*
Runs a single shortest path step to find the best association for a subproblem given the
solution to the originating problem.
Returns the increase in cost between the new and originating solutions.
If the increase in cost is greater than cost_bound, stops early and returns infinity.
*/
double spStep(cs_di c, Subproblem* prb, WorkvarsforSSP* workvars, double cost_bound);
#endif