1 /* This file is part of libDAI - http://www.libdai.org/
3 * libDAI is licensed under the terms of the GNU General Public License version
4 * 2, or (at your option) any later version. libDAI is distributed without any
5 * warranty. See the file COPYING for more details.
7 * Copyright (C) 2006-2010 Joris Mooij [joris dot mooij at libdai dot org]
8 * Copyright (C) 2006-2007 Radboud University Nijmegen, The Netherlands
16 #include <dai/factorgraph.h>
23 int main( int argc
, char *argv
[] ) {
25 // Display help message if number of command line arguments is incorrect
26 cout
<< "This program is part of libDAI - http://www.libdai.org/" << endl
<< endl
;
27 cout
<< "Usage: ./fg2dot <in.fg> <out.dot>" << endl
<< endl
;
28 cout
<< "Converts a libDAI factor graph file to a GraphViz .dot file for visualization." << endl
;
29 cout
<< "The .dot file can be converted to .ps (PostScript) by" << endl
;
30 cout
<< "'neato -T ps out.dot > out.ps' or by 'dot -T ps out.dot > out.ps'" << endl
<< endl
;
35 char *infile
= argv
[1];
36 fg
.ReadFromFile( infile
);
38 // Open output file for writing (except if filename equals "-")
41 if( string( argv
[2] ) != "-" ) {
42 outfile
.open( argv
[2] );
43 if( !outfile
.is_open() ) {
44 cerr
<< "Cannot open " << argv
[2] << " for writing" << endl
;
48 } // else, write to cout
50 // Write the .dot file