Add missing overlap edges. For each vertex u with at least two * outgoing edges, (u,v1) and (u,v2), add the edge (v1,v2) if v1 < v2, * and add the edge (v2,v1) if v2 < v1. */
| 629 | * and add the edge (v2,v1) if v2 < v1. |
| 630 | */ |
| 631 | static void |
| 632 | addMissingEdges(const Lengths& lengths, PathGraph& g, const ContigPathMap& paths) |
| 633 | { |
| 634 | typedef graph_traits<PathGraph>::adjacency_iterator Vit; |
| 635 | typedef graph_traits<PathGraph>::vertex_iterator Uit; |
| 636 | typedef graph_traits<PathGraph>::vertex_descriptor V; |
| 637 | |
| 638 | unsigned numAdded = 0; |
| 639 | pair<Uit, Uit> urange = vertices(g); |
| 640 | for (Uit uit = urange.first; uit != urange.second; ++uit) { |
| 641 | V u = *uit; |
| 642 | if (out_degree(u, g) < 2) |
| 643 | continue; |
| 644 | pair<Vit, Vit> vrange = adjacent_vertices(u, g); |
| 645 | for (Vit vit1 = vrange.first; vit1 != vrange.second;) { |
| 646 | V v1 = *vit1; |
| 647 | ++vit1; |
| 648 | assert(v1 != u); |
| 649 | ContigPath path1 = getPath(paths, v1); |
| 650 | if (find(path1.begin(), path1.end(), ContigPath::value_type(u)) == path1.end()) |
| 651 | continue; |
| 652 | for (Vit vit2 = vit1; vit2 != vrange.second; ++vit2) { |
| 653 | V v2 = *vit2; |
| 654 | assert(v2 != u); |
| 655 | assert(v1 != v2); |
| 656 | if (edge(v1, v2, g).second || edge(v2, v1, g).second) |
| 657 | continue; |
| 658 | ContigPath path2 = getPath(paths, v2); |
| 659 | if (find(path2.begin(), path2.end(), ContigPath::value_type(u)) == path2.end()) |
| 660 | continue; |
| 661 | numAdded += addOverlapEdge(lengths, g, u, v1, path1, v2, path2); |
| 662 | } |
| 663 | } |
| 664 | } |
| 665 | if (opt::verbose > 0) |
| 666 | cout << "Added " << numAdded << " missing edges.\n"; |
| 667 | if (!opt::db.empty()) |
| 668 | addToDb(db, "addedMissingEdges", numAdded); |
| 669 | } |
| 670 | |
| 671 | /** Remove transitive edges. */ |
| 672 | static void |
no test coverage detected