diff options
author | Evan Martin <martine@danga.com> | 2012-02-14 00:18:46 (GMT) |
---|---|---|
committer | Evan Martin <martine@danga.com> | 2012-02-14 00:20:18 (GMT) |
commit | 51066421eef67847b244154119ca77a893bd6be8 (patch) | |
tree | 73648e2b9bede41bf0045c7bf073c4e645760a20 | |
parent | a1ea9c2d3b74bbc8b290d41c31b4d54f905146ec (diff) | |
download | Ninja-51066421eef67847b244154119ca77a893bd6be8.zip Ninja-51066421eef67847b244154119ca77a893bd6be8.tar.gz Ninja-51066421eef67847b244154119ca77a893bd6be8.tar.bz2 |
graphviz: don't draw edges multiple times
From a patch from Ian Godin <iangodin@gmail.com>.
-rw-r--r-- | src/graphviz.cc | 8 | ||||
-rw-r--r-- | src/graphviz.h | 4 |
2 files changed, 9 insertions, 3 deletions
diff --git a/src/graphviz.cc b/src/graphviz.cc index 3ead975..8354a22 100644 --- a/src/graphviz.cc +++ b/src/graphviz.cc @@ -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 diff --git a/src/graphviz.h b/src/graphviz.h index ab0e2fe..1e2a29d 100644 --- a/src/graphviz.h +++ b/src/graphviz.h @@ -19,6 +19,7 @@ using namespace std; struct Node; +struct Edge; /// Runs the process of creating GraphViz .dot file output. struct GraphViz { @@ -26,7 +27,8 @@ struct GraphViz { void AddTarget(Node* node); void Finish(); - set<Node*> visited_; + set<Node*> visited_nodes_; + set<Edge*> visited_edges_; }; #endif // NINJA_GRAPHVIZ_H_ |