Examples for Boost Libraries |
This example demonstrates how to copy all of the vertices and edges from an adjacency list graph g1 to adjacency list graph g2 and adjacency list graph g3 to adjacency list graph g1.
An adjacency-list is a two-dimensional structure, where each element of the first dimension represents a vertex, and each of the vertices contain a one-dimensional structure that is its edge list. The copy_graph function copies all of the vertices and edges from graph g1 into g2 and g3 into g1. Also, it copies the vertex and edge properties by using either, the vertex_all and edge_all property maps, or by user-supplied copy functions. The binary function vertex_copy copies the properties of a vertex in the original graph into the corresponding vertex in the copy.
The MMP file for Copy is as shown below:
TARGET OpenCBoostCopy.exe TARGETTYPE exe UID 0x1000008d 0xe000000e #ifdef EKA2 CAPABILITY ALL -TCB VENDORID 0x70000001 #endif SYSTEMINCLUDE \epoc32\include SYSTEMINCLUDE \epoc32\include\stdapis SYSTEMINCLUDE \epoc32\include\stdapis\sys SYSTEMINCLUDE \epoc32\include\stdapis\stlport SYSTEMINCLUDE \epoc32\include\stdapis\boost SOURCEPATH ..\src SOURCE OpenCBoostCopy.cpp SOURCEPATH ..\data START RESOURCE OpenCBoostCopy_reg.rss #ifdef WINSCW TARGETPATH \private\10003a3f\apps #else TARGETPATH \private\10003a3f\import\apps #endif END //RESOURCE USERINCLUDE ..\inc STATICLIBRARY libcrt0.lib LIBRARY libstdcpp.lib LIBRARY libc.lib LIBRARY libpthread.lib LIBRARY euser.lib OPTION CW -wchar_t on MACRO _WCHAR_T_DECLARED
The code snippet below is an example usage for the boost copy function:
#include<boost/graph/adjacency_list.hpp> #include<boost/graph/copy.hpp> #ifdef __GCCE__ #include<staticlibinit_gcce.h> #endif int failed_tests = 0; using namespace boost; class copier { public: template <class V1, class V2> void operator()(const V1&, const V2&) const {} }; int main() { adjacency_list < vecS, vecS, directedS, property< vertex_root_t, int>>g1, g2; adjacency_list < vecS, vecS, directedS, property< vertex_index_t, int>>g3; printf("Call copy_graph with g1 and g2 adjacency_list"); copy_graph(g1, g2); printf("Create Copier instance"); copier c; printf("Call copy_graph with with vertex copy"); copy_graph(g3, g1, vertex_copy(c)); getchar(); return 0; }