Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r53265 - in trunk/libs/graph: doc src
From: jewillco_at_[hidden]
Date: 2009-05-25 20:10:23


Author: jewillco
Date: 2009-05-25 20:10:22 EDT (Mon, 25 May 2009)
New Revision: 53265
URL: http://svn.boost.org/trac/boost/changeset/53265

Log:
Fixed strict graph support
Text files modified:
   trunk/libs/graph/doc/read_graphviz.rst | 3 ---
   trunk/libs/graph/src/read_graphviz_new.cpp | 9 +++++++++
   2 files changed, 9 insertions(+), 3 deletions(-)

Modified: trunk/libs/graph/doc/read_graphviz.rst
==============================================================================
--- trunk/libs/graph/doc/read_graphviz.rst (original)
+++ trunk/libs/graph/doc/read_graphviz.rst 2009-05-25 20:10:22 EDT (Mon, 25 May 2009)
@@ -231,9 +231,6 @@
 
  - Expanding escape codes in the same way GraphViz does.
 
- - Enforcement of the ``strict`` keyword (ignoring self-loops and parallel
- edges).
-
  - Support for optional recognition of subgraphs as distinct entities.
 
 

Modified: trunk/libs/graph/src/read_graphviz_new.cpp
==============================================================================
--- trunk/libs/graph/src/read_graphviz_new.cpp (original)
+++ trunk/libs/graph/src/read_graphviz_new.cpp 2009-05-25 20:10:22 EDT (Mon, 25 May 2009)
@@ -335,6 +335,7 @@
     std::map<subgraph_name, subgraph_info> subgraphs;
     std::string current_subgraph_name;
     int sgcounter; // Counter for anonymous subgraphs
+ std::set<std::pair<node_name, node_name> > existing_edges; // Used for checking in strict graphs
 
     subgraph_info& current() {return subgraphs[current_subgraph_name];}
     properties& current_graph_props() {return r.graph_props[current_subgraph_name];}
@@ -649,6 +650,14 @@
 
     // Do a fixed-up edge, with only nodes as endpoints
     void do_edge(const node_and_port& src, const node_and_port& tgt, const properties& props) {
+ if (r.graph_is_strict) {
+ if (src.name == tgt.name) return;
+ std::pair<node_name, node_name> tag(src.name, tgt.name);
+ if (existing_edges.find(tag) != existing_edges.end()) {
+ return; // Parallel edge
+ }
+ existing_edges.insert(tag);
+ }
       edge_info e;
       e.source = src;
       e.target = tgt;


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk