complete: build complete and complete multipartite graphs
SYNOPSIS
function complete(g,a,b)
DESCRIPTION
complete: build complete and complete multipartite graphs
complete(g) --- convert g to a complete graph on same vertex set
complete(g,a) --- convert g to a complete graph on a vertices
complete(g,a,b) --- convert g to K(a,b)
complete(g,list) --- convert g to a multipartite graph
CROSS-REFERENCE INFORMATION
This function calls:
fast_set_matrix fast_set_matrix(g,A) --- overwrite the adjacency matrix of g with A
0001 function complete(g,a,b)
0002 % complete: build complete and complete multipartite graphs
0003 % complete(g) --- convert g to a complete graph on same vertex set
0004 % complete(g,a) --- convert g to a complete graph on a vertices
0005 % complete(g,a,b) --- convert g to K(a,b)
0006 % complete(g,list) --- convert g to a multipartite graph
0007
0008 global GRAPH_MAGIC
0009
0010 % convert existing graph to complete
0011
0012 if nargin==1
0013 n = nv(g);
0014 fast_set_matrix(g,(ones(n) - eye(n)));
0015 return
0016 end
0017
0018 % overwrite with K_a
0019
0020 if (nargin==2) & (length(a)==1)
0021 fast_set_matrix(g,ones(a)-eye(a));
0022 return
0023 end
0024
0025 % overwrite with K(a,b)
0026
0027 if (nargin==3)
0028 A = zeros(a,a);
0029 B = zeros(b,b);
0030 Z = ones(a,b);
0031 fast_set_matrix(g,[A,Z;Z',B]);
0032 return
0033 end
0034
0035 % last case: complete multipartite graph (a is a list)
0036
0037 n = sum(a);
0038
0039 GRAPH_MAGIC.graphs{g.idx}.array = logical(ones(n));
0040 a = a(:)';
0041 aa = [0,cumsum(a)];
0042 for k=1:length(a)
0043 GRAPH_MAGIC.graphs{g.idx}.array(aa(k)+1:aa(k+1),aa(k)+1:aa(k+1))=0;
0044 end
0045
0046