On the Use of Factor Graphs in Optical Communications