init_state = 9 V = np.arange(0, 10) E = np.array([[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 6], [1, 7], [2, 5], [9, 4]]) # problem = GraphSearchProblem(goal_states, init_state, V, E) # path, num_nodes_expanded, max_frontier_size = bidirectional_search(problem) # correct = problem.check_graph_solution(path) # print("Solution is correct: {:}".format(correct)) # Use stanford_large_network_facebook_combined.txt to make your own test instances E = np.loadtxt('stanford_large_network_facebook_combined.txt', dtype=int) V = np.unique(E) goal_states = [349] init_state = [0] problem = GraphSearchProblem(goal_states, init_state, V, E) E_twitter = numpy.load('twitter_edges_project_01.npy') V_twitter = numpy.unique(E_twitter) twitter_problem = GraphSearchProblem([59999], 0, V_twitter, E_twitter) start = time.time() path, num_nodes_expanded, max_frontier_size = bidirectional_search( twitter_problem) end = time.time() print(end - start) correct = twitter_problem.check_graph_solution(path) print("Solution is correct: {:}".format(correct)) print(path) # Be sure to compare with breadth_first_search!
path2[index].pop() path = path1[index] + path2[index][::-1] num_nodes_expanded = len(explored1) + len(explored2) return path, num_nodes_expanded, max_frontier_size if __name__ == '__main__': # Simple example goal_states = [0] init_state = 9 V = np.arange(0, 10) E = np.array([[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 6], [1, 7], [2, 5], [9, 4]]) problem = GraphSearchProblem(goal_states, init_state, V, E) path, num_nodes_expanded, max_frontier_size = bidirectional_search(problem) correct = problem.check_graph_solution(path) print("Solution is correct: {:}".format(correct)) print(path) # Use stanford_large_network_facebook_combined.txt to make your own test instances E = np.loadtxt('stanford_large_network_facebook_combined.txt', dtype=int) V = np.unique(E) goal_states = [349] init_state = 0 problem = GraphSearchProblem(goal_states, init_state, V, E) path, num_nodes_expanded, max_frontier_size = bidirectional_search(problem) correct = problem.check_graph_solution(path) print("Solution is correct: {:}".format(correct)) print(path)