In [13]:
import chompack as cp
from cvxopt import spmatrix, matrix, printing, lapack
printing.options['width'] = 18

In [14]:
L = [[0,2,3,4,14],[1,2,3],[2,3,4,14],[3,4,14],[4,8,14,15],[5,8,15],[6,7,8,14],[7,8,14],[8,14,15],[9,10,12,13,16],[10,12,13,16],[11,12,13,15,16],[12,13,15,16],[13,15,16],[14,15,16],[15,16],[16]]
I = []
J = []
for k,l in enumerate(L):
    I.extend(l)
    J.extend(len(l)*[k])
    
A = spmatrix(1.0,I,J,(17,17))
#mf = cp.merge_size_fill(tfill = 2, tsize = 2)
mf = None
symb = cp.symbolic(A, merge_function = mf)
print symb


[X X                       X X   X]
[X X                       X X   X]
[    X   X X                      ]
[      X X X       X   X          ]
[    X X X X       X   X          ]
[    X X X X       X   X          ]
[            X       X         X  ]
[              X X   X X          ]
[              X X   X X          ]
[      X X X       X X X       X  ]
[            X X X X X X       X  ]
[      X X X   X X X X X       X X]
[                        X X X X X]
[X X                     X X X X X]
[X X                     X X X X X]
[            X     X X X X X X X X]
[X X                   X X X X X X]


In [15]:
print "Id Parent Supernode"
for k,sk in enumerate(symb.supernodes()):
    print "%2i  %2i   "%(k,symb.snpar[k]),sk


Id Parent Supernode
 0   7    [0, 1]
 1   2    [2]
 2   5    [3, 4, 5]
 3   5    [6]
 4   5    [7, 8]
 5   6    [9, 10]
 6   7    [11]
 7  -1    [12, 13, 14, 15, 16]

In [16]:
At = cp.cspmatrix(symb) + A + spmatrix(1.0,range(symb.n),range(symb.n))
X = cp.psdcompletion(At)

In [17]:
imshow(X, interpolation = 'nearest')
colorbar()


Out[17]:
<matplotlib.colorbar.Colorbar instance at 0x10df9b320>

In [12]:
imshow(matrix(At.spmatrix(symmetric=True)), interpolation = 'nearest')
colorbar()


Out[12]:
<matplotlib.colorbar.Colorbar instance at 0x10dd6e5f0>