// // alternation_reachable.pp // // computes the alternation reachable sets for each vertex in the class // dictionary and returns an Ar_Vertex_list. An Ar_Vertex contains the // name of the Vertex in question, the alternation reachable set in question // and the 'contained-in' member used in determining if the list of // alternation reachable sets correspond to a class dictionary that satisfies // the tree property. // // compute_ar_sets initializes the return list (this includes generating the // list of all the vertices and setting the alternation reachable sets for // construction vertices) then calls ar_compute to do the rest of the // computing. // // ar_compute visits each vertex in the list, computing the alternation // reachable sets for any vertex that it hasn't been calculated for already. // This is done for improved performance since the calculated value of // alternation reachable sets for alternation vertices is the union of the // values of the alternation reachable sets for all the vertices that the // alternation vertex in question has alternation edges going to. // // init, call main computation *operation* Ar_Vertex_list* compute_ar_sets() *init* (@ init_ar_list() @) *traverse* *from* Cd_graph *to-stop* Cd_graph *wrapper* Cd_graph *prefix* (@ return_val->ar_compute(this); @) // visit each vertex and calculate if not done already *operation* void ar_compute(Cd_graph* cd) *traverse* *from* Ar_Vertex_list *to* Ar_Vertex *wrapper* Ar_Vertex *prefix* (@ if (ar == NULL) { ar = cd->ar_compute(v); } @) // init routine, set up names, handle construction vertices *operation* Ar_Vertex_list* init_ar_list() *init* (@ new Ar_Vertex_list @) *traverse* *from* Cd_graph *to-stop* Adjacency *wrapper* Adjacency *suffix* (@ Ar_Vertex* ar_v = new Ar_Vertex(source, NULL, NULL); return_val->append(ar_v); @) // compute the ar set for a particular vertex *operation* Vertex_comma_list* ar_compute(Vertex* v) *init* (@ new Vertex_comma_list @) *traverse* *from* Cd_graph *to-stop* Adjacency *carry* *in* Cd_graph* cd = (@ this @) *along* *from* Cd_graph *to* Adjacency *wrapper* Adjacency *suffix* (@ if (v->g_equal(source)) { return_val->concatenate(ar_vertices(cd)); } @) *operation* Vertex_comma_list* ar_vertices(Cd_graph* cd) *init* (@ new Vertex_comma_list @) *traverse* *merge* (*from* Adjacency *to-stop* Construct_ns, *from* Adjacency *through* ->*,alternat_ns,* *to-stop* Vertex) *carry* *in* Vertex* src = (@ source @) *along* *from* Adjacency *to* Construct_ns *wrapper* Construct_ns *suffix* (@ return_val->set_union(src); @) *wrapper* Vertex *suffix* (@ return_val->set_union(cd->ar_compute(this)); @)