code: def factorgraph_viz(d):
          
          m = defaultdict(list)
  
          for node in d['nodes']:
              m['nodes'].append(dict(
                  id=node['id'],
                  type='rv'
              ))
  
          for factor in d['factors']:
              m['nodes'].append(dict(
                  id=factor['id'],
                  type='fac'
              ))
  
              for source in factor['sources']:
                  m['links'].append(dict(
                      source=source,
                      target=factor['id']
                  ))
              if factor['sink']:
                  m['links'].append(dict(
                      source=factor['id'],
                      target=factor['sink']
                  ))
  
          return dict(m)
docs: Map the dictionary into factorgraph-viz format. See https://github.com/mbforbes/factorgraph-viz
  
          :param d: The dictionary
          :return: The formatted dictionary