Example Planar MapsThe following program shows how to use planar maps. First a bidirected
planar #include <LEDA/graph/graph.h> #include <LEDA/graph/planar_map.h> using namespace leda; int main() { graph G; //create new nodes of G node v0=G.new_node(); node v1=G.new_node(); node v2=G.new_node(); node v3=G.new_node(); //create new edges G.new_edge(v0,v1);G.new_edge(v1,v0); G.new_edge(v1,v2);G.new_edge(v2,v1); G.new_edge(v2,v3);G.new_edge(v3,v2); G.new_edge(v3,v0);G.new_edge(v0,v3); planar_map M(G); //create planar_map from G face f; forall_faces(f,M) { //iterate through all faces of M M.print_face(f); cout << endl; edge e; forall_face_edges(e,f) { M.print_edge(e); std::cout << std::endl; } std::cout << std::endl; } //split f into triangles by inserting new node u //and connecting it to all nodes of f. f=M.first_face(); node u=M.new_node(f); M.print(); //delete e1 and its reversal from M. The two faces //adjacent to e1 are united to one new face edge e1=M.first_edge(); M.del_edge(e1); M.print(); return 0; } |
See also:Manual Entries: |