Lemon Graph Library C++ add coordinates in Node

523 Views Asked by At

I have a map with many polygons. I want to do a pathfinding with the "center" of these polygones. So I try to use Lemon Graph Library in order to generate my graph and the Dijkstra 's algorithm.

I see in the Lemon Tutorial :

 ListDigraph g;
 ListDigraph::Node u = g.addNode();
 ListDigraph::Node v = g.addNode();
 ListDigraph::Arc  a = g.addArc(u, v);

My question is : How can I add coordinates in a Node ?

Like :

ListDigraph::Node u = g.addNode(sf::Vector2f(10, 12));
1

There are 1 best solutions below

0
On

You have to include the lemon/dim2.h header file and a ListDigraph::NodeMap. For example, to assign coordinate values to your nodes you would do this:

ListDigraph g;
ListDigraph::NodeMap<dim2::Point<int>> coord(g);

ListDigraph::Node node1 = g.addNode();
coord[node1].x = 0;
coord[node1].y = 0;