labeled_graph.cpp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. // (C) Copyright 2009 Andrew Sutton
  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. /*
  7. IMPORTANT!!!
  8. ~~~~~~~~~~~~
  9. This example does not compile, see https://github.com/boostorg/graph/issues/147
  10. */
  11. #include <iostream>
  12. #include <string>
  13. #include <boost/graph/directed_graph.hpp>
  14. #include <boost/graph/labeled_graph.hpp>
  15. using namespace boost;
  16. using namespace std;
  17. int main() {
  18. using namespace boost::graph_detail;
  19. typedef directed_graph<> Digraph;
  20. {
  21. typedef labeled_graph<Digraph, unsigned> Graph;
  22. Graph g;
  23. add_vertex(1, g);
  24. add_vertex(2, g);
  25. Graph h(12);
  26. }
  27. {
  28. typedef labeled_graph<Digraph, string> Graph;
  29. Graph g;
  30. add_vertex("foo", g);
  31. add_vertex("bar", g);
  32. }
  33. {
  34. typedef labeled_graph<Digraph, string, mapS> Graph;
  35. Graph g;
  36. add_vertex("foo", g);
  37. add_vertex("bar", g);
  38. add_vertex("foo", g);
  39. }
  40. {
  41. typedef labeled_graph<Digraph*, int> TempGraph;
  42. Digraph g;
  43. TempGraph h(&g);
  44. add_vertex(12, h);
  45. }
  46. {
  47. // This is actually a fairly complicated specialization.
  48. typedef adjacency_list<vecS, vecS, bidirectionalS> G;
  49. typedef labeled_graph<G, size_t> Graph;
  50. Graph g;
  51. add_vertex(0, g);
  52. add_vertex(1, g);
  53. g.add_edge(0, 1);
  54. }
  55. return 0;
  56. }