m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcin Chrzanowski <marcin.j.chrzanowski@gmail.com>2017-01-04 23:08:45 -0500
committerMarcin Chrzanowski <marcin.j.chrzanowski@gmail.com>2017-01-04 23:08:45 -0500
commita13f7f90743ccdf72e4e3196e666a23c26b896ec (patch)
tree13a86af27a3b64af3c2568e9c259ced5f1780196
parent65f6a91e86cdbe2c67e9185036e82925b3198566 (diff)
Note existence of out edges
-rw-r--r--src/graph.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/graph.h b/src/graph.h
index b4b300b..7d0ae08 100644
--- a/src/graph.h
+++ b/src/graph.h
@@ -19,6 +19,7 @@ public:
add_vertex(from);
add_vertex(to);
graph_[from].push_back(to);
+ has_out_edges_.insert(from);
}
const std::set<int> & get_vertices() const {
@@ -28,9 +29,14 @@ public:
const std::vector<int> & get_neighbors(int vertex) const {
return graph_.find(vertex)->second;
}
+
+ bool has_out_edges(int vertex) const {
+ return has_out_edges_.count(vertex) > 0;
+ }
private:
std::set<int> vertices_;
std::map<int, std::vector<int>> graph_;
+ std::set<int> has_out_edges_;
};
#endif