Home > matgraph > @graph > disjoint_union.m

disjoint_union

PURPOSE ^

disjoint_union(g,h,k) --- overwrite g with the disjoint union of the

SYNOPSIS ^

function disjoint_union(g,h,k)

DESCRIPTION ^

 disjoint_union(g,h,k) --- overwrite g with the disjoint union of the
 graphs h and k. 
 If h and k both have embeddings, those embeddings are combined to form an
 embedding for g.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function disjoint_union(g,h,k)
0002 % disjoint_union(g,h,k) --- overwrite g with the disjoint union of the
0003 % graphs h and k.
0004 % If h and k both have embeddings, those embeddings are combined to form an
0005 % embedding for g.
0006 
0007 global GRAPH_MAGIC
0008 
0009 n1 = nv(h);
0010 n2 = nv(k);
0011 
0012 if (issparse(h) | issparse(k))
0013     z = logical(sparse([],[],[],n1,n2,0));
0014 else
0015     z = logical(zeros(n1,n2));
0016 end
0017 
0018 rmxy(g);
0019 
0020 GRAPH_MAGIC.graphs{g.idx}.array = ...
0021     [GRAPH_MAGIC.graphs{h.idx}.array, z; ...
0022      z', GRAPH_MAGIC.graphs{k.idx}.array
0023     ];
0024 make_logical(g);
0025 
0026 if (hasxy(h) & hasxy(k))
0027     xy = [getxy(h);getxy(k)];
0028     embed(g,xy);
0029 end

Generated on Thu 13-Mar-2008 14:23:52 by m2html © 2003