Add reverse a digraph function and test
This commit is contained in:
@@ -28,7 +28,15 @@ Digraph<T>::Digraph(std::map<T, std::set<T>> digraph) {
|
||||
|
||||
template<typename T>
|
||||
Digraph<T> Digraph<T>::reverse() {
|
||||
return Digraph<T>();
|
||||
std::map<T, std::set<T>> revMatrix;
|
||||
|
||||
for (const auto& v : Graph<T>::adjMatrix) {
|
||||
for (const auto& u : v.second) {
|
||||
revMatrix[u].insert(v.first);
|
||||
}
|
||||
}
|
||||
|
||||
return revMatrix;
|
||||
}
|
||||
|
||||
} // namespace graph
|
||||
|
||||
Reference in New Issue
Block a user