Example Face ArraysThe following program shows how an
#include <LEDA/graph/graph.h>
#include <LEDA/graph/face_array.h>
using namespace leda;
int main()
{
graph G;
node v1=G.new_node();
node v2=G.new_node();
node v3=G.new_node();
G.new_edge(v1,v2);G.new_edge(v2,v1);
G.new_edge(v2,v3);G.new_edge(v3,v2);
G.new_edge(v3,v1);G.new_edge(v1,v3);
G.make_map(); //sets reversal information for every edge
G.compute_faces(); //computes faces of G
face_array<int> A(G,1); //define edge array A for G
//and assign 1 to every edge
face f;
forall_faces(f,G) std::cout << A[f] << " ";
std::cout << std::endl;
//assign new values
int i=2;
forall_faces(f,G) A[f]=i++;
forall_faces(f,G) cout << A[f] << " ";
std::cout << std::endl;
return 0;
}
|
See also:Associate Information with Graphs Manual Entries: |