Closed op-hunter closed 4 years ago
Yes, DFS can be optimized using union-find-set, BFS, etc. However, the time cost of DFS is negligible compare to the main process of building NSG, optimization for DFS will not make much improvement for the whole building process.
Learn much posture of C++ programing from your code. But I think there is still space for optimizing the performance by using union-find-set to judge the connectivity of the NSG. emm.. maybe can economize a non-recursive DFS function, am i right:)