Esempio n. 1
0
import SupportAlgorithms as sup
import Algorithms as alg

H = sup.EdgesToMAG(
    "../MAG_Edge_Lists/MAG_EX1_Edges.txt")  # Builds MAG H from an edge list
J, T = alg.AdjMatrix(
    H)  # Computes Adjacency matrix (J) and companion tuple (T) for MAG H
V, D, P = alg.BFS(J, T,
                  (2, 1, 1))  # Runs BFS starting from composite vertex (2,1,1)

print(V)  # Prints reached composite vertices
print(D)  # Prints distances
print(P)  # Prints predecessors
Esempio n. 2
0
    def goalTest(self, state):
        color = ''
        for i in range(0, 25):
            if i % 4 == 1:
                color = state.value[i]
            elif color != state.value[i]:
                return False
        return True

    def stepCost(self, state, action):
        return 1


print("BFS : \n")
G = Problem()
Alg7 = Algorithms(G)
Alg7.BFS(G.initialState())
print("=======================")

print("DFS_LIMITED : \n")
H = Problem()
Alg8 = Algorithms(H)
Alg8.DFS_Limited(H.initialState(), 14)
print("=======================")

print("DFS_ADITIVE : \n")
W = Problem()
Alg9 = Algorithms(W)
Alg9.DFS_Aditive(W.initialState(), 1)