Subversion Repositories programming

Rev

Rev 380 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 380 Rev 382
Line 83... Line 83...
83
 
83
 
84
			# Check if we've reached the goal
84
			# Check if we've reached the goal
85
			if N in self.__goal_nodes:
85
			if N in self.__goal_nodes:
86
				return self.__kb #result
86
				return self.__kb #result
87
 
87
 
88
			for node in M:
88
			#for node in M:
89
				if (node not in OPEN) and (node not in CLOSED):
89
			#	if (node not in OPEN) and (node not in CLOSED):
90
					OPEN.append (node)
90
			#		OPEN.append (node)
91
 
91
 
92
			# Sort OPEN appropriately
92
			# Sort OPEN appropriately
93
			# NOTE: no sort algorithm is BFS
93
			# NOTE: no sort algorithm is BFS
94
			#self.__ordering_func (OPEN)
94
			#self.__ordering_func (OPEN)
95
 
95
 
Line 97... Line 97...
97
			# FIXME: combine it with the ordering function into
97
			# FIXME: combine it with the ordering function into
98
			# FIXME: it's own function that chooses how to add
98
			# FIXME: it's own function that chooses how to add
99
			# FIXME: the nodes from M into OPEN
99
			# FIXME: the nodes from M into OPEN
100
			#
100
			#
101
			# FIXME: prototype might be: func (M, OPEN, CLOSED)
101
			# FIXME: prototype might be: func (M, OPEN, CLOSED)
-
 
102
			#add_dfs (M, OPEN, CLOSED)
-
 
103
			OPEN = add_bfs (M, OPEN, CLOSED)
102
 
104
 
103
			counter += 1
105
			counter += 1
104
 
106
 
105
		return 'FAILURE'
107
		return 'FAILURE'
106
 
108
 
107
def add_bfs (M, OPEN, CLOSED):
109
def add_bfs (M, OPEN, CLOSED):
108
	for node in M:
110
	for node in M:
109
		if (node not in OPEN) and (node not in CLOSED):
111
		if (node not in OPEN) and (node not in CLOSED):
110
			OPEN.append (node)
112
			OPEN.append (node)
111
 
113
 
-
 
114
	return OPEN
-
 
115
 
112
def add_dfs (M, OPEN, CLOSED):
116
def add_dfs (M, OPEN, CLOSED):
113
	for node in M:
117
	for node in M:
114
		if (node not in OPEN) and (node not in CLOSED):
118
		if (node not in OPEN) and (node not in CLOSED):
115
			OPEN.insert (0, node) # insert node at beginning
119
			OPEN.insert (0, node) # insert node at beginning
116
 
120
 
-
 
121
	return OPEN
-
 
122
 
117
 
123
 
118
from Graph import Graph
124
from Graph import Graph
119
from DrawGraph import DrawGraph
125
from DrawGraph import DrawGraph
120
 
126
 
121
def main ():
127
def main ():