Skip to content

Commit

Permalink
Delete PathFinder::FindAnyPathToNode method as it's not at all used o…
Browse files Browse the repository at this point in the history
…utside besides tests.

PiperOrigin-RevId: 703467954
  • Loading branch information
h-joo authored and copybara-github committed Dec 6, 2024
1 parent 720d393 commit 6c12c33
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 32 deletions.
21 changes: 0 additions & 21 deletions pytype/typegraph/solver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -151,27 +151,6 @@ QueryResult PathCacheTrie::GetResult(const CFGNode* start,
return {false, nullptr};
}

bool PathFinder::FindAnyPathToNode(
const CFGNode* start,
const CFGNode* finish,
const CFGNodeSet& blocked) const {
std::vector<const CFGNode*> stack;
stack.push_back(start);
CFGNodeSet seen;
const CFGNode* node;
while (!stack.empty()) {
node = stack.back();
stack.pop_back();
if (node == finish)
return true;
if (seen.count(node) || blocked.count(node))
continue;
seen.insert(node);
stack.insert(stack.end(), node->incoming().begin(), node->incoming().end());
}
return false;
}

std::deque<const CFGNode*> PathFinder::FindShortestPathToNode(
const CFGNode* start, const CFGNode* finish,
const CFGNodeSet& blocked) const {
Expand Down
4 changes: 0 additions & 4 deletions pytype/typegraph/solver.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,6 @@ class PathFinder {
PathFinder(const PathFinder&) = delete;
PathFinder& operator=(const PathFinder&) = delete;

// Determine whether we can reach a node at all.
bool FindAnyPathToNode(const CFGNode* start, const CFGNode* finish,
const CFGNodeSet& blocked) const;

// Find a shortest path from start to finish, going backwards. Returns an
// empty path if no path exists.
std::deque<const CFGNode*> FindShortestPathToNode(
Expand Down
7 changes: 0 additions & 7 deletions pytype/typegraph/solver_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -350,13 +350,6 @@ TEST(SolverTest, TestPathFinder) {
CFGNode* n5 = n4->ConnectNew("n5");
n5->ConnectTo(n5);
internal::PathFinder f;
EXPECT_TRUE(f.FindAnyPathToNode(n1, n1, {}));
EXPECT_TRUE(f.FindAnyPathToNode(n1, n1, {n1}));
EXPECT_TRUE(f.FindAnyPathToNode(n4, n1, {n1}));
EXPECT_TRUE(f.FindAnyPathToNode(n4, n1, {n2}));
EXPECT_TRUE(f.FindAnyPathToNode(n4, n1, {n3}));
EXPECT_FALSE(f.FindAnyPathToNode(n4, n1, {n4}));
EXPECT_FALSE(f.FindAnyPathToNode(n4, n1, {n2, n3}));
EXPECT_THAT(f.FindShortestPathToNode(n1, n1, {}), ElementsAre(n1));
EXPECT_THAT(f.FindShortestPathToNode(n1, n1, {n1}), ElementsAre(n1));
EXPECT_FALSE(f.FindShortestPathToNode(n4, n1, {n1}).empty());
Expand Down

0 comments on commit 6c12c33

Please sign in to comment.