Marks the given subgraph as a direct antecedent (dependency) of this one.
| 120 | |
| 121 | /// Marks the given subgraph as a direct antecedent (dependency) of this one. |
| 122 | void AddDirectAntecedent(PartialSubgraph* antecedent) |
| 123 | { |
| 124 | if (m_Parent == nullptr) |
| 125 | { |
| 126 | antecedent = antecedent->GetRepresentative(); |
| 127 | |
| 128 | m_Antecedents.insert(antecedent); |
| 129 | // Also record all of its antecedents, so that we end up with direct and indirect antecedents. |
| 130 | // This makes the lookup in HasAntecedent() faster. |
| 131 | m_Antecedents.insert(antecedent->m_Antecedents.begin(), antecedent->m_Antecedents.end()); |
| 132 | // All of our dependents also need to include the new antecedents |
| 133 | for (PartialSubgraph* d : m_Dependants) |
| 134 | { |
| 135 | d->m_Antecedents.insert(antecedent); |
| 136 | d->m_Antecedents.insert(antecedent->m_Antecedents.begin(), antecedent->m_Antecedents.end()); |
| 137 | } |
| 138 | |
| 139 | // Store reverse dependencies as well, required so that we can efficiently navigate the graph |
| 140 | // when making updates. |
| 141 | antecedent->m_Dependants.insert(this); |
| 142 | antecedent->m_Dependants.insert(m_Dependants.begin(), m_Dependants.end()); |
| 143 | for (PartialSubgraph* a : antecedent->m_Antecedents) |
| 144 | { |
| 145 | a->m_Dependants.insert(this); |
| 146 | a->m_Dependants.insert(m_Dependants.begin(), m_Dependants.end()); |
| 147 | } |
| 148 | } |
| 149 | else |
| 150 | { |
| 151 | // Defer request to the representative |
| 152 | GetRepresentative()->AddDirectAntecedent(antecedent); |
| 153 | } |
| 154 | } |
| 155 | |
| 156 | /// Checks if this subgraph is dependent on the given subgraph, either directly or indirectly. |
| 157 | bool HasAntecedent(PartialSubgraph* antecedent) |
no test coverage detected