A factor graph is a bipartite graphical model that explicitly represents the factorization of a global function into a product of simpler local functions, or factors. In Simultaneous Localization and Mapping (SLAM), this global function is typically a joint probability distribution over unknown variables like robot poses and landmark positions. The graph's two node types are variable nodes (unknown states) and factor nodes (probabilistic constraints from sensor measurements), with edges connecting each factor to the variables it constrains. This structure cleanly separates the estimation problem from the specific sensor models.
Glossary
Factor Graph

What is a Factor Graph?
A factor graph is a bipartite graphical model that represents the factorization of a complex probability distribution, commonly used in modern SLAM back-ends to structure the optimization problem.
The primary power of the factor graph formulation in robotics and computer vision is its efficiency for incremental smoothing and mapping. When a new sensor measurement arrives, it is added as a new factor node, and only affected parts of the graph need re-optimization. This makes it the backbone of modern graph-based SLAM and bundle adjustment systems. Optimization algorithms, like Gauss-Newton or Levenberg-Marquardt, operate directly on this graph to find the maximum a posteriori (MAP) estimate by minimizing the sum of squared residual errors encoded by the factors.
Key Components of a Factor Graph
A factor graph decomposes a complex probability distribution into a product of simpler local functions. Its structure directly encodes the dependencies and constraints within a SLAM optimization problem.
Variable Nodes
Represent the unknown quantities to be estimated. In SLAM, these are typically:
- Robot poses at different timestamps (e.g., position and orientation).
- Landmark positions (3D points or features in the map). Each node holds a belief (probability distribution) about its state, which is refined during optimization.
Factor Nodes
Encode constraints and measurements that connect variables. Each factor represents a local function in the factorization of the joint probability distribution.
- Odometry factors model motion between consecutive poses.
- Landmark observation factors connect a pose to a landmark based on a sensor measurement (e.g., a camera projection).
- Loop closure factors impose strong constraints when a place is re-recognized, correcting accumulated drift.
- Prior factors anchor the graph with absolute information (e.g., a known starting pose).
Edges (Connections)
Edges connect factor nodes to the variable nodes they constrain. An edge exists only between a factor and a variable. This bipartite structure makes dependencies explicit:
- A unary factor connects to one variable (e.g., a prior).
- A binary factor connects to two variables (e.g., an odometry constraint between two poses).
- A higher-order factor can connect to multiple variables (e.g., a visual reprojection factor linking one landmark and two observing poses).
The Joint Probability Distribution
The entire factor graph represents the factorization of the system's posterior probability. If X is the set of all variables and Z is the set of all measurements/factors, the graph models:
P(X | Z) ∝ ∏ᵢ fᵢ(Xᵢ)
where each fᵢ is a factor function over a subset of variables Xᵢ. In SLAM, this is typically a Maximum A Posteriori (MAP) estimation problem: finding the variable values that maximize this product.
The Optimization Back-End
The factor graph structure is solved via non-linear least squares optimization. Under the assumption of Gaussian noise models, each factor corresponds to a squared error term in a cost function. The optimization (e.g., using Gauss-Newton or Levenberg-Marquardt algorithms) adjusts the variable node estimates to minimize the sum of these errors, reconciling all constraints. Libraries like g2o, GTSAM, and Ceres Solver are built to efficiently perform this inference on factor graphs.
Comparison to Pose Graphs
A pose graph is a specific, simplified type of factor graph used in SLAM.
- Pose Graph: Variable nodes are only robot poses. Factors represent constraints between poses (odometry, loop closures). Landmarks are marginalized out.
- Full Factor Graph: Variable nodes include both poses and landmarks. Factors include direct observation constraints between poses and landmarks. Pose graphs are more compact; full factor graphs preserve more information but are larger. Modern graph SLAM systems often use a hybrid or sliding-window approach.
How Factor Graphs Work in SLAM
A factor graph is the core data structure used in modern optimization-based SLAM back-ends to represent and solve the underlying inference problem.
A factor graph is a bipartite graphical model that explicitly represents the factorization of a complex probability distribution, structuring the maximum a posteriori (MAP) estimation problem central to Graph SLAM. In SLAM, nodes represent unknown random variables (robot poses and landmark positions), while factors represent probabilistic constraints (sensor measurements and motion models) that connect them. This factorization allows the joint probability of all variables given all measurements to be broken into a product of simpler, local functions.
The graph is optimized by minimizing the negative log-likelihood of all factors, which translates to solving a non-linear least squares problem. Each factor encodes a cost function penalizing deviations from its associated measurement, such as odometry or a landmark observation. Back-end optimization algorithms, like Gauss-Newton or Levenberg-Marquardt, efficiently exploit the graph's sparse connectivity to compute the optimal configuration of all poses and map points, correcting for accumulated drift and enforcing global consistency through loop closure constraints.
Examples and Frameworks
Factor graphs are a foundational data structure in modern probabilistic robotics. This section details their practical implementations, key software frameworks, and their specific role in structuring the optimization problems central to SLAM.
The Core SLAM Back-End
In modern Graph SLAM, the factor graph is the explicit data structure for the back-end optimization. It encodes the complete inference problem:
- Nodes (Variables): Represent unknown quantities—robot poses (
x1, x2,...) and landmark positions (l1, l2,...). - Factors (Constraints): Represent probabilistic measurements connecting nodes. Each factor defines a cost function based on sensor models.
- Examples: An odometry factor connects two consecutive pose nodes. A landmark observation factor connects a pose node and a landmark node. The goal is to find the variable assignments (the map and trajectory) that maximize the product of all factors, which is equivalent to minimizing the sum of negative log-likelihoods—a non-linear least squares problem.
iSAM2: Incremental Smoothing and Mapping
iSAM2 (Incremental Smoothing and Mapping 2) is a canonical algorithm for real-time factor graph optimization in SLAM. Its key innovation is incremental and bayesian tree-based updating.
- Incremental Solving: Instead of re-solving the entire graph from scratch, iSAM2 efficiently updates the solution as new factors (measurements) are added, which is critical for online robotics.
- Elimination and the Bayes Tree: It uses variable elimination to transform the factor graph into a Bayes tree, a data structure that allows for efficient re-linearization and updates only to affected parts of the solution.
- Impact: This algorithm enabled practical, large-scale SLAM in real-time and is the optimization engine behind frameworks like GTSAM.
From Pose Graphs to Dense Factors
Factor graphs scale in complexity based on the problem formulation:
- Pose Graph: A simplified factor graph containing only pose variables. Edges are odometry and loop closure constraints. This is the core of pose graph SLAM after marginalizing out landmarks.
- Landmark-based Graph: Includes both pose and landmark variables, with factors for all observations. This is the full Bundle Adjustment problem.
- Dense Factors: Modern approaches use photometric error or point-to-plane ICP error as factors, creating a graph with a very large number of constraints (one per pixel or point). This moves from sparse feature-based to direct or dense SLAM formulations, where the factor graph principle remains the same but the computational challenge increases significantly.
Frequently Asked Questions
A factor graph is a core data structure in modern probabilistic robotics, providing the mathematical scaffolding for solving complex state estimation problems like SLAM. These questions address its fundamental mechanics, role, and practical implementation.
A factor graph is a bipartite graphical model that explicitly represents the factorization of a complex, global probability distribution into a product of simpler, local functions called factors. It works by structuring an inference problem—like estimating a robot's trajectory and a map in SLAM—as a graph with two types of nodes: variable nodes (representing unknown states like robot poses and landmark positions) and factor nodes (representing probabilistic constraints or measurements connecting those variables). The graph's connectivity encodes which variables are involved in each measurement. Solving the estimation problem then becomes the task of finding the variable values that maximize the product of all factors, which is typically achieved through non-linear least squares optimization.
For example, in a SLAM context, a factor graph might have:
- Variable Nodes:
pose_1,pose_2,landmark_A - Factor Nodes: An odometry factor connecting
pose_1andpose_2(from wheel encoders/IMU), and a landmark observation factor connectingpose_2andlandmark_A(from a camera or LiDAR). The optimizer adjusts the values of the variable nodes to best satisfy all the constraints imposed by the factors.
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
Factor graphs are a core data structure within modern SLAM back-ends. These related concepts define the mathematical and algorithmic framework for solving the underlying state estimation problem.
Graph SLAM
Graph SLAM is an optimization-based approach to the Simultaneous Localization and Mapping problem. It formulates the entire history of robot poses and landmark observations as a graph:
- Nodes represent variables to estimate (robot poses, landmark positions).
- Edges represent constraints between nodes, derived from sensor measurements (odometry, loop closures). The goal is to find the configuration of nodes that maximizes the probability of all constraints, typically solved via non-linear least squares optimization. Factor graphs provide the explicit factorization of this probability distribution.
Pose Graph
A pose graph is a simplified, but highly common, instance of a factor graph used in SLAM. It is a graph where:
- Nodes represent robot poses (position and orientation) at different times.
- Edges represent relative pose constraints between these nodes. These constraints come from odometry measurements between consecutive poses or from loop closure detections between non-consecutive poses. Optimizing the pose graph corrects accumulated drift and produces a globally consistent trajectory. It is a specialization where the factor graph's variables are exclusively poses.
Bundle Adjustment
Bundle Adjustment is a classic non-linear optimization technique in computer vision and photogrammetry that is naturally expressed as a factor graph. It jointly refines:
- The 3D coordinates of a set of scene points (landmarks).
- The camera poses from which those points were observed. The optimization minimizes the total reprojection error—the difference between the observed 2D image locations of features and their projected 3D positions. In a Visual SLAM factor graph, each camera pose-landmark observation forms a binary factor connecting a pose node and a landmark node.
Back-End Optimization
In the SLAM pipeline, the back-end optimization is the process that takes the noisy measurements and constraints generated by the front-end (e.g., visual odometry, loop closure detection) and infers the most probable map and trajectory. The factor graph is the central model used in modern back-ends. Solving this graph involves:
- Linearization of non-linear measurement models (e.g., using a Jacobian).
- Constructing and solving a large, sparse system of linear equations, often via methods like Gauss-Newton or Levenberg-Marquardt. This process is what corrects errors and ensures global consistency.
Bayes Network / Markov Random Field
Factor graphs are closely related to other probabilistic graphical models:
- A Bayesian network is a directed graphical model representing conditional dependencies. The factorization it represents can be converted into a factor graph.
- A Markov Random Field is an undirected graphical model representing local dependencies. Factor graphs provide a more explicit representation of the factorization in both cases.
In SLAM, the underlying estimation problem has a natural probabilistic structure (e.g.,
P(poses, landmarks | measurements)), which these models describe. The factor graph is often the preferred representation for performing efficient inference via message passing or linear algebra.
Incremental Smoothing and Mapping (iSAM)
iSAM is a seminal algorithm for efficient, incremental solution of factor graphs in SLAM. Instead of re-solving the entire optimization from scratch each time a new measurement (factor) is added, iSAM:
- Updates the solution by modifying only the parts of the factorization (e.g., QR, Cholesky) affected by the new data.
- Periodically performs variable reordering to maintain sparsity and efficiency.
- Enables real-time performance for large-scale, long-term SLAM. It is a prime example of an inference engine designed specifically for the sparse, incremental factor graphs generated by robotic state estimation.

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