Add vertices without arcs into the BFTree
This commit is contained in:
@@ -46,6 +46,7 @@ std::map<T, std::set<T>> BreadthFirstSearch<T>::execute(const T& root) {
|
|||||||
if (!visited[u]) {
|
if (!visited[u]) {
|
||||||
visited[u] = true;
|
visited[u] = true;
|
||||||
tree[v].insert(u);
|
tree[v].insert(u);
|
||||||
|
tree[u];
|
||||||
Q.push(u);
|
Q.push(u);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -114,12 +114,15 @@ TEST_SUITE("Algorithm") {
|
|||||||
{2, {3, 6}},
|
{2, {3, 6}},
|
||||||
{3, {4}},
|
{3, {4}},
|
||||||
{4, {5}},
|
{4, {5}},
|
||||||
|
{5, {}},
|
||||||
{6, {7, 9}},
|
{6, {7, 9}},
|
||||||
{7, {8}},
|
{7, {8}},
|
||||||
|
{8, {}},
|
||||||
{9, {10}},
|
{9, {10}},
|
||||||
{10, {11}},
|
{10, {11}},
|
||||||
{11, {12}},
|
{11, {12}},
|
||||||
{12, {13}}
|
{12, {13}},
|
||||||
|
{13, {}}
|
||||||
};
|
};
|
||||||
|
|
||||||
CHECK_EQ(tree, expected);
|
CHECK_EQ(tree, expected);
|
||||||
|
|||||||
Reference in New Issue
Block a user