41 using Vertex =
typename Graph::vertex_descriptor;
44 typename boost::container_gen<typename Graph::vertex_list_selector, bitvec>::type;
48 if (forwardsReachableVertices.empty()) recompute();
49 return forwardsReachableVertices.at(v1).getbit(v2);
55 if (forwardsReachableVertices.empty() || backwardsReachableVertices.empty()) recompute();
56 return forwardsReachableVertices.at(v1) & backwardsReachableVertices.at(v2);
63 forwardsReachableVertices.clear();
64 backwardsReachableVertices.clear();
68 void setSink(std::optional<Vertex> sink) {
78 forwardsReachableVertices.clear();
79 backwardsReachableVertices.clear();
81 forwardsReachableVertices.resize(boost::num_vertices(g),
bitvec());
82 backwardsReachableVertices.resize(boost::num_vertices(g),
bitvec());
85 typename Graph::vertex_iterator v, v_end;
86 for (boost::tie(v, v_end) = boost::vertices(g); v != v_end; ++v) {
87 forwardsReachableVertices[*v].clear();
88 backwardsReachableVertices[*v].clear();
92 typename Graph::edge_iterator edges, edges_end;
93 for (boost::tie(edges, edges_end) = boost::edges(g); edges != edges_end; ++edges) {
94 auto src = boost::source(*edges, g);
95 auto dst = boost::target(*edges, g);
96 forwardsReachableVertices[src].setbit(dst);
97 backwardsReachableVertices[dst].setbit(src);
101 typename Graph::vertex_iterator mid, mid_end;
102 for (boost::tie(mid, mid_end) = boost::vertices(g); mid != mid_end; ++mid) {
104 if (sink && *mid == *sink)
continue;
106 typename Graph::vertex_iterator src, src_end;
107 for (boost::tie(src, src_end) = boost::vertices(g); src != src_end; ++src) {
108 recompute(backwardsReachableVertices, *src, *mid);
111 if (sink && *src == *sink)
continue;
112 recompute(forwardsReachableVertices, *src, *mid);
119 void recompute(EdgeSet &reachMatrix, Vertex src, Vertex mid) {
121 if (!reachMatrix[src].getbit(mid))
return;
130 reachMatrix[src] |= reachMatrix[mid];
137 std::optional<Vertex> sink = std::nullopt;
141 EdgeSet forwardsReachableVertices;
145 EdgeSet backwardsReachableVertices;
void setSink(std::optional< Vertex > sink)
Sets the sink node; no nodes will be considered reachable from this node.
Definition boost_graph.h:68
bool canReach(Vertex v1, Vertex v2)
Determines whether vertex v2 is reachable from the vertex v1.
Definition boost_graph.h:47
TODO: this is not really specific to BMV2, it should reside somewhere else.
Definition applyOptionsPragmas.cpp:24