<tb@panthema.net>
<http://www.gnu.org/licenses/>
#include "graph.h"
#include "graph6.h"
#include "graphml.h"
#include "alg_bispanning.h"
#include "alg_game.h"
#include "alg_play_decompose.h"
#include "alg_play_trivial.h"
#include "bispanning.h"
#include <iostream>
#include <sstream>
#include <boost/lexical_cast.hpp>
#include <boost/program_options.hpp>
bool g_print_graphs = false;
bool g_print_games = false;
bool g_write_tgf = false;
bool g_write_graphml = false;
bool g_write_json = false;
bool g_save_graphs = false;
std::vector<BaseGraph> g_graphs;
#include "decomposition.h"
#include "enumerate.h"
#include "play_cliquesum.h"
void process(BaseGraph& g)
{
if (0)
{
for (size_t cbo = 0; cbo < 80; ++cbo)
{
tree_pair_type trees = calc_cyclic_base_ordering(g, cbo);
if (!trees.valid) break;
bool testUE = test_cyclic_base_ordering<true>(g, trees, true);
std::cout << "// cbo[" << 0 << "] tree0: " << trees.t0 << " - tree1: " << trees.t1
<< " - " << (testUE ? "UEs" : "") << std::endl;
if (!testUE) abort();
}
}
if (1)
{
}
if (g_write_tgf)
{
std::string fname = "g-" + write_graph6(g) + ".tgf";
std::ofstream(fname) << graphtgf(g, BaseGraph::GraphDecoratorA()) << "\n";
}
if (g_write_graphml)
{
std::string fname = "g-" + write_graph6(g) + ".graphml";
std::ofstream(fname) << yedgraphml(g, BaseGraph::GraphDecoratorA()) << "\n";
}
if (g_write_json)
{
std::string fname = "g-" + write_graph6(g) + ".json";
std::ofstream of(fname);
g.output_json(of);
}
if (g_print_graphs)
{
std::cout << "// " << g.graphstring() << std::endl;
std::cout << g.graphviz() << std::endl;
iGraph<BaseGraph> ig(g);
std::cout << "// GRAPH"
<< " graph=" << write_graph6(g)
<< " num_vertex=" << g.num_vertex()
<< " num_edge=" << g.num_edge()
<< " degrees=" << g.get_degree_sequence()
<< " girth=" << ig.get_girth()
<< " vertex_conn=" << ig.get_vertex_connectivity()
<< " edge_conn=" << ig.get_edge_connectivity()
<< std::endl;
}
if (g_save_graphs)
g_graphs.push_back(g);
AlgGame<BaseGraph> game(g);
game.print(g_print_games, g_write_tgf);
}
void post_process()
{
}
int main(int argc, char* argv[])
{
namespace po = boost::program_options;
po::options_description desc("Available options");
desc.add_options()
("help,h", "produce help message")
("print-base-graphs,g", po::bool_switch(&g_print_graphs),
"output base graphs on stdout using the dot graph format")
("print-game-graphs,G", po::bool_switch(&g_print_games),
"output game graphs on stdout using the dot graph format")
("write-tgf,T", po::bool_switch(&g_write_tgf),
"write base graph as TGF trivial graph format")
("write-graphml,Y", po::bool_switch(&g_write_graphml),
"write base and game graphs as yEd's GraphML format")
("write-json,J", po::bool_switch(&g_write_json),
"write base and game graphs as a JSON format")
;
po::parsed_options parsed = po::parse_command_line(argc, argv, desc);
po::variables_map vm;
po::store(parsed, vm);
po::notify(vm);
if (vm.count("help")) {
std::cout << desc << "\n";
return 1;
}
std::vector<std::string> args =
po::collect_unrecognized(parsed.options, po::include_positional);
enumerate_bispanning_graphs(args, process);
post_process();
return 0;
}