Page 1

template <class T> void ledaToGraphviz( GRAPH<T,T> &G, array<list<node>> &AB, int KEYWSIZE, char *filename, node_array<leda::color> &Colors, bool colorsFlag , node_array<leda::string> &nodeNames, bool nodeNamesFlag ){ node n; list_item it; edge e; list<node> n_temp; char filename2[ 32 ]; sprintf( filename2, "%s.txt", filename ); FILE *fptr; if( ( fptr = fopen( filename2, "w" ) ) == NULL ){ cout << "\n File open error, could not find specified files \n"; } else{ fprintf( fptr, "/*%s%s%s*/", filename, " is produced by ", " LEDA to Graphviz convertor" ); fprintf( fptr, "%s%s%s\n", "digraph ", "filename", "{" ); for( int i = 0; i < KEYWSIZE; i++ ){ fprintf( fptr, "%s" ,"{rank=same; " ); n_temp = AB[ i ]; n_temp.print(); forall_items( it, n_temp ){ cout << G[ n_temp[ it ] ]; if( G[ n_temp[ it ] ] != 0 ) fprintf( fptr, " %d ", G[ n_temp[ it ] ] ); } fprintf( fptr, "%s\n" ,";}" ); }

} }

forall_nodes( n, G ){ if( nodeNamesFlag == false ){ if( colorsFlag == false ) fprintf( fptr, "%d [label = %d ]\n", G[ n ], G[ n ] ); else fprintf( fptr, "%d [label = %d, color = %s ]\n", G[ n ], G[ n ], Colors[ n ] ); } else{ if( colorsFlag == false ) fprintf( fptr, "%d [label = %d ]\n", G[ n ], nodeNames[ n ] ); else fprintf( fptr, "%d [label = %d, color = %s ]\n", G[ n ], nodeNames[ n ], Colors[ n ] } } forall_edges( e, G ){ fprintf( fptr, " %d -> %d [label = %d ]\n", G[ G.source( e ) ], G[ G.target( e ) ], G[ e ] ); } fprintf( fptr, "%s", "}" ); fclose( fptr );

);

Coding Part  

Convertor Leda to Graphviz