tiernan_girth_circumference.cpp 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // (C) Copyright Andrew Sutton 2007
  2. //
  3. // Use, modification and distribution are subject to the
  4. // Boost Software License, Version 1.0 (See accompanying file
  5. // LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
  6. //[tiernan_girth_circumference
  7. #include <iostream>
  8. #include <boost/graph/directed_graph.hpp>
  9. #include <boost/graph/tiernan_all_cycles.hpp>
  10. #include "helper.hpp"
  11. using namespace std;
  12. using namespace boost;
  13. // Declare the graph type and its vertex and edge types.
  14. typedef directed_graph<> Graph;
  15. typedef graph_traits<Graph>::vertex_descriptor Vertex;
  16. typedef graph_traits<Graph>::edge_descriptor Edge;
  17. int
  18. main(int argc, char *argv[])
  19. {
  20. // Create the graph and read it from standard input.
  21. Graph g;
  22. read_graph(g, cin);
  23. // Compute the girth and circumference simulataneously
  24. size_t girth, circ;
  25. boost::tie(girth, circ) = tiernan_girth_and_circumference(g);
  26. // Print the result
  27. cout << "girth: " << girth << endl;
  28. cout << "circumference: " << circ << endl;
  29. return 0;
  30. }
  31. //]