|
@ -10,16 +10,10 @@ |
|
|
namespace data { |
|
|
namespace data { |
|
|
Graph::Graph(bool stdout_output, bool file_output, std::string output_filename, bool verbose_max_flow, bool min_cut, int verbosity) |
|
|
Graph::Graph(bool stdout_output, bool file_output, std::string output_filename, bool verbose_max_flow, bool min_cut, int verbosity) |
|
|
: m_file_output(file_output), m_output_file_name(output_filename), m_verbose_max_flow(verbose_max_flow), m_min_cut(min_cut), m_verbosity(verbosity) { |
|
|
: m_file_output(file_output), m_output_file_name(output_filename), m_verbose_max_flow(verbose_max_flow), m_min_cut(min_cut), m_verbosity(verbosity) { |
|
|
//if(!stdout_output && file_output) {
|
|
|
|
|
|
// m_stdout_output = false;
|
|
|
|
|
|
//} else {
|
|
|
|
|
|
// m_stdout_output = true;
|
|
|
|
|
|
//}
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void Graph::parseFromString(const std::string &graph_string) { |
|
|
void Graph::parseFromString(const std::string &graph_string) { |
|
|
parser::parseString(graph_string, m_arc_list, m_vertices, m_source_id, m_sink_id, m_num_vertices, m_num_arcs); |
|
|
parser::parseString(graph_string, m_arc_list, m_vertices, m_source_id, m_sink_id, m_num_vertices, m_num_arcs); |
|
|
setSourceAndSinkIterator(); |
|
|
|
|
|
initMatrices(); |
|
|
initMatrices(); |
|
|
initOstream(); |
|
|
initOstream(); |
|
|
} |
|
|
} |
|
@ -29,7 +23,6 @@ namespace data { |
|
|
throw std::runtime_error("Input graph file name and output file name are the same. Will not overwrite. Exiting..."); |
|
|
throw std::runtime_error("Input graph file name and output file name are the same. Will not overwrite. Exiting..."); |
|
|
} |
|
|
} |
|
|
parser::parseFile(graph_file, m_arc_list, m_vertices, m_source_id, m_sink_id, m_num_vertices, m_num_arcs); |
|
|
parser::parseFile(graph_file, m_arc_list, m_vertices, m_source_id, m_sink_id, m_num_vertices, m_num_arcs); |
|
|
setSourceAndSinkIterator(); |
|
|
|
|
|
initMatrices(); |
|
|
initMatrices(); |
|
|
initOstream(); |
|
|
initOstream(); |
|
|
} |
|
|
} |
|
@ -38,15 +31,10 @@ namespace data { |
|
|
m_flow.resize(m_num_vertices, std::vector<Capacity>(m_num_vertices, 0)); |
|
|
m_flow.resize(m_num_vertices, std::vector<Capacity>(m_num_vertices, 0)); |
|
|
m_capapcities.resize(m_num_vertices, std::vector<Capacity>(m_num_vertices, 0)); |
|
|
m_capapcities.resize(m_num_vertices, std::vector<Capacity>(m_num_vertices, 0)); |
|
|
for(auto const &arc : m_arc_list) { |
|
|
for(auto const &arc : m_arc_list) { |
|
|
m_capapcities.at(arc.start - 1).at(arc.end - 1) = arc.capacity; // how to best map arbitrary ids to index in matrix
|
|
|
|
|
|
|
|
|
m_capapcities.at(arc.start - 1).at(arc.end - 1) = arc.capacity; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void Graph::setSourceAndSinkIterator() { |
|
|
|
|
|
auto m_source = std::find_if(m_vertices.begin(), m_vertices.end(), [this] (const Vertex &v) { return (v.getID() == m_source_id); }); |
|
|
|
|
|
auto m_sink = std::find_if(m_vertices.begin(), m_vertices.end(), [this] (const Vertex &v) { return (v.getID() == m_sink_id); }); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Graph::initOstream() { |
|
|
void Graph::initOstream() { |
|
|
if(m_file_output) { |
|
|
if(m_file_output) { |
|
|
m_ofstream = new std::ofstream(m_output_file_name); |
|
|
m_ofstream = new std::ofstream(m_output_file_name); |
|
|