Home > matgraph > @graph > nauty.m

nauty

PURPOSE ^

nauty(g,filename) -- save a graph in nauty format

SYNOPSIS ^

function nauty(g, filename)

DESCRIPTION ^

 nauty(g,filename) -- save a graph in nauty format
 g is the graph, filename is a string containing the filename.
 It is recommended that the file name end ".dre"

 nauty is a program for computing automorphisms of graphs. It can be
 downloaded from http://cs.anu.edu.au/~bdm/nauty/

 Inside the dreadnaut program, type <filename to load the graph saved by
 this function.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function nauty(g, filename)
0002 % nauty(g,filename) -- save a graph in nauty format
0003 % g is the graph, filename is a string containing the filename.
0004 % It is recommended that the file name end ".dre"
0005 %
0006 % nauty is a program for computing automorphisms of graphs. It can be
0007 % downloaded from http://cs.anu.edu.au/~bdm/nauty/
0008 %
0009 % Inside the dreadnaut program, type <filename to load the graph saved by
0010 % this function.
0011 
0012 
0013 fid = fopen(filename,'w');
0014 
0015 if (fid == -1)
0016     error(['Cannot open "', filename, '" for output']);
0017 end
0018 
0019 n = nv(g);
0020 
0021 fprintf(fid,'$ 1\n');     % sets nauty to start number vertices from 1
0022 fprintf(fid,'n=%d\n', n); % write the number of vertices
0023 fprintf(fid,'g\n');       % begin the graph
0024 
0025 for v=1:n
0026     Nv = neighbors(g,v);
0027     Nv = Nv(Nv>v);
0028     if isempty(Nv)
0029         continue
0030     end
0031     fprintf(fid,'%d: ', v);
0032     fprintf(fid,'%d ', Nv);
0033     fprintf(fid,';\n');
0034 end
0035 
0036 
0037 fprintf(fid,'.\n');       % end writing the graph
0038

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