Skip to content

Instantly share code, notes, and snippets.

@karlnapf
Created June 15, 2013 12:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save karlnapf/5787975 to your computer and use it in GitHub Desktop.
Save karlnapf/5787975 to your computer and use it in GitHub Desktop.
probe a graph colouring
function [V,colours] = probe( colours)
%% function [V] = probe(A,p)
% Creates a probing matrix based on a graph colouring of A using the
% algorithm in "J. Tang and Y. Saad, A probing method for computing the diagonal of the matrix
% inverse" (2010).
%
% REQUIRES: Matgraph toolbox http://www.ams.jhu.edu/~ers/matgraph/
%
% Input: colours - A graph colouring (of A^p probably)
%
% Output: V - Probing matrix V
%
% Author: Daniel Simpson
% Date: 26/08/2010
%
% There is no waranty or guarentee of any kind associated with this code.
%%
%Calculate adjacency graph of the pth nearest neighbour graph.
n = length(colours);
ncolours = max(colours);
V = zeros(n,ncolours);
for i = 1:ncolours
V(colours==i,i)=sign(randn(sum(colours==i),1));
end
% keyboard;
% free(g);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment