-
Notifications
You must be signed in to change notification settings - Fork 33
/
test_wrapper.cpp
61 lines (49 loc) · 1.31 KB
/
test_wrapper.cpp
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include "cgco.h"
#include <stdio.h>
int main()
{
int handle;
int unary[4][3] = {
{2, 8, 8},
{7, 3, 7},
{8, 8, 2},
{6, 4, 6}
};
int edge1[3] = {0, 1, 2};
int edge2[3] = {1, 2, 3};
int edge_weight[3] = {3, 10, 1};
int smooth_cost[3][3] = {
{0, 1, 1},
{1, 0, 1},
{1, 1, 0}
};
int n_sites = 4, n_labels = 3, n_edges = 3;
int labels[3] = {0};
long long energy = 0;
int i = 0;
int handle2;
gcoCreateGeneralGraph(n_sites, n_labels, &handle);
gcoCreateGeneralGraph(10, 20, &handle2);
gcoDestroyGraph(handle2);
gcoSetDataCost(handle, (int*)unary);
gcoSetAllNeighbors(handle, edge1, edge2, edge_weight, n_edges);
gcoSetSmoothCost(handle, (int*)smooth_cost);
/*
unary[0][0] = 12345;
unary[1][0] = 23456;
unary[2][0] = 78903;
unary[3][0] = 11111;
*/
gcoExpansion(handle, 10, &energy);
gcoGetLabels(handle, labels);
printf("labels = [ ");
for (i = 0; i < n_sites; i++)
printf("%d ", labels[i]);
printf("], energy=%lld\n", energy);
gcoComputeDataEnergy(handle, &energy);
printf("data energy=%lld, ", energy);
gcoComputeSmoothEnergy(handle, &energy);
printf("smooth energy=%lld\n", energy);
gcoDestroyGraph(handle);
return 0;
}