I'm trying to reproduce the experiments carried out in this paper, measuring the performance of an algorithm on the DIMACS Vertex-Coloring benchmark graphs, which can be found here.
The graphs are in the DIMACS Standard format, and I'd like to parse them into the C++ Boost Graph Library format, so I can run my algorithm on them.
I've tried parsing them using the existing Boost DIMACS functions, but the documentation on them is fairly sparse, so I'm unclear on how exactly to use the functions. When I print the graph to Graphviz, the result doesn't seem to match the DIMACS file.
I'm wondering:
What am I doing wrong using the Boost parsing functions? (See example below)
Is there a better or alternative C++ library for easily parsing the DIMACS standard graph format?
Here's my attempt at parsing and printing the graphs:
#include <cstdlib>
#include <iostream>
#include <boost/property_map/property_map.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/graphviz.hpp>
#include <boost/graph/dimacs.hpp>
#include <fstream>
using namespace boost::graph;
typedef boost::adjacency_list < boost::vecS, boost::vecS, boost::undirectedS > Graph;
typedef typename boost::graph_traits<Graph>::edge_descriptor Edge;
typedef typename boost::graph_traits<Graph>::vertex_descriptor Vertex;
int main()
{
std::ifstream inGraphFile;
inGraphFile.open("myciel4.col");
dimacs_basic_reader reader(inGraphFile, false);
dimacs_basic_reader end;
dimacs_edge_iterator<dimacs_basic_reader> dimacsStart(reader);
dimacs_edge_iterator<dimacs_basic_reader> endIter(end);
Graph g2(dimacsStart, endIter, reader.n_vertices());
boost::write_graphviz(std::cout, g2);
}
