Boost logo

Boost Users :

From: Bernhard Lippmann (bernhard.lippmann_at_[hidden])
Date: 2008-03-23 18:21:08


Hi,

I need some help on the remove_edge, remove_vertex functions.
What is wrong with my two functions, removing edges or vertex from a graph
with a given name in the coressponding property map.
pls. see code snippet
after calling my function a second time I get a run time error.
I did the code as shown under
http://www.boost.org/libs/graph/doc/adjacency_list.html
but I feel the rebuild of the vectors did not work,
any input is welcome

Best

Bernhard

this is the code in the main program:

   // ok
    MyElementList.RemoveVertexByName("vss!",g, VertexNamesMap);
  // now the run time error ...
    MyElementList.RemoveVertexByName("vss!s",g, VertexNamesMap);

this is the called sub routine:

/*$
****************************************************************************
**
                                        Method Name RemoveVertexByName ()...
                                        Parameters std::string AE_Name
                                        Return long , Index in Map
                                        Description remove vertex with a given name
                                                            see
http://www.boost.org/libs/graph/doc/adjacency_list.html
                                                                                for troubles
****************************************************************************
****** */
void TElementList::RemoveVertexByName(std::string elementname, TGraph &g,
TVertexNameMap &VertexNamesMap)
{
  Tvertex_iter vi, vi_end, next;
  tie(vi, vi_end) = vertices(g);
  for (next = vi; vi != vi_end; vi = next) {
    ++next;
        if (VertexNamesMap[*vi] == elementname) {
                remove_vertex(*vi, g); }
  }

}

/*$
****************************************************************************
**
                                        Method Name RemoveEdgeByName ()
                                        Parameters std::string AE_Name
                                        Return long , Index in Map
                                        Description Removes the edge (u,v) from the graph.
                                                            void remove_edge(vertex_descriptor u,
vertex_descriptor v, adjacency_list& g)
                                        void remove_edge(edge_descriptor e,
adjacency_list& g)
****************************************************************************
****** */
void TElementList::RemoveEdgeByName(std::string elementname, TGraph &g,
TEdgeNameMap &EdgeNamesMap)
{
  Tedge_iter xei, xei_end;
  for (tie(xei, xei_end) = edges(g); xei != xei_end; ++xei)
     {
      Tedge_descriptor e = *xei;

          if (EdgeNamesMap[e] == elementname) { remove_edge (e,g); }

      // Tvertex_descriptor u = source(e, g), v = target(e, g);
      // if .... (option 29
      }

}
No virus found in this outgoing message.
Checked by AVG.
Version: 7.5.519 / Virus Database: 269.21.8/1339 - Release Date: 22.03.2008
16:43


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net