graph complement complement(g) --- overwrite a graph with its own complement complement(g,h) --- overwrite g with the complement of h
0001 function complement(g,h) 0002 % graph complement 0003 % complement(g) --- overwrite a graph with its own complement 0004 % complement(g,h) --- overwrite g with the complement of h 0005 0006 if nargin>1 0007 copy(g,h) 0008 end 0009 0010 % complement only makes sense for full storage 0011 if (issparse(g)) 0012 full(g); 0013 end 0014 0015 n = nv(g); 0016 i = g.idx; 0017 0018 fast_set_matrix(g, ones(n) - eye(n) - matrix(g))