MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / DFS

Method DFS

tensorflow/core/graph/graph_constructor.cc:1053–1077  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1051}
1052
1053void GraphConstructor::DFS(int cur_node, std::vector<int>* cur_branch,
1054 std::vector<bool>* is_on_cur_branch,
1055 absl::flat_hash_set<int>* unvisited) {
1056 cur_branch->push_back(cur_node);
1057 is_on_cur_branch->at(cur_node) = true;
1058 for (auto next_node : outputs_[cur_node]) {
1059 if (unvisited->find(next_node) != unvisited->end()) {
1060 if (is_on_cur_branch->at(next_node)) {
1061 auto iter =
1062 std::find(cur_branch->begin(), cur_branch->end(), next_node);
1063 LOG(WARNING) << "Cycle detected:";
1064 while (iter != cur_branch->end()) {
1065 LOG(WARNING) << *iter;
1066 ++iter;
1067 }
1068 LOG(WARNING) << "End of cycle";
1069 } else {
1070 DFS(next_node, cur_branch, is_on_cur_branch, unvisited);
1071 }
1072 }
1073 }
1074 cur_branch->pop_back();
1075 is_on_cur_branch->at(cur_node) = false;
1076 unvisited->erase(cur_node);
1077}
1078
1079void GraphConstructor::PrintCycles() {
1080 int num_nodes = outputs_.size();

Callers

nothing calls this directly

Calls 8

DFSFunction · 0.85
pop_backMethod · 0.80
push_backMethod · 0.45
atMethod · 0.45
findMethod · 0.45
endMethod · 0.45
beginMethod · 0.45
eraseMethod · 0.45

Tested by

no test coverage detected