read_graphviz_spirit.cpp 1.18 KB
Newer Older
Tiago Peixoto's avatar
Tiago Peixoto committed
1
2
3
4
5
6
7
// Copyright 2004-5 Trustees of Indiana University

// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

//
8
// read_graphviz_spirit.hpp - 
Tiago Peixoto's avatar
Tiago Peixoto committed
9
10
//   Initialize a model of the BGL's MutableGraph concept and an associated
//  collection of property maps using a graph expressed in the GraphViz
11
// DOT Language.  
Tiago Peixoto's avatar
Tiago Peixoto committed
12
13
14
15
//
//   Based on the grammar found at:
//   http://www.graphviz.org/cvs/doc/info/lang.html
//
16
//   See documentation for this code at: 
Tiago Peixoto's avatar
Tiago Peixoto committed
17
18
19
20
21
22
//     http://www.boost.org/libs/graph/doc/read-graphviz.html
//

// Authors: Ronald Garcia and Douglas Gregor
//

23
24
#define BOOST_GRAPH_SOURCE

Tiago Peixoto's avatar
Tiago Peixoto committed
25
26
27
28
#ifndef BOOST_GRAPH_READ_GRAPHVIZ_ITERATORS
#  define BOOST_GRAPH_READ_GRAPHVIZ_ITERATORS
#endif
#include <boost/graph/graphviz.hpp>
29
#include <iostream>
Tiago Peixoto's avatar
Tiago Peixoto committed
30

31
namespace boost { namespace detail { namespace graph { 
Tiago Peixoto's avatar
Tiago Peixoto committed
32

33

34
35
BOOST_GRAPH_DECL
bool read_graphviz(std::istream& in, mutate_graph& graph) 
Tiago Peixoto's avatar
Tiago Peixoto committed
36
37
38
39
40
{
  using namespace boost;

  typedef std::istream_iterator<char> is_t;

41
  std::string str((is_t(in)), is_t());
Tiago Peixoto's avatar
Tiago Peixoto committed
42

43
  return read_graphviz(str, &graph);
Tiago Peixoto's avatar
Tiago Peixoto committed
44
45
46
}

} } } // end namespace boost::detail::graph