Permalink
Browse files

graphviz: don't draw edges multiple times

From a patch from Ian Godin <iangodin@gmail.com>.
  • Loading branch information...
1 parent a1ea9c2 commit 51066421eef67847b244154119ca77a893bd6be8 @evmar evmar committed Feb 14, 2012
Showing with 9 additions and 3 deletions.
  1. +6 −2 src/graphviz.cc
  2. +3 −1 src/graphviz.h
View
@@ -19,11 +19,11 @@
#include "graph.h"
void GraphViz::AddTarget(Node* node) {
- if (visited_.find(node) != visited_.end())
+ if (visited_nodes_.find(node) != visited_nodes_.end())
return;
printf("\"%p\" [label=\"%s\"]\n", node, node->path().c_str());
- visited_.insert(node);
+ visited_nodes_.insert(node);
Edge* edge = node->in_edge();
@@ -33,6 +33,10 @@ void GraphViz::AddTarget(Node* node) {
return;
}
+ if (visited_edges_.find(edge) != visited_edges_.end())
+ return;
+ visited_edges_.insert(edge);
+
if (edge->inputs_.size() == 1 && edge->outputs_.size() == 1) {
// Can draw simply.
// Note extra space before label text -- this is cosmetic and feels
View
@@ -19,14 +19,16 @@
using namespace std;
struct Node;
+struct Edge;
/// Runs the process of creating GraphViz .dot file output.
struct GraphViz {
void Start();
void AddTarget(Node* node);
void Finish();
- set<Node*> visited_;
+ set<Node*> visited_nodes_;
+ set<Edge*> visited_edges_;
};
#endif // NINJA_GRAPHVIZ_H_

0 comments on commit 5106642

Please sign in to comment.