directed_graph.cpp 1011 B

1234567891011121314151617181920212223242526
  1. //=======================================================================
  2. // Copyright 2012
  3. // Authors: David Doria
  4. //
  5. // Distributed under the Boost Software License, Version 1.0. (See
  6. // accompanying file LICENSE_1_0.txt or copy at
  7. // http://www.boost.org/LICENSE_1_0.txt)
  8. //=======================================================================
  9. #include <boost/graph/directed_graph.hpp> // A subclass to provide reasonable arguments to adjacency_list for a typical directed graph
  10. int main(int,char*[])
  11. {
  12. // directed_graph is a subclass of adjacency_list which gives you object oriented access to functions
  13. // like add_vertex and add_edge, which makes the code easier to understand. However, it hard codes many
  14. // of the template parameters, so it is much less flexible.
  15. typedef boost::directed_graph<> Graph;
  16. Graph g;
  17. boost::graph_traits<Graph>::vertex_descriptor v0 = g.add_vertex();
  18. boost::graph_traits<Graph>::vertex_descriptor v1 = g.add_vertex();
  19. g.add_edge(v0, v1);
  20. return 0;
  21. }