| 313 | */ |
| 314 | template <class Graph> |
| 315 | static inline std::pair<typename boost::graph_traits<Graph>::vertex_descriptor, |
| 316 | PathExtensionResultCode> |
| 317 | successor(const typename boost::graph_traits<Graph>::vertex_descriptor& u, |
| 318 | Direction dir, const Graph& g, unsigned trim, unsigned fpTrim) |
| 319 | { |
| 320 | typedef typename boost::graph_traits<Graph>::vertex_descriptor V; |
| 321 | typedef typename boost::graph_traits<Graph>::in_edge_iterator InEdgeIt; |
| 322 | typedef typename boost::graph_traits<Graph>::out_edge_iterator OutEdgeIt; |
| 323 | |
| 324 | InEdgeIt iei, iei_end; |
| 325 | OutEdgeIt oei, oei_end; |
| 326 | |
| 327 | /* assign u to suppress uninitialized warning */ |
| 328 | V v = u; |
| 329 | for (unsigned i = 0; true; i = (i == 0) ? 1 : std::min(trim, 2*i)) |
| 330 | { |
| 331 | unsigned trueBranches = 0; |
| 332 | |
| 333 | if (dir == FORWARD) { |
| 334 | for (boost::tie(oei, oei_end) = out_edges(u, g); oei != oei_end; ++oei) { |
| 335 | if (trueBranch(*oei, FORWARD, g, i, fpTrim)) { |
| 336 | v = target(*oei, g); |
| 337 | ++trueBranches; |
| 338 | if (trueBranches >= 2) |
| 339 | break; |
| 340 | } |
| 341 | } |
| 342 | } else { |
| 343 | assert(dir == REVERSE); |
| 344 | for (boost::tie(iei, iei_end) = in_edges(u, g); iei != iei_end; ++iei) { |
| 345 | if (trueBranch(*iei, REVERSE, g, i, fpTrim)) { |
| 346 | v = source(*iei, g); |
| 347 | ++trueBranches; |
| 348 | if (trueBranches >= 2) |
| 349 | break; |
| 350 | } |
| 351 | } |
| 352 | } |
| 353 | |
| 354 | if (trueBranches == 0) |
| 355 | return std::make_pair(v, ER_DEAD_END); |
| 356 | else if (trueBranches == 1) |
| 357 | return std::make_pair(v, ER_LENGTH_LIMIT); |
| 358 | else if (i == trim) |
| 359 | return std::make_pair(v, ER_AMBI_OUT); |
| 360 | } |
| 361 | |
| 362 | } |
| 363 | |
| 364 | /** |
| 365 | * Return true if the given vertex has more than one possible |
no test coverage detected