cppDelAEdge

UseCase3



// COM1205 Propagation Pattern for DemDraw Project
//
// Created by Young Soo Yang (yyang@ccs.neu.edu)
//
// This propagation pattern will traverse all the alternation edges in a
// Graph object to remove one.  It finds an edge to be removed by comparing
// source and destination vertex names of an edge with arguments SrcLabelname
// and DesLabelname by calling cppCompVertName().  It returns 1, if deleting
// done successfully, otherwise, returns 0.
// Note: can't use g_delete() to delete an edge since each edge also points
//       to two vertices, source & destination, that should not be removed.
//
// Modification History:
//
// 11/27/95 - Young Soo Yang (yyang@ccs.neu.edu)
//	Modified to make it more structure shy
//

*operation* int cppDelAEdge( char* SrcLabelname, char* DesLabelname )
   *init* (@ 0 @)
   *traverse*
      *from* Graph
         *through* -> *,edges,*
      *to*   { AltEdge, ConstEdge }

   *carry*
      *in* Edge_List* new_EList = (@ new Edge_List() @)
      *along* *from* Graph *through* -> *,edges,* *to* { AltEdge, ConstEdge }

   *wrapper* Graph
      *suffix*
      (@
         delete (this -> get_edges());
         this -> set_edges(new_EList);

         this -> cppDrawVertices();
         this -> cppDrawEdges();
      @)

   *wrapper* ConstEdge
      (@
         new_EList -> append(this);
      @)

   *wrapper* AltEdge
      (@
         if (this->get_from()->cppCompVertName(SrcLabelname) &&
             this->get_to()->cppCompVertName(DesLabelname)) {

            if (this->get_middlepoints() != NULL)
               this->get_middlepoints()->g_delete();
            delete (this);

            return_val = 1;

         } else {

            new_EList -> append(this);

         }
      @)