/* * import CDG-file (CDG ... CostDelayGraph) */ int InstanceHandler::readCDG( Graph& graph, const char* filename ) { ifstream file( filename ); if( !file.good() ) { cerr << "File error." << endl; return -1; } u_int n_nodes; int cost; int delay; // line 1: number of nodes if( file >> n_nodes ) graph.setNumberOfNodes( n_nodes ); else return -1; // line 2 - EOF: edges (" ") of complete graph for( u_int i = 0; i < n_nodes; i++ ) { for( u_int j = i + 1; j < n_nodes; j++ ) { if( file >> cost >> delay ) graph.addEdge( i, j, cost, delay ); else return -1; } } file.close(); // the root node is always set to 0 graph.setRootNode( 0 ); return 0; }