My repository, which I'm already using as a submodule in many of my projects, can be found here:
https://github.com/quantombone/graphviz_matlab_magic
Here is a matlab script (included as a Github gist), which should be ran in an empty directory, and it will download a nice mat file plus clone my repo and show the following nice graph. I perform two graphviz passes where the first one is used to read the graphviz coordinates (from the sfdp embedding) and use Matlab's jet colormap to color the edges based on distances in this space. In other words, nearby nodes which are connected will be connected by red (hot) edges and faraway nodes will be connected by blue (cold) edges.
The matrix visualized comes from an electromagnetic model, the details can be found here: http://www.cise.ufl.edu/research/sparse/matrices/Bai/qc324.html
The original picture generated by Yifan Hu is here for comparison:
Enjoy
--Tomasz
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%Create an empty directory and run this function inside Matlab | |
%Tomasz Malisiewicz (tomasz@csail.mit.edu | |
%Clone my repository with Matlab-graphviz wrappers | |
fprintf(1,'Cloning git repositories\n'); | |
unix(['git clone git@github.com:quantombone/' ... | |
'graphviz_matlab_magic.git']) | |
addpath(genpath(pwd)) | |
%Download a matrix which will be rendered via Graphviz | |
unix('wget http://www.cise.ufl.edu/research/sparse/mat/Bai/qc324.mat') | |
load('qc324.mat'); | |
A = full(real(Problem.A)); | |
params = sexy_graph_params(A); | |
params.sfdp_coloring = 1; | |
params.file_prefix = 'synthetic'; | |
sexy_graph(A,params); | |
fprintf(1,'Now open /tmp/synthetic.pdf\n'); | |
unix('open /tmp/synthetic.pdf'); |
Thanks so much for releasing this. Very useful& works like magic.
ReplyDeleteThanks a lot for releasing this. How is it different from the following interface?
ReplyDeletehttp://www.mathworks.com/matlabcentral/fileexchange/4518
This is awesome. Thank you.
ReplyDeleteHi,
ReplyDeleteIt seems that the script is not really working for me. I sometimes get an empty graph when there should be edges. Does the matrix need to fulfill certain requirements? All my matrices are symmetric matrices. Thank you very much!
I just tried, and it worked for me. I suggest you make sure your graphviz installation is working properly before using the matlab wrappers.
ReplyDelete--Tomasz