#pragma once #include #include #include #include #include #include #include #include #include "array_hash.hpp" #include "clusters.hpp" #include "current_info.hpp" #include "graph.hpp" #include "hooks.hpp" #include "problem.hpp" #define CURRENT_CUTOFF 1e-10 class fuse_network; class elastic_network; class percolation_network; class network { friend class fuse_network; friend class elastic_network; friend class percolation_network; private: problem px; problem py; std::unordered_map, bool> seen_pairs; void update_backbone(const std::vector& c); void break_edge(unsigned, bool unbreak = false); void get_cycle_edges_helper(std::set&, std::set&, unsigned, unsigned) const; bool find_cycle_helper(std::array&, const std::set&, unsigned, unsigned, unsigned) const; bool get_cycle_helper(std::array&, std::set&, const std::set&, unsigned, unsigned, unsigned) const; std::array find_cycle(const std::set&, unsigned, unsigned) const; void get_cluster_edges_helper(std::set&, unsigned) const; std::set get_cluster_edges(unsigned) const; void get_tie_flaps_helper(std::set&, unsigned, unsigned) const; std::list> get_tie_flaps(unsigned) const; public: const graph& G; ClusterTree C; std::vector fuses; std::vector backbone; std::vector thresholds; network(const graph&, cholmod_common*); void set_thresholds(double, std::mt19937&); void fracture(hooks&); std::set get_cycle_edges(unsigned) const; std::pair, std::set> get_cycle(const std::set&, unsigned, unsigned) const; virtual current_info get_current_info() { current_info empty; return empty; }; std::string write(); }; class fuse_network : public network { private: double weight; public: fuse_network(const graph&, cholmod_common*, double weight = 1.0); fuse_network(const fuse_network&); current_info get_current_info() override; }; class elastic_network : public network { private: double weight; public: elastic_network(const graph&, cholmod_common*, double weight = 0.5); elastic_network(const elastic_network&); current_info get_current_info() override; }; class percolation_network : public network { public: percolation_network(const graph&, cholmod_common*); percolation_network(const percolation_network&); current_info get_current_info() override; };