Code covered by the BSD License  

Highlights from
Matgraph

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

Description of complement
Home > matgraph > @graph > complement.m

complement

PURPOSE ^

graph complement

SYNOPSIS ^

function complement(g,h)

DESCRIPTION ^

 graph complement
 complement(g) --- overwrite a graph with its own complement
 complement(g,h) --- overwrite g with the complement of h

CROSS-REFERENCE INFORMATION ^

This function calls:
  • copy copy(g,h) --- overwrite g with a copy of h
  • fast_set_matrix fast_set_matrix(g,A) --- overwrite the adjacency matrix of g with A
  • full full(g) --- convert internal storage for g to full
  • issparse issparse(g) --- check if g's adjacency matrix is sparse
  • matrix matrix(g) --- return (a copy of) the adjacency matrix of g
  • nv nv(g) --- number of vertices in g
This function is called by:
  • omega [w,S] = omega(g) --- clique number

SOURCE CODE ^

0001 function complement(g,h)
0002 % graph complement
0003 % complement(g) --- overwrite a graph with its own complement
0004 % complement(g,h) --- overwrite g with the complement of h
0005 
0006 if nargin>1
0007     copy(g,h)
0008 end
0009 
0010 % complement only makes sense for full storage
0011 if (issparse(g))
0012     full(g);
0013 end
0014 
0015 n = nv(g);
0016 i = g.idx;
0017 
0018 fast_set_matrix(g, ones(n) - eye(n) - matrix(g))

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

Contact us at files@mathworks.com