Home > matgraph > @graph > intersect.m

intersect

PURPOSE ^

intersect(g,h1,h2) --- g is set to the intersection of h1 and h2.

SYNOPSIS ^

function intersect(g,h1,h2)

DESCRIPTION ^

 intersect(g,h1,h2) --- g is set to the intersection of h1 and h2.
 The vertex set of g is intersection of the vertex sets of h1 and h2, and
 the edge set of g is the intersection of the edge sets of h1 and h2.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

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

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