I think after implementing loopy inference, we could have both cases in the so_factorgraph.cpp, but currently we can't do inference on grid graph.