fork download
  1. #include <boost\graph\adjacency_list.hpp>
  2. #include <boost\graph\astar_search.hpp>
  3. #include <cassert>
  4. #include <iostream>
  5.  
  6. typedef boost::adjacency_list<boost::listS, boost::vecS, boost::directedS> mygraph_t;
  7.  
  8.  
  9. struct Goal_Found_Ex {};
  10.  
  11. template<class Vertex>
  12. struct astar_vis : public boost::default_astar_visitor
  13. {
  14. astar_vis(Vertex goal)
  15. : m_goal(goal)
  16. { }
  17.  
  18. template<typename Graph>
  19. void examine_vertex(Vertex v, Graph const& g)
  20. {
  21. if ( v == m_goal )
  22. throw Goal_Found_Ex();
  23. }
  24.  
  25. Vertex m_goal;
  26. };
  27.  
  28. int main()
  29. {
  30. mygraph_t graph;
  31.  
  32. mygraph_t::vertex_descriptor aVertex = boost::add_vertex(graph);
  33. mygraph_t::vertex_descriptor bVertex = boost::add_vertex(graph);
  34.  
  35. mygraph_t::edge_descriptor edge; bool success;
  36. boost::tie(edge, success) = boost::add_edge(aVertex, bVertex, graph);
  37. assert(success);
  38.  
  39.  
  40. try {
  41. boost::astar_search(graph, aVertex, boost::astar_heuristic<mygraph_t, double>(),
  42. boost::visitor(astar_vis<mygraph_t::vertex_descriptor>(aVertex)));
  43. }
  44. catch(Goal_Found_Ex gf)
  45. {
  46. gf;
  47. std::cout << "Way found" << std::endl;
  48. return 0x0;
  49. }
  50.  
  51. std::cout << "Way not found" << std::endl;
  52. return 0x1;
  53. }
  54.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:1:42: fatal error: boost\graph\adjacency_list.hpp: No such file or directory
compilation terminated.
stdout
Standard output is empty