|
@@ -11,30 +11,18 @@ Element function bfs(params : Element, output_mms : Element):
|
|
|
String state
|
|
|
Element path
|
|
|
Element path_copy
|
|
|
- Element visited
|
|
|
- Element visited_copy
|
|
|
String option
|
|
|
- String dest
|
|
|
|
|
|
model = params["reachability_graph"]
|
|
|
|
|
|
worklist = create_node()
|
|
|
initial = set_pop(allInstances(model, "InitialState"))
|
|
|
- work_unit = create_node()
|
|
|
- list_append(work_unit, initial)
|
|
|
- path = create_node()
|
|
|
- list_append(work_unit, path)
|
|
|
- visited = create_node()
|
|
|
- set_add(visited, initial)
|
|
|
- list_append(work_unit, visited)
|
|
|
-
|
|
|
- list_append(worklist, work_unit)
|
|
|
+ list_append(worklist, create_tuple(initial, create_node()))
|
|
|
|
|
|
while (read_nr_out(worklist) > 0):
|
|
|
work_unit = list_pop(worklist, 0)
|
|
|
state = work_unit[0]
|
|
|
path = work_unit[1]
|
|
|
- visited = work_unit[2]
|
|
|
log("Searching for length " + cast_v2s(read_nr_out(path)))
|
|
|
|
|
|
if (value_eq(read_attribute(model, state, "error"), True)):
|
|
@@ -46,24 +34,11 @@ Element function bfs(params : Element, output_mms : Element):
|
|
|
break!
|
|
|
|
|
|
options = allOutgoingAssociationInstances(model, state, "Transition")
|
|
|
+
|
|
|
while (read_nr_out(options) > 0):
|
|
|
option = set_pop(options)
|
|
|
- dest = readAssociationDestination(model, option)
|
|
|
-
|
|
|
- if (set_in(visited, dest)):
|
|
|
- // Already visited this node, so skip
|
|
|
- continue!
|
|
|
-
|
|
|
path_copy = dict_copy(path)
|
|
|
- visited_copy = set_copy(visited)
|
|
|
-
|
|
|
- set_add(visited_copy, dest)
|
|
|
list_append(path_copy, read_attribute(model, option, "name"))
|
|
|
-
|
|
|
- work_unit = create_node()
|
|
|
- list_append(work_unit, dest)
|
|
|
- list_append(work_unit, path_copy)
|
|
|
- list_append(work_unit, visited_copy)
|
|
|
- list_append(worklist, work_unit)
|
|
|
+ list_append(worklist, create_tuple(readAssociationDestination(model, option), path_copy))
|
|
|
|
|
|
return create_node()!
|