# Visual analysis of large sparse matrices with GraphInsight

In the subfield of numerical analysis, a sparse matrix is a matrix populated primarily with zeros (Stoer & Bulirsch 2002, p. 619).

Huge sparse matrices often appear in science or engineering when solving partial differential equations (wikipedia).

Tim Davis from the University of Florida did a great job collecting a myriad of datasets, known as the The University of Florida Sparse Matrix Collection. As the fastcodesign guys say, http://www.fastcodesign.com/1662136/geeky-science-problems-double-as-works-of-art

Timothy Alden Davis, a computer, information science, and engineering professor at the University of Florida, is a sort of Eli Broad with a pocket protector. He’s got the largest open-source collection of sparse matrices in the world [...].

Sparse matrices can be represented as graphs, and this is what they look like using MATLAB/Octave to obtain static visualizations:

A quick view of some sparse matrices in Tim Davis collection

How do we map sparse matrices to weighted graphs? the algorithm for square matrices is straightforward: Given a square sparse matrix M = n x n, its corresponding graph G = (N, E) contains n nodes and the edge between nodes n1 and n2 is weighted as M[n1,n2]. If M[n1,n2] = 0, then there is no edge between nodes n1 and n2.

The interested reader may find more details at this link: Visualizing Sparse Matrices. In addition, there are a few academic references at the end of this post.

You can explore this data interactively using GraphInsight with 2D and 3D layouts. To export square sparse matrices from MATLAB/Octave to the DIMACS format (supported by GraphInsight), you can use the following function:

```function sparse2dimacs(A,filename)
fid = fopen(filename,'wt');
n=length(A);
for i=1:n
klen = length( nonzeros(A(i,[1:(i-1) (i+1):end])) );
fprintf(fid,'%d ( 0.0, 0.0 ) %d ',i, klen );
% find non zero elements of row i
[p]=find(A(i,:));
for m=p
if (i~=m )
fprintf(fid,'%d ',m);
end
end
fprintf(fid,'\n');
end```

In the following, we show some screenshots obtained from GraphInsight. We observe that these are screenshots from interactive 3D visualizations.

UK roads as laid out from GraphInsight Kamada Kawai 2D model. This network represents the UK roads system as laid out from out software GraphInsight. One can note the increased density of roads around the city of London.
This network represents the UK roads system, laid out with GraphInsight FR-ML Prop Multilevel model.
The shallow_water matrix arise from weather shallow water equations (see http://www.icon.enes.org), from the Max-Plank Institute of Meteorology. The problem gives rise to an automatic differentiation problem. An iterative solver is used for the larger problem, but a direct sovler is used for finding the adjoints of a linear problem. The velocity field is integrated over a time loop with a semi-implicit method. The implicit part leads to a linear problem A*x=b, whose entries vary with time. This is a visualization done with GraphInsight which underlines the nodes degree-constantness.

Explore interactively your data with GrahInsight! download your evaluation copy at graphinsight.com. We support Microsoft Windows, Mac OS X, and Linux. Do not hesitate to contact us for any question or problem you may have with our product.

We are seeking for collaborations and work opportunities. Do not hesitate to contact Us at info@graphinsight.com.

Bibliographic notes

This entry was posted in Uncategorized. Bookmark the permalink.

### One Response to Visual analysis of large sparse matrices with GraphInsight

1. Very nice post !