Revision 20756421 custompackages/graph-parser/src/utility.cpp

View differences:

custompackages/graph-parser/src/utility.cpp
5 5
#include "utility.h"
6 6
using namespace boost;
7 7

  
8
void printGraph(Graph &g) {
9
    typename boost::graph_traits<Graph>::out_edge_iterator out_i, out_ie;
10
    Viter v_i, v_ie;
11

  
12
    Vertex v;
13
    Edge e;
14

  
15
    boost::tie(v_i, v_ie) = boost::vertices(g);
16
    for (v_i; v_i != v_ie; ++v_i) {
17
        v = *v_i;
18
        boost::tie(out_i, out_ie) = boost::out_edges(v, g);
19

  
20
        for (out_i; out_i != out_ie; ++out_i) {
21
            e = *out_i;
22
            Vertex src = boost::source(e, g);
23
            Vertex targ = boost::target(e, g);
24
            std::cout << "(" << g[src].id << ","
25
            << g[targ].id << ") ";
26
        }
27
        cout << endl;
28
    }
29
}
30

  
31 8
/* outops namespace */
32 9
namespace outops {
33
    std::ostream& operator<<(std::ostream& os, const Graph& g)
34
    {
10
    std::ostream& operator<<(std::ostream& os, const Graph& g) {
35 11
        os <<   "Graph has: \n"
36 12
                "---------- " << boost::num_vertices(g) << " vertices\n"
37 13
                "---------- " << boost::num_edges(g) << " edges\n";
......
86 62
        return os;
87 63
    }
88 64

  
89
    std::ostream& operator<<(std::ostream& os, const std::map<string, int>& m)
90
    {
65
    std::ostream& operator<<(std::ostream& os, const std::map<string, int>& m) {
91 66
        // similar to printhelper::for_map()
92 67
        os << "cout << std::map\n";
93 68
        std::map<string, int>::const_iterator iter;

Also available in: Unified diff