• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //=======================================================================
2 // Copyright 1997, 1998, 1999, 2000 University of Notre Dame.
3 // Author: Jeremy G. Siek
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/config.hpp>
10 #include <iostream>
11 #include <boost/graph/adjacency_matrix.hpp>
12 #include <boost/graph/graph_utility.hpp>
13 
main()14 int main()
15 {
16     using namespace boost;
17     enum
18     {
19         A,
20         B,
21         C,
22         D,
23         E,
24         F,
25         N
26     };
27     const char* name = "ABCDEF";
28 
29     // A directed graph
30 
31     typedef adjacency_matrix< directedS > Graph;
32     Graph g(N);
33     add_edge(B, C, g);
34     add_edge(B, F, g);
35     add_edge(C, A, g);
36     add_edge(C, C, g);
37     add_edge(D, E, g);
38     add_edge(E, D, g);
39     add_edge(F, A, g);
40 
41     std::cout << "vertex set: ";
42     print_vertices(g, name);
43     std::cout << std::endl;
44 
45     std::cout << "edge set: ";
46     print_edges(g, name);
47     std::cout << std::endl;
48 
49     std::cout << "out-edges: " << std::endl;
50     print_graph(g, name);
51     std::cout << std::endl;
52 
53     // An undirected graph
54 
55     typedef adjacency_matrix< undirectedS > UGraph;
56     UGraph ug(N);
57     add_edge(B, C, ug);
58     add_edge(B, F, ug);
59     add_edge(C, A, ug);
60     add_edge(D, E, ug);
61     add_edge(F, A, ug);
62 
63     std::cout << "vertex set: ";
64     print_vertices(ug, name);
65     std::cout << std::endl;
66 
67     std::cout << "edge set: ";
68     print_edges(ug, name);
69     std::cout << std::endl;
70 
71     std::cout << "incident edges: " << std::endl;
72     print_graph(ug, name);
73     std::cout << std::endl;
74     return 0;
75 }
76