include "primitives.alh" include "modelling.alh" include "object_operations.alh" Element function bfs(params : Element, output_mms : Element): Element model String initial Element options Element worklist Element work_unit String state Element path Element path_copy String option model = params["reachability_graph"] worklist = create_node() initial = set_pop(allInstances(model, "InitialState")) 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] log("Searching for length " + cast_v2s(read_nr_out(path))) if (value_eq(read_attribute(model, state, "error"), True)): // Found an error path! log("Found error path!") log(list_to_string(path)) output("Found error path:") output(list_to_string(path)) break! options = allOutgoingAssociationInstances(model, state, "Transition") while (read_nr_out(options) > 0): option = set_pop(options) path_copy = dict_copy(path) list_append(path_copy, read_attribute(model, option, "name")) list_append(worklist, create_tuple(readAssociationDestination(model, option), path_copy)) return create_node()!