Code covered by the BSD License  

Highlights from
Matgraph

from Matgraph by Ed Scheinerman
Toolbox for working with simple, undirected graphs

Description of disjoint_union
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:
  • embed embed --- create an embedding for a graph
  • getxy getxy(g) --- give g's embedding (or [] if g doesn't have one)
  • hasxy hasxy(g) --- determine if an embedding has been created for g
  • issparse issparse(g) --- check if g's adjacency matrix is sparse
  • make_logical make_logical(g) --- ensure that the internal storage for g's matrix is a
  • nv nv(g) --- number of vertices in g
  • rmxy rmxy(g) --- erase g's embedding
  • sparse sparse(g) --- convert internal storage for g to sparse
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

Contact us at files@mathworks.com