summaryrefslogtreecommitdiff
path: root/ot/lp/EMD_wrapper.cpp
diff options
context:
space:
mode:
authorarolet <antoine.rolet@gmail.com>2017-07-21 12:12:21 +0900
committerarolet <antoine.rolet@gmail.com>2017-07-21 12:12:21 +0900
commitdc3bbd4134f0e2b80e0fe72368bdcf9966f434dc (patch)
tree00c58d3024e1b40c9d285148e9827d5dced64703 /ot/lp/EMD_wrapper.cpp
parent1fcb7d0ffbc5b00ed20b5ded2e7f1001dc914d6e (diff)
Cleaned optimal plan and optimal cost computation
Diffstat (limited to 'ot/lp/EMD_wrapper.cpp')
-rw-r--r--ot/lp/EMD_wrapper.cpp13
1 files changed, 6 insertions, 7 deletions
diff --git a/ot/lp/EMD_wrapper.cpp b/ot/lp/EMD_wrapper.cpp
index d719c6e..cc13230 100644
--- a/ot/lp/EMD_wrapper.cpp
+++ b/ot/lp/EMD_wrapper.cpp
@@ -93,14 +93,13 @@ void EMD_wrap(int n1, int n2, double *X, double *Y,
}
} else
{
- for (node_id_type i=0; i<n; i++)
- {
- for (node_id_type j=0; j<m; j++)
- {
- *(G+indI[i]*n2+indJ[j]) = net.flow(di.arcFromId(i*m+j));
- }
- };
*cost = net.totalCost();
+ Arc a; di.first(a);
+ for (; a != INVALID; di.next(a)) {
+ int i = di.source(a);
+ int j = di.target(a);
+ *(G+indI[i]*n2+indJ[j-n]) = net.flow(a);
+ }
};