@@ -53,33 +53,6 @@ bool Italiano<T>::query(const T& u, const T& v) {
|
|||||||
template<typename T>
|
template<typename T>
|
||||||
void Italiano<T>::remove(const T& u, const T& v) {
|
void Italiano<T>::remove(const T& u, const T& v) {
|
||||||
|
|
||||||
for (const auto& w : G.adjMatrix) {
|
|
||||||
// Check if (u,v) edge of T(w) || p(w,v) points to (u,v)
|
|
||||||
|
|
||||||
// If yes => set p(w, v) to point to the next edge (u',v) in Ein(v)
|
|
||||||
// If (u,v) the last edge, then set it to point to null
|
|
||||||
|
|
||||||
// If T(w) contains u' then the new edge reconnects v to T(w)
|
|
||||||
// As this needs to be checked, we set R(w) <- {v}
|
|
||||||
|
|
||||||
// If (u,v) is not edge of T(w) or is the last edge in Ein(v), R(w) <- phi
|
|
||||||
|
|
||||||
// Remove (u,v) from Eout(u) and Ein(v)
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const auto& w : G.adjMatrix) {
|
|
||||||
|
|
||||||
// Check tentative pointers of the vertices in R(w).
|
|
||||||
// While there is a vertex x in R(w), scan the edges in Ein(x), starting
|
|
||||||
// from the edge pointed to by p(w,x), until an edge (u',x) for which
|
|
||||||
// p(w,u') != null is found or Ein(x) is exhausted.
|
|
||||||
|
|
||||||
// If such edge is found, x is removed from R(w).
|
|
||||||
// If the list is exhausted, set p(w,x) to null and M(w,x) to 0
|
|
||||||
|
|
||||||
// Then scan all Eout(x). If (x,x') is tree edge, add x' to R(w)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace algo
|
} // namespace algo
|
||||||
|
|||||||
@@ -45,8 +45,6 @@ Graph<T>::~Graph() {
|
|||||||
template<typename T>
|
template<typename T>
|
||||||
inline void Graph<T>::insert(const T& u, const T& v) {
|
inline void Graph<T>::insert(const T& u, const T& v) {
|
||||||
Graph<T>::adjMatrix[u].insert(v);
|
Graph<T>::adjMatrix[u].insert(v);
|
||||||
Graph<T>::adjMatrix[v];
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
|||||||
@@ -45,13 +45,13 @@ TEST_SUITE("Graph") {
|
|||||||
CHECK_EQ(R, X);
|
CHECK_EQ(R, X);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Graph::V and Graph::E") {
|
TEST_CASE("Digraph::V and Digraph::E") {
|
||||||
// 1 --> 2 --> 3 --> 1
|
// 1 --> 2 --> 3 --> 1
|
||||||
// 3 --> 4 --> 5 --> 3
|
// 3 --> 4 --> 5 --> 3
|
||||||
// 2 --> 6 --> 7 --> 8 --> 6
|
// 2 --> 6 --> 7 --> 8 --> 6
|
||||||
// 6 --> 9 --> 10 --> 11 --> 12 --> 13 --> 9
|
// 6 --> 9 --> 10 --> 11 --> 12 --> 13 --> 9
|
||||||
// 12 --> 10
|
// 12 --> 10
|
||||||
Graph<std::uint16_t> G;
|
Digraph<std::uint16_t> G;
|
||||||
G.insert(1, 2);
|
G.insert(1, 2);
|
||||||
G.insert(2, 3);
|
G.insert(2, 3);
|
||||||
G.insert(3, 1);
|
G.insert(3, 1);
|
||||||
|
|||||||
Reference in New Issue
Block a user