~ubuntu-branches/ubuntu/wily/deal.ii/wily-proposed

« back to all changes in this revision

Viewing changes to contrib/boost/include/boost/graph/detail/read_graphviz_new.hpp

  • Committer: Bazaar Package Importer
  • Author(s): Adam C. Powell, IV, Adam C. Powell, IV, Denis Barbier
  • Date: 2010-07-29 13:47:01 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20100729134701-qk60t2om7u7oklkb
Tags: 6.3.1-1
[ Adam C. Powell, IV ]
* Changed to source format 3.0 (quilt).
* Changed maintainer to debian-science with Adam Powell as uploader.
* Added source lintian overrides about Adam Powell's name.
* Added Vcs info on git repository.
* Bumped Standards-Version.
* Changed stamp-patch to patch target and fixed its application criterion.
* Moved make_dependencies and expand_instantiations to a versioned directory
  to avoid shlib package conflicts.

[ Denis Barbier ]
* New upstream release (closes: #562332).
  + Added libtbb support.
  + Forward-ported all patches.
* Updates for new PETSc version, including workaround for different versions
  of petsc and slepc.
* Add debian/watch.
* Update to debhelper 7.
* Added pdebuild patch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright 2004-9 Trustees of Indiana University
 
2
 
 
3
// Distributed under the Boost Software License, Version 1.0.
 
4
// (See accompanying file LICENSE_1_0.txt or copy at
 
5
// http://www.boost.org/LICENSE_1_0.txt)
 
6
 
 
7
//
 
8
// read_graphviz_new.hpp - 
 
9
//   Initialize a model of the BGL's MutableGraph concept and an associated
 
10
//  collection of property maps using a graph expressed in the GraphViz
 
11
// DOT Language.  
 
12
//
 
13
//   Based on the grammar found at:
 
14
//   http://www.graphviz.org/cvs/doc/info/lang.html
 
15
//
 
16
//   Jeremiah rewrite used grammar found at:
 
17
//   http://www.graphviz.org/doc/info/lang.html
 
18
//   and page 34 or http://www.graphviz.org/pdf/dotguide.pdf
 
19
//
 
20
//   See documentation for this code at: 
 
21
//     http://www.boost.org/libs/graph/doc/read-graphviz.html
 
22
//
 
23
 
 
24
// Author: Jeremiah Willcock
 
25
//         Ronald Garcia
 
26
//
 
27
 
 
28
#ifndef BOOST_READ_GRAPHVIZ_NEW_HPP
 
29
#define BOOST_READ_GRAPHVIZ_NEW_HPP
 
30
 
 
31
#include <boost/ref.hpp>
 
32
#include <boost/property_map/dynamic_property_map.hpp>
 
33
#include <boost/graph/graph_traits.hpp>
 
34
#include <boost/detail/workaround.hpp>
 
35
#include <algorithm>
 
36
#include <string>
 
37
#include <vector>
 
38
#include <set>
 
39
#include <utility>
 
40
#include <map>
 
41
#include <iostream>
 
42
#include <cstdlib>
 
43
 
 
44
namespace boost {
 
45
 
 
46
namespace read_graphviz_detail {
 
47
  typedef std::string node_name;
 
48
  typedef std::string subgraph_name;
 
49
 
 
50
  typedef std::map<std::string, std::string> properties;
 
51
 
 
52
  struct node_and_port {
 
53
    node_name name;
 
54
    std::string angle; // Or empty if no angle
 
55
    std::vector<std::string> location; // Up to two identifiers
 
56
 
 
57
    friend inline bool operator==(const node_and_port& a, const node_and_port& b) {
 
58
      return a.name == b.name &&
 
59
             a.angle == b.angle &&
 
60
             a.location == b.location;
 
61
    }
 
62
 
 
63
    friend inline bool operator<(const node_and_port& a, const node_and_port& b) {
 
64
      if (a.name != b.name) return a.name < b.name;
 
65
      if (a.angle != b.angle) return a.angle < b.angle;
 
66
      return a.location < b.location;
 
67
    }
 
68
  };
 
69
 
 
70
  struct edge_info {
 
71
    node_and_port source;
 
72
    node_and_port target;
 
73
    properties props;
 
74
  };
 
75
 
 
76
  struct parser_result {
 
77
    bool graph_is_directed;
 
78
    bool graph_is_strict;
 
79
    std::map<node_name, properties> nodes; // Global set
 
80
    std::vector<edge_info> edges;
 
81
    std::map<subgraph_name, properties> graph_props; // Root and subgraphs
 
82
  };
 
83
 
 
84
  // The actual parser, from libs/graph/src/read_graphviz_new.cpp
 
85
  void parse_graphviz_from_string(const std::string& str, parser_result& result, bool want_directed);
 
86
 
 
87
  // Translate from those results to a graph
 
88
  void translate_results_to_graph(const parser_result& r, ::boost::detail::graph::mutate_graph* mg);
 
89
 
 
90
} // namespace read_graphviz_detail
 
91
 
 
92
// This is also in boost/graph/graphviz.hpp
 
93
namespace detail {
 
94
  namespace graph {
 
95
    BOOST_GRAPH_DECL bool read_graphviz(const std::string& str, boost::detail::graph::mutate_graph* mg);
 
96
  } // end namespace graph
 
97
} // end namespace detail
 
98
 
 
99
template <typename MutableGraph>
 
100
bool read_graphviz(const std::string& str,
 
101
                   MutableGraph& graph, boost::dynamic_properties& dp,
 
102
                   std::string const& node_id = "node_id") {
 
103
  boost::detail::graph::mutate_graph_impl<MutableGraph> mg(graph, dp, node_id);
 
104
  return detail::graph::read_graphviz(str, &mg);
 
105
}
 
106
 
 
107
template <typename InputIter, typename MutableGraph>
 
108
bool read_graphviz(InputIter begin, InputIter end,
 
109
                   MutableGraph& graph, boost::dynamic_properties& dp,
 
110
                   std::string const& node_id = "node_id") {
 
111
  return read_graphviz(std::string(begin, end), graph, dp, node_id);
 
112
}
 
113
 
 
114
} // namespace boost
 
115
 
 
116
#endif // BOOST_READ_GRAPHVIZ_NEW_HPP