You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
63 lines
1.3 KiB
63 lines
1.3 KiB
#include <iostream>
|
|
// #include <string>
|
|
#include <signal.h>
|
|
|
|
#include <graph/graph.hpp>
|
|
#include <graph/graph_plaintext.hpp>
|
|
|
|
#include <functional>
|
|
|
|
#include "graph_browser.hpp"
|
|
|
|
std::function<void(int)> callback_wrapper;
|
|
|
|
void callback_function( int value )
|
|
{
|
|
callback_wrapper(value);
|
|
}
|
|
|
|
// template<typename T>T conveter(T){};
|
|
// template<>std::string conveter(const std::string& s)<std::string>{retun s;}
|
|
inline std::string atoa(const std::string s)
|
|
{
|
|
return s;
|
|
}
|
|
|
|
int main(int argc, char* argv[])
|
|
{
|
|
if (argc != 2) {
|
|
std::cout << "Usage: " << argv[0] << " [graph file]" << std::endl;
|
|
return 1;
|
|
}
|
|
const std::string graph_file(argv[1]);
|
|
Graph<std::string> g;
|
|
try {
|
|
g = readGraphFromPlainText<std::string>(graph_file, atoa);
|
|
} catch (std::runtime_error &e) {
|
|
std::cerr << e.what() << std::endl;
|
|
return 1;
|
|
}
|
|
|
|
GraphBrowser::init();
|
|
{
|
|
GraphBrowser gb(g);
|
|
|
|
if (!empty(g))
|
|
gb.setStartVertex(*g.begin());
|
|
|
|
callback_wrapper = std::bind(&GraphBrowser::terminalResizedEvent,
|
|
&gb,
|
|
std::placeholders::_1);
|
|
struct sigaction act;
|
|
act.sa_handler = callback_function;
|
|
sigaction(SIGWINCH, &act, NULL);
|
|
|
|
gb.mainLoop();
|
|
}
|
|
|
|
GraphBrowser::destroy();
|
|
writeGraphToPlainText<std::string>(g, graph_file, atoa);
|
|
|
|
return EXIT_SUCCESS;
|
|
}
|