Home > matgraph > @graph > union.m

union

PURPOSE ^

union(g,h1,h2) --- set g equal to the union of h1 and h2.

SYNOPSIS ^

function union(g,h1,h2)

DESCRIPTION ^

 union(g,h1,h2) --- set g equal to the union of h1 and h2.
 The vertices of g are the union of the vertex sets of h1 and h2, and the
 edge set of g is the union of the edge sets of h1 and h2.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function union(g,h1,h2)
0002 % union(g,h1,h2) --- set g equal to the union of h1 and h2.
0003 % The vertices of g are the union of the vertex sets of h1 and h2, and the
0004 % edge set of g is the union of the edge sets of h1 and h2.
0005 
0006 global GRAPH_MAGIC
0007 
0008 n1 = nv(h1);
0009 n2 = nv(h2);
0010 
0011 g1 = graph;
0012 g2 = graph;
0013 
0014 copy(g1,h1);
0015 copy(g2,h2);
0016 
0017 if n1 < n2
0018     resize(g1,n2)
0019 else
0020     resize(g2,n1)
0021 end
0022 
0023 GRAPH_MAGIC.graphs{g.idx}.array = ...
0024     double(matrix(g1) | matrix(g2));
0025 
0026 free(g1);
0027 free(g2);

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