OKlibrary  0.2.1.6
demo_read_graph.cpp
Go to the documentation of this file.
00001 // Oliver Kullmann, 23.11.2007 (Swansea)
00002 /* Copyright 2007 Oliver Kullmann
00003 This file is part of the OKlibrary. OKlibrary is free software; you can redistribute
00004 it and/or modify it under the terms of the GNU General Public License as published by
00005 the Free Software Foundation and included in this library; either version 3 of the
00006 License, or any later version. */
00007 
00028 #include <iostream>
00029 #include <string>
00030 
00031 #include <boost/graph/graphviz.hpp>
00032 #include <boost/graph/adjacency_list.hpp>
00033 #include <boost/property_map/dynamic_property_map.hpp>
00034 
00035 namespace {
00036 
00037   template <class Graph>
00038   struct process {
00039     Graph g;
00040     boost::dynamic_properties p;
00041     process() {
00042       p.property("node_id", get(boost::vertex_name, g));
00043       boost::read_graphviz(std::cin, g, p);
00044       std::cout << num_vertices(g) << ", " << num_edges(g) << "\n";
00045       boost::write_graphviz_dp(std::cout, g, p); 
00046     }
00047   };
00048 }
00049 
00050 int main(const int argc, const char* const argv[]) {
00051   if (argc == 1) {
00052     typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::undirectedS, boost::property<boost::vertex_name_t, std::string> > Graph;
00053     process<Graph>();
00054   }
00055   else {
00056     typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::directedS, boost::property<boost::vertex_name_t, std::string> > Graph;
00057     process<Graph>();
00058   }
00059 }
00060