FactorGraph.jl

Hi everyone,

I would like to announce FactorGraph.jl, a Julia package for constructing factor graphs and running belief propagation algorithms.

The current version covers a fairly broad family of inference algorithms on factor graphs, with support for both Gaussian and discrete models.

Main features include:

  • Gaussian factor graphs with scalar and vector variables
  • Linear Gaussian factors
  • Gaussian belief propagation in moment, canonical, and min-sum form
  • Discrete finite-state factor graphs
  • Iterative sum-product and min-sum belief propagation
  • Forward-backward inference on tree-structured graphs
  • Flooding, sequential, and residual message schedules
  • Dynamic graph updates with stale-inference checks
  • Printing, diagnostics, and graph inspection helpers

The documentation includes separate sections for Gaussian models, discrete models, examples, validation, and API references.

Package repository:

Documentation:

I would be very happy to receive feedback, bug reports, suggestions about the API, or ideas for additional examples and use cases.

Is there anything special about FactorGraph objects that would make it difficult to apply plotting methods?

Thanks for the question. No, there is nothing fundamentally special that should make plotting difficult.

The graph is bipartite: variable nodes and factor nodes are stored separately, and edges connect variables to factors. A simple first step would probably be Graphviz support, for example by exporting the factor graph to DOT format. This would provide basic visualization without introducing a heavy plotting dependency.

Later, a Graphs.jl-compatible conversion could also be useful, together with node metadata such as variable/factor type and labels.

Nice! I‘ve been using GitHub - stecrotti/BeliefPropagation.jl: The Belief Propagation approximation for probability distributions on sparse graphs · GitHub for largish discrete models (10^4 variables with tens of states each and mostly unary and binary factors) and I wonder what advantage your package would give for these cases.

For that specific use case, BeliefPropagation.jl is probably a very strong baseline.

FactorGraph.jl is intended to be more general-purpose. It uses an explicit factor graph architecture where variable nodes and factor nodes can be added and modified easily, which makes it convenient for experimentation, different factor types, schedules, and model updates.

The trade-off is that a specialized structure for large discrete models with mostly unary and binary factors can likely be faster and more memory efficient than this more general architecture. So for that exact setting, the advantage of FactorGraph.jl would mainly be flexibility rather than raw speed.

Thank you for raising this point and for the very useful suggestion. We have added dependency-free SVG visualization to the FactorGraph package, allowing users to inspect Gaussian and discrete factor graphs directly without requiring external plotting dependencies.