Delmond / Factor-Graph-Visualizer

A short python script to visualize factor graphs passed in as matrix inputs.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Factor Graph Visualizer

A short script written in python3 for factor graph visualization.

Setup

This script relies on the graph-tool utility. Please follow the installing instructions on their wegraphage before using this script.

Usage:

python visualise.py -i /path/to/matrix.txt -o drawn_graph.png

Examples

First example

Given the following matrix:

14 12
1     0     0     0      0      0      0      0      0      0      0      0 
0     0     1     0      0      1      0      0      0      0      0      0 
0     0     0     1      0      0      0      0      0      0      0      0 
0     0     0     0      1      0      0      0      0      0      0      0 
1     1     0     0      0      1      0      1      0      0      0      0 
0     0     0     1      0      0      0      0      1      0      0      0 
0     0     0     0      1      0      1      0      0      1      0      0 
0     0     0     0      0      0      0      0      1      0      0      0 
0     0     0     0      0      0      0      0      0      1      0      0 
0     0     0     0      0      0      0      1      1      0      1      0 
0     0     0     0      0      0      0      0      0      1      0      1 
0     0     0     0      0      0      0      0      0      0      1      0 
0     0     0     0      0      0      0      0      0      0      1      1 
0     0     0     0      0      1      0      0      0      0      0      0 

The generated factor graph is:

Second example

Given the following matrix:

1         0         0         0         0         0         1         0         0
0         1         0         0         0         0         0         0         0
0         0         0         0         1         0         0         0         0
0         0         0         0         0         1         0         1         0
0         0         0         0         0         0         1         0         0
1         1         1         1         0         0         0         0         0
0         1         1         0         0         0         0         0         0
0         1         0         1         1         0         0         0         0
0         0         0         1         1         0         0         0         0
0         0         0         0         0         1         1         0         0
0         0         0         0         1         0         0         0         1
0         0         0         0         1         0         0         0         0
0         0         0         0         1         0         0         0         0
0         0         1         0         0         0         0         1         0
1         0         0         1         0         0         0         0         0
0         1         0         1         0         0         0         0         0
0         1         0         0         0         0         0         0         0

The generated factor graph is:

About

A short python script to visualize factor graphs passed in as matrix inputs.

License:MIT License


Languages

Language:Python 100.0%