Home > Mateda2.0 > knowledge_extraction > visualization > MakePajekGraphFromDag.m

MakePajekGraphFromDag

PURPOSE ^

MakePajekGraphGraphFromDag(dag,pajekfilename)

SYNOPSIS ^

function MakePajekGraphFromDag(dag,pajekfilename)

DESCRIPTION ^

 MakePajekGraphGraphFromDag(dag,pajekfilename)
 MakePajekGraphFromDag:  Creates a graph in .net format (to be read by
 Pajek program http://vlado.fmf.uni-lj.si/pub/networks/pajek/ ) of the Bayesian network with structure in dag
 Pajek allows sophisticated network analysis and visualization 
 INPUTS
 dag: Bayesian network structure 
 pajekfilename: Name of the pajek file containing the structure of the
 network

 Last version 3/9/2009. Roberto Santana (roberto.santana@ehu.es)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function  MakePajekGraphFromDag(dag,pajekfilename)
0002 % MakePajekGraphGraphFromDag(dag,pajekfilename)
0003 % MakePajekGraphFromDag:  Creates a graph in .net format (to be read by
0004 % Pajek program http://vlado.fmf.uni-lj.si/pub/networks/pajek/ ) of the Bayesian network with structure in dag
0005 % Pajek allows sophisticated network analysis and visualization
0006 % INPUTS
0007 % dag: Bayesian network structure
0008 % pajekfilename: Name of the pajek file containing the structure of the
0009 % network
0010 %
0011 % Last version 3/9/2009. Roberto Santana (roberto.santana@ehu.es)
0012 
0013 n = size(dag,1);
0014 
0015 Pos(:,1) = [0:1/n:1];
0016 Pos(:,2) = 0.5;
0017 
0018 
0019 fid = fopen(pajekfilename,'wt');
0020         fprintf(fid,'*Vertices %d \n', n); 
0021          for i=1:n,
0022           auxstr = ['"v',num2str(i),'"'];   
0023           auxstr1 = 'ellipse ic Black fos 20';
0024           fprintf(fid,'%d %s %d %d %s \n',i,auxstr,Pos(i,1),Pos(i,2),auxstr1);
0025          end,
0026      
0027      fprintf(fid,'*Arcs %d \n', sum(sum(dag))); 
0028       for i=1:n,
0029        for j=1:n,   
0030          if dag(i,j)==1
0031              fprintf(fid,'%d %d \n',i,j);
0032          end
0033        end
0034      end
0035       
0036   fclose(fid)
0037

Generated on Fri 04-Dec-2009 13:38:29 by m2html © 2003