**1. Description**

This example, found in the path `MRPT/samples/graph_slam_demo`

, demonstrates:

- the basic
**construction of a graph**of pose constraints, - the execution of a
**graph-slam optimization algorithm**on it (in order to optimize the global node poses given the information in all the edges and one fixed root node), and - how to
**render graphs**as MRPT’s OpenGL primitives.

**Both 2D or 3D graphs** can be generated and optimized, since the example code is templatized.

The optimization algorithm is a Sparse Levenberg-Marquartd iterative method, implemented in the template function mrpt::graphslam::optimize_graph_spa_levmarq(), in the library `mrpt-graphslam`

.

**2. Example snapshots**

**3. Complete source code**

You can browse the complete C++ source code of this example online: https://github.com/MRPT/mrpt/blob/master/samples/graph_slam_demo/