In robotics and computer vision, graph optimization formulates problems like Simultaneous Localization and Mapping (SLAM) as a graph. Here, nodes represent unknown variables (e.g., robot poses, landmark positions), and edges represent constraints between them derived from sensor measurements (e.g., odometry, loop closures). The goal is to find the configuration of node values that minimizes the total error across all constraints, a process known as bundle adjustment or graph-based SLAM.
Glossary
Graph Optimization

What is Graph Optimization?
Graph optimization is a mathematical framework for solving large-scale estimation problems by representing them as a network of variables and constraints, which is then solved via nonlinear least squares.
The solution is typically found using iterative nonlinear least squares solvers like Levenberg-Marquardt or Gauss-Newton, which linearize the constraints around the current estimate. This approach is highly scalable and can efficiently handle sparse problems, making it the backbone of modern state estimation systems. It is directly related to probabilistic inference on a factor graph, where the optimized graph represents the maximum likelihood estimate of the system's state.
Key Characteristics of Graph Optimization
Graph optimization, or graph-based SLAM, formulates the simultaneous localization and mapping (SLAM) problem as a graph of constraints, which is then solved via nonlinear least squares. Its core characteristics define its power and applicability in robotics and autonomous systems.
Factor Graph Representation
The core abstraction of graph-based SLAM is the factor graph, a bipartite graph that factorizes a complex probability distribution. Nodes represent variables like robot poses or landmark positions. Edges, or factors, represent constraints derived from sensor measurements (e.g., odometry, lidar scans, loop closures). This representation cleanly separates the probabilistic model from the optimization algorithm, making the system modular and extensible. For example, adding a new sensor type simply requires defining a new factor that computes error based on its measurements.
Sparse Nonlinear Least Squares
The primary computational method for solving the graph is sparse nonlinear least squares. The goal is to find the configuration of node variables that minimizes the sum of squared errors from all factors. Crucially, the Hessian matrix (the matrix of second derivatives) of this problem is inherently sparse because each factor only connects a small subset of nodes. This sparsity enables the use of highly efficient solvers like g2o, GTSAM, or Ceres Solver, which employ Cholesky or QR factorization on the sparse matrix, allowing real-time optimization of maps with thousands of poses.
Incremental Optimization & Loop Closure
Graph optimization excels at handling loop closures—when a robot recognizes a previously visited location. This creates a new constraint in the graph between non-sequential poses. The optimization then distributes the resulting error across the entire trajectory, correcting the accumulated drift from odometry. Modern systems use incremental solvers (like iSAM2) that update the solution efficiently as new factors are added, rather than re-solving from scratch. This is critical for online SLAM where the map must be updated in real-time as the robot moves.
Robust Cost Functions
Real sensor data contains outliers (e.g., incorrect loop closures from perceptual aliasing). To maintain system integrity, graph optimization employs robust cost functions (or robust kernels) like Huber, Cauchy, or DCS. These functions reduce the influence of large residual errors during optimization, preventing a single bad measurement from corrupting the entire map. This is a form of M-estimation integrated directly into the least-squares framework. The choice of kernel is a key hyperparameter that balances sensitivity to outliers against convergence speed.
Pose Graph vs. Full SLAM
There are two main graph formulations. The pose graph is a simplification where landmarks are marginalized out; nodes represent only robot poses, and edges represent constraints between them. This drastically reduces the problem size and is standard for lidar SLAM. Full SLAM includes both pose and landmark nodes, preserving the full posterior distribution. It is more expressive and accurate but computationally heavier, often used in visual SLAM (e.g., ORB-SLAM) where re-observing visual features provides rich constraints.
Covariance & Uncertainty Estimation
A major advantage over filtering approaches (like EKF) is the direct access to the covariance matrix of the entire estimated state. After optimization, the marginal covariance for any node or set of nodes can be recovered from the inverted Hessian (the information matrix). This provides a principled measure of uncertainty for each estimated pose and landmark, essential for tasks like active exploration, path planning under uncertainty, and sensor fusion with other estimators. The information matrix's sparsity mirrors the graph's connectivity.
Graph Optimization vs. Filtering Approaches
A technical comparison of two core paradigms for solving the Simultaneous Localization and Mapping (SLAM) problem in robotics and autonomous systems.
| Feature / Metric | Graph Optimization (Graph-Based SLAM) | Filtering Approaches (e.g., EKF, UKF, Particle Filter) |
|---|---|---|
Core Formulation | Formulated as a large-scale nonlinear least squares problem over a pose graph. | Formulated as recursive Bayesian estimation (predict-update cycle). |
Primary Output | A globally consistent map and trajectory after processing a batch of data. | The current best estimate of the state (pose, map) at the latest timestep. |
Historical Data Handling | Explicitly retains and optimizes over all historical poses (full trajectory). | Typically marginalizes out past states, summarizing them in a current belief state (e.g., covariance matrix). |
Computational Profile | Batch or incremental optimization; complexity grows with graph size. Offline or online with loop closures. | Constant time per update (O(k³) for state dimension k). Designed for strict real-time streaming. |
Loop Closure Handling | Native strength. Adding a loop closure edge triggers a global re-optimization of the entire graph. | Challenging. Requires augmenting the state or using sophisticated techniques to avoid covariance inconsistency. |
Accuracy vs. Compute | Generally higher accuracy due to global consistency, at the cost of higher latency for optimization. | Generally lower latency, but can accumulate unbounded drift without explicit loop closure mechanisms. |
Memory Usage | Higher. Stores a graph of nodes (poses/landmarks) and edges (constraints). | Lower. Stores only the current state vector and its covariance (or particle set). |
Typical Use Case | Post-processing, mapping, or online systems where occasional optimization latency is acceptable (e.g., autonomous vehicle HD mapping). | Systems requiring hard real-time, low-latency state estimates for control (e.g., drone flight stabilization, visual-inertial odometry). |
Underlying Math | Sparse linear algebra (solving Ax=b via Cholesky decomposition or Conjugate Gradient on the information matrix). | Linear algebra for Kalman variants (matrix inversions); Monte Carlo sampling for particle filters. |
Robustness to Linearization Errors | Often uses more accurate nonlinear optimizers (e.g., Levenberg-Marquardt) that iteratively relinearize. | EKF linearizes once per step at the current estimate; UKF uses unscented transform for better nonlinear handling. |
Frequently Asked Questions
Graph optimization, or graph-based SLAM, formulates the SLAM problem as a graph where nodes represent robot poses or landmarks and edges represent constraints from sensor measurements, which is then solved via nonlinear least squares.
Graph optimization, also known as graph-based SLAM, is a framework for solving the Simultaneous Localization and Mapping (SLAM) problem by representing it as a factor graph. It works by constructing a graph where nodes represent the robot's poses (positions and orientations) and/or landmark positions at different times, and edges represent constraints between these nodes derived from sensor measurements (e.g., odometry, lidar scans, loop closures). The goal is to find the configuration of node states that maximizes the likelihood of all the measured constraints, which is formulated as a nonlinear least squares problem and solved using iterative optimization algorithms like Gauss-Newton or Levenberg-Marquardt.
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Related Terms
Graph optimization is a core technique within sensor fusion and SLAM. These related concepts define the mathematical frameworks, algorithms, and system architectures that enable robust state estimation from noisy, multi-sensor data.
Factor Graph
A factor graph is a bipartite graph used to represent the factorization of a complex probability distribution. In sensor fusion and SLAM, it provides a visual and computational structure where:
- Variable nodes represent unknown states (e.g., robot poses, landmark positions).
- Factor nodes represent probabilistic constraints derived from sensor measurements or motion models. This graphical representation directly translates into the nonlinear least squares problem solved in graph-based SLAM, making the optimization's sparsity pattern explicit for efficient computation.
Simultaneous Localization and Mapping (SLAM)
Simultaneous Localization and Mapping is the computational problem of constructing a map of an unknown environment while simultaneously tracking an agent's location within it. Graph optimization, or graph-based SLAM, is a leading backend solution for this problem. It formulates the entire history of poses and landmarks as a graph, which is then optimized to find the most probable configuration given all sensor constraints. This approach is favored for its ability to perform loop closure—correcting accumulated drift by recognizing previously visited places.
Bayesian Filtering
Bayesian filtering is the overarching probabilistic framework for recursively estimating the state of a dynamic system from a sequence of noisy observations. It maintains a belief state (the posterior) that is updated as new data arrives. Key algorithms are special cases of this framework:
- Kalman Filter: Optimal for linear, Gaussian systems.
- Extended/Unscented Kalman Filter (EKF/UKF): Handle nonlinearities.
- Particle Filter: Handles non-Gaussian distributions via sampling. While filters are online (sequential), graph optimization is often batch or sliding-window, re-optimizing over a history of states for greater accuracy at higher computational cost.
State Estimation
State estimation is the process of inferring the hidden variables (the state) of a dynamic system from indirect, noisy sensor measurements. The state typically includes quantities like position, velocity, and orientation. This is the fundamental goal of sensor fusion. Graph optimization achieves state estimation by framing it as a maximum a posteriori (MAP) inference problem. It finds the set of states (e.g., all robot poses in a trajectory) that are most consistent with the entire set of sensor measurements, rather than just the most recent one.
Robust Estimation
Robust estimation refers to statistical methods designed to be insensitive to outliers—erroneous measurements that violate assumed noise models. In graph optimization for robotics, outliers are common due to sensor noise, incorrect data association, or dynamic objects. Techniques like:
- M-estimators (e.g., Huber, Cauchy loss) replace the quadratic cost function with one that grows more slowly for large residuals.
- RANSAC (Random Sample Consensus) identifies inlier sets. These methods are critical for preventing a few bad measurements from corrupting the entire optimized graph, ensuring system reliability in real-world, cluttered environments.
Covariance Matrix & Mahalanobis Distance
The covariance matrix is a square matrix representing the uncertainty (variance) of a state estimate and the correlations between its components. In graph optimization, the Hessian (information matrix) is inverted to solve the system and obtain the covariance, which quantifies the precision of the estimated poses and landmarks.
The Mahalanobis distance is a statistical distance measure that accounts for this covariance. It is used extensively in sensor fusion for:
- Gating: Determining if a new sensor measurement is plausible enough to be associated with an existing track.
- Outlier Rejection: Identifying measurements that are statistically improbable given the current state uncertainty.

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us