split.h
Go to the documentation of this file.00001 #ifndef VVELIB_ALGORITHMS_SPLIT_H
00002 #define VVELIB_ALGORITHMS_SPLIT_H
00003
00009 #include <config.h>
00010 namespace algorithms
00011 {
00012
00021 template <class vvgraph>
00022 typename vvgraph::vertex_t split(const typename vvgraph::vertex_t& v,
00023 const typename vvgraph::vertex_t& n1,
00024 const typename vvgraph::vertex_t& n2,
00025 vvgraph& S)
00026 {
00027 typedef typename vvgraph::vertex_t vertex;
00028 typedef typename vvgraph::edge_t edge;
00029 vertex x;
00030 vertex pv = v;
00031 S.insert(x);
00032 S.spliceBefore(v,n1,x);
00033 S.insertEdge(x,v);
00034 do
00035 {
00036 const vertex& n = S.nextTo(v,x);
00037 typename edge::content_t ec = *S.edge(n,v);
00038 *S.replace(n,v,x) = ec;
00039 *S.spliceAfter(x,pv,n) = *S.edge(v,n);
00040 pv = n;
00041 S.eraseEdge(v,n);
00042 } while(pv != n2);
00043 return x;
00044 }
00045 }
00046
00047 #endif // VVELIB_ALGORITHMS_SPLIT_H
00048