| 889 | } |
| 890 | |
| 891 | void test_inf() |
| 892 | { |
| 893 | graph<double,double>::kernel_1a_c g; |
| 894 | g.set_number_of_nodes(4); |
| 895 | g.add_edge(0,1); |
| 896 | g.add_edge(1,2); |
| 897 | g.add_edge(2,3); |
| 898 | g.add_edge(3,0); |
| 899 | |
| 900 | g.node(0).data = std::numeric_limits<double>::infinity(); |
| 901 | g.node(1).data = -std::numeric_limits<double>::infinity(); |
| 902 | g.node(2).data = std::numeric_limits<double>::infinity(); |
| 903 | g.node(3).data = -std::numeric_limits<double>::infinity(); |
| 904 | |
| 905 | edge(g,0,1) = 1; |
| 906 | edge(g,1,2) = 1; |
| 907 | edge(g,2,3) = 1; |
| 908 | edge(g,3,0) = 1; |
| 909 | |
| 910 | std::vector<node_label> labels; |
| 911 | find_max_factor_graph_potts(g, labels); |
| 912 | |
| 913 | DLIB_TEST(labels[0] != 0); |
| 914 | DLIB_TEST(labels[1] == 0); |
| 915 | DLIB_TEST(labels[2] != 0); |
| 916 | DLIB_TEST(labels[3] == 0); |
| 917 | |
| 918 | // -------------------------- |
| 919 | |
| 920 | g.node(0).data = std::numeric_limits<double>::infinity(); |
| 921 | g.node(1).data = 0; |
| 922 | g.node(2).data = 0; |
| 923 | g.node(3).data = -3; |
| 924 | |
| 925 | edge(g,0,1) = 1; |
| 926 | edge(g,1,2) = 1; |
| 927 | edge(g,2,3) = 1; |
| 928 | edge(g,3,0) = 1; |
| 929 | |
| 930 | find_max_factor_graph_potts(g, labels); |
| 931 | |
| 932 | DLIB_TEST(labels[0] != 0); |
| 933 | DLIB_TEST(labels[1] != 0); |
| 934 | DLIB_TEST(labels[2] != 0); |
| 935 | DLIB_TEST(labels[3] == 0); |
| 936 | |
| 937 | // -------------------------- |
| 938 | |
| 939 | g.node(0).data = std::numeric_limits<double>::infinity(); |
| 940 | g.node(1).data = 0; |
| 941 | g.node(2).data = 0; |
| 942 | g.node(3).data = -0.1; |
| 943 | |
| 944 | edge(g,0,1) = 1; |
| 945 | edge(g,1,2) = 1; |
| 946 | edge(g,2,3) = 1; |
| 947 | edge(g,3,0) = 1; |
| 948 |
no test coverage detected