#pragma once #include #include #include #include #include #include #include "util/GraphParser.h" #include "util/Arc.h" #define NO_AUGMENTING_PATH_FOUND -1 typedef std::vector> CapacityMatrix; namespace data { class Graph { public: Graph(bool stdout_output, bool file_output, std::string output_filename, bool verbose_max_flow, bool min_cut, int verbosity); void parseFromString(const std::string &graph_string); void parseFromFile(const std::string &graph_file); void maxFlowDinic(); private: void initMatrices(); void setSourceAndSinkIterator(); void initOstream(); void constructLevelGraph(); int findAugmentingPaths(); void buildPath(std::vector ¤t_path); void computeFlowForPath(const std::vector ¤t_path); void printInformation() const; void printMaxFlowInformation() const; void printMinCut() const; void printComputationStatistics(const std::chrono::steady_clock::time_point &start, const std::chrono::steady_clock::time_point &end) const; std::vector m_vertices; std::vector m_arc_list; VertexID m_source_id; VertexID m_sink_id; std::vector::iterator m_source; std::vector::iterator m_sink; CapacityMatrix m_flow; CapacityMatrix m_capapcities; int m_num_vertices; int m_num_arcs; int m_max_flow = 0; bool m_stdout_output = true; bool m_file_output = false; std::string m_output_file_name; std::ostream *m_ofstream; bool m_verbose_max_flow = false; bool m_min_cut = false; int m_verbosity = 0; uint m_num_paths = 0; uint m_num_build_path_calls = 0; uint m_num_level_graphs_built = 0; std::vector m_augmenting_paths; }; }