summaryrefslogtreecommitdiff
path: root/lib/include/network.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/include/network.hpp')
-rw-r--r--lib/include/network.hpp46
1 files changed, 33 insertions, 13 deletions
diff --git a/lib/include/network.hpp b/lib/include/network.hpp
index 544f828..8211cfc 100644
--- a/lib/include/network.hpp
+++ b/lib/include/network.hpp
@@ -7,6 +7,7 @@
#include <random>
#include <limits>
#include <valarray>
+#include <set>
#include "problem.hpp"
#include "graph.hpp"
@@ -16,60 +17,79 @@
#define CURRENT_CUTOFF 1e-10
+#include <boost/graph/adjacency_list.hpp>
+#include <boost/graph/connected_components.hpp>
+#include <boost/graph/depth_first_search.hpp>
+#include <boost/range/combine.hpp>
+#include <boost/foreach.hpp>
+#include <boost/graph/graph_utility.hpp>
+#include <boost/graph/incremental_components.hpp>
+#include <boost/pending/disjoint_sets.hpp>
+
+struct EdgeProperties {
+ unsigned index;
+};
+
+typedef boost::adjacency_list<boost::listS, boost::vecS, boost::undirectedS, boost::no_property, EdgeProperties> Graph;
+typedef boost::graph_traits<Graph>::vertex_descriptor Vertex;
+typedef boost::graph_traits<Graph>::vertices_size_type VertexIndex;
+
class network {
public:
const graph& G;
+
+ Graph bG;
+ Graph dG;
+ std::vector<VertexIndex> rank;
+ std::vector<Vertex> parent;
+ boost::disjoint_sets<VertexIndex*, Vertex*> ds;
+ std::unordered_map<std::array<unsigned, 2>, bool> seen_pairs;
+
std::vector<bool> fuses;
+ std::vector<bool> backbone;
std::vector<long double> thresholds;
- network(const graph&);
+ problem px;
+ problem py;
+
+ network(const graph&, cholmod_common*);
network(const network&);
void set_thresholds(double, std::mt19937&);
void fracture(hooks&, bool one_axis = false);
+ void update_backbone(const std::vector<double>& c);
- virtual void break_edge(unsigned e, bool unbreak = false) {fuses[e] = !unbreak;};
+ void break_edge(unsigned, bool unbreak = false);
virtual current_info get_current_info() {current_info empty; return empty;};
};
class fuse_network : public network {
private:
double weight;
- problem ohm_x;
- problem ohm_y;
public:
fuse_network(const graph&, cholmod_common*, double weight = 1.0);
fuse_network(const fuse_network&);
- void break_edge(unsigned, bool unbreak = false) override;
current_info get_current_info() override;
};
class elastic_network : public network {
private:
double weight;
- problem hook_x;
- problem hook_y;
public:
elastic_network(const graph&, cholmod_common*, double weight = 0.5);
elastic_network(const elastic_network&);
- void break_edge(unsigned, bool unbreak = false) override;
current_info get_current_info() override;
};
class percolation_network : public network {
- private:
- problem px;
- problem py;
-
public:
percolation_network(const graph&, cholmod_common*);
percolation_network(const percolation_network&);
- void break_edge(unsigned, bool unbreak = false) override;
current_info get_current_info() override;
};