Chris@16: // Copyright 2004-9 Trustees of Indiana University Chris@16: Chris@16: // Distributed under the Boost Software License, Version 1.0. Chris@16: // (See accompanying file LICENSE_1_0.txt or copy at Chris@16: // http://www.boost.org/LICENSE_1_0.txt) Chris@16: Chris@16: // Chris@16: // read_graphviz_new.hpp - Chris@16: // Initialize a model of the BGL's MutableGraph concept and an associated Chris@16: // collection of property maps using a graph expressed in the GraphViz Chris@16: // DOT Language. Chris@16: // Chris@16: // Based on the grammar found at: Chris@16: // http://www.graphviz.org/cvs/doc/info/lang.html Chris@16: // Chris@16: // Jeremiah rewrite used grammar found at: Chris@16: // http://www.graphviz.org/doc/info/lang.html Chris@16: // and page 34 or http://www.graphviz.org/pdf/dotguide.pdf Chris@16: // Chris@16: // See documentation for this code at: Chris@16: // http://www.boost.org/libs/graph/doc/read-graphviz.html Chris@16: // Chris@16: Chris@16: // Author: Jeremiah Willcock Chris@16: // Ronald Garcia Chris@16: // Chris@16: Chris@16: #ifndef BOOST_READ_GRAPHVIZ_NEW_HPP Chris@16: #define BOOST_READ_GRAPHVIZ_NEW_HPP Chris@16: Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: Chris@16: namespace boost { Chris@16: Chris@16: namespace read_graphviz_detail { Chris@16: typedef std::string node_name; Chris@16: typedef std::string subgraph_name; Chris@16: Chris@16: typedef std::map properties; Chris@16: Chris@16: struct node_and_port { Chris@16: node_name name; Chris@16: std::string angle; // Or empty if no angle Chris@16: std::vector location; // Up to two identifiers Chris@16: Chris@16: friend inline bool operator==(const node_and_port& a, const node_and_port& b) { Chris@16: return a.name == b.name && Chris@16: a.angle == b.angle && Chris@16: a.location == b.location; Chris@16: } Chris@16: Chris@16: friend inline bool operator<(const node_and_port& a, const node_and_port& b) { Chris@16: if (a.name != b.name) return a.name < b.name; Chris@16: if (a.angle != b.angle) return a.angle < b.angle; Chris@16: return a.location < b.location; Chris@16: } Chris@16: }; Chris@16: Chris@16: struct edge_info { Chris@16: node_and_port source; Chris@16: node_and_port target; Chris@16: properties props; Chris@16: }; Chris@16: Chris@16: struct parser_result { Chris@16: bool graph_is_directed; Chris@16: bool graph_is_strict; Chris@16: std::map nodes; // Global set Chris@16: std::vector edges; Chris@16: std::map graph_props; // Root and subgraphs Chris@16: }; Chris@16: Chris@16: // The actual parser, from libs/graph/src/read_graphviz_new.cpp Chris@16: void parse_graphviz_from_string(const std::string& str, parser_result& result, bool want_directed); Chris@16: Chris@16: // Translate from those results to a graph Chris@16: void translate_results_to_graph(const parser_result& r, ::boost::detail::graph::mutate_graph* mg); Chris@16: Chris@16: } // namespace read_graphviz_detail Chris@16: Chris@16: namespace detail { Chris@16: namespace graph { Chris@16: BOOST_GRAPH_DECL bool read_graphviz_new(const std::string& str, boost::detail::graph::mutate_graph* mg); Chris@16: } // end namespace graph Chris@16: } // end namespace detail Chris@16: Chris@16: template Chris@16: bool read_graphviz_new(const std::string& str, Chris@16: MutableGraph& graph, boost::dynamic_properties& dp, Chris@16: std::string const& node_id = "node_id") { Chris@16: boost::detail::graph::mutate_graph_impl mg(graph, dp, node_id); Chris@16: return detail::graph::read_graphviz_new(str, &mg); Chris@16: } Chris@16: Chris@16: } // namespace boost Chris@16: Chris@16: #endif // BOOST_READ_GRAPHVIZ_NEW_HPP