Hello,
I am trying to run the metric_tsp_approx.cpp example, but I get an error, I am using the suggested data 3 vertices data, I don't know what I am doing wrong, please help.

Vicky.


http://www.boost.org/doc/libs/1_58_0/libs/graph/test/metric_tsp_approx.cpp



$more graph.txt
1,2
20,4
15,7

I get this error:
terminate called after throwing an instance of 'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::negative_edge> >'
  what():  The graph may not contain an edge with negative weight.
Aborted (core dumped)

Its after all the graph is connected:

we can parse the given file
Opened file
1,2
20,4
15,7
Closed file
(1,2) -> (20,4) = 19.105
(1,2) -> (15,7) = 14.8661
(20,4) -> (15,7) = 5.83095
Conected all
terminate called after throwing an instance of 'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::negative_edge> >'
  what():  The graph may not contain an edge with negative weight.
Aborted (core dumped)

This is what I get when doing a backtrace: (shortened)

(gdb) bt
#0  0x00007ffff722bcc9 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
#1  0x00007ffff722f0d8 in __GI_abort () at abort.c:89
#2  0x00007ffff7b36535 in __gnu_cxx::__verbose_terminate_handler() () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#3  0x00007ffff7b346d6 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#4  0x00007ffff7b34703 in std::terminate() () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#5  0x00007ffff7b34922 in __cxa_throw () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#6  0x00000000004085c8 in boost::throw_exception<boost::negative_edge> (e=...) at /usr/include/boost/throw_exception.hpp:67
#7  0x0000000000408b0f in examine_edge<boost...
#8  boost::breadth_first_visit<boost...
    vis=..., color=...) at /usr/include/boost/graph/breadth_first_search.hpp:82
#9  0x00000000004038ec in breadth_first_visit<boost...
    at /usr/include/boost/graph/breadth_first_search.hpp:105
#10 dijkstra_shortest_paths_no_init<...
    (color=..., vis=..., zero=0, combine=..., compare=..., index_map=..., weight=..., distance=..., predecessor=..., s=0, g=...) at /usr/include/boost/graph/dijkstra_shortest_paths.hpp:337
#11 dijkstra_shortest_paths<boost...
    (color=..., vis=..., zero=0, inf=1.7976931348623157e+308, combine=..., compare=..., index_map=..., weight=..., distance=..., predecessor=..., s=0, g=...) at /usr/include/boost/graph/dijkstra_shortest_paths.hpp:388
#12 dijkstra_shortest_paths<boost...
    at /usr/include/boost/graph/dijkstra_shortest_paths.hpp:358
#13 dijkstra_dispatch2<boost...
    at /usr/include/boost/graph/dijkstra_shortest_paths.hpp:431
#14 dijkstra_dispatch1<boost:
    at /usr/include/boost/graph/dijkstra_shortest_paths.hpp:462
#15 dijkstra_shortest_paths<boost...
    params=..., s=0, g=...) at /usr/include/boost/graph/dijkstra_shortest_paths.hpp:480
#16 prim_mst_impl<boost
    at /usr/include/boost/graph/prim_minimum_spanning_tree.hpp:41
#17 boost::prim_minimum_spanning_tree<boost...
     at /usr/include/boost/graph/prim_minimum_spanning_tree.hpp:72
#18 0x0000000000408bb3 in boost::metric_tsp_approx_from_vertex<boost::...
    at /usr/include/boost/graph/metric_tsp_approx.hpp:193
#19 0x0000000000402320 in metric_tsp_approx_tour<boost::...
    o=..., g=...) at /usr/include/boost/graph/metric_tsp_approx.hpp:89
#20 main (argc=<optimized out>, argv=<optimized out>) at metric_tsp_approximation.cpp:249