| 38 | /** Find the root of the tree/set containing the vertex i : Use Path halving */ |
| 39 | template<typename Index, typename IndexVector> |
| 40 | Index etree_find (Index i, IndexVector& pp) |
| 41 | { |
| 42 | Index p = pp(i); // Parent |
| 43 | Index gp = pp(p); // Grand parent |
| 44 | while (gp != p) |
| 45 | { |
| 46 | pp(i) = gp; // Parent pointer on find path is changed to former grand parent |
| 47 | i = gp; |
| 48 | p = pp(i); |
| 49 | gp = pp(p); |
| 50 | } |
| 51 | return p; |
| 52 | } |
| 53 | |
| 54 | /** Compute the column elimination tree of a sparse matrix |
| 55 | * \param mat The matrix in column-major format. |