Using the LEMON C++ library and GraphToEps, I am trying to visualize a grid graph with accompanying edge (or arc) weights, without luck. Here's what I've got in my main() so far:
// Create graph and init maps
GridGraph g = GridGraph(5, 5);
GridGraph::NodeMap<Point> coords(g);
GridGraph::EdgeMap<int> weights(g, 1);
// Set positions of nodes for graphToEps use
for(GridGraph::NodeIt u(g); u != INVALID; ++u ) {
coords[u] = g.pos(u);
}
cout << "Create 'graph.eps'" << endl;
graphToEps(g,"graph.eps").
coords(coords).
title("Sample .eps figure").
run();
I can get node text (which I left out of the above code for simplicity) using graphToEps.nodeTexts(id)
, as shown in the graphToEps demo, but I can't find something like edgeTexts(weights(id))
or arcTexts(weights(id))
.
The output of the above code is shown below, and I would like the weights from the map weights
to be on top of the corresponding edges.
Any help is greatly appreciated.
There does not seem to be a built in way to do this. I ended up hooking into the part of graphToEps which prints node text, and then just figure out where to place text for all the edges. All the edges are "printed" as if they were nodes.
I'll probably put in a pull request later this year.