Commit 34e61191 authored by Jonas Seidel's avatar Jonas Seidel

Graph Selectors

parent 9458bb39
......@@ -113,6 +113,11 @@ public:
std::string upper_limit_attr
);
// _select_opertations
std::set<Edge*> gather_edges(std::vector<std::string> attributes);
std::set<Node*> gather_nodes(std::vector<std::string> attributes);
// fringe_operations
std::vector<Node*> select_targets();
Node* tip_targets(
......
std::set<Edge*> Graph::gather_edges(std::vector<std::string> attributes){
std::set<Edge*> edges;
for(Edge* e : this->_edges){
for(std::string attribute_name : attributes){
auto attribute_search = e->attribute(attribute_name);
if(attribute_search.first && attribute_search.second.value()){
edges.insert(e);
}
}
}
return edges;
}
std::set<Node*> Graph::gather_nodes(std::vector<std::string> attributes){
std::set<Node*> nodes;
for(Node* n : this->_nodes){
for(std::string attribute_name : attributes){
auto attribute_search = n->attribute(attribute_name);
if(attribute_search.first && attribute_search.second.value()){
nodes.insert(n);
}
}
}
return nodes;
}
......@@ -15,11 +15,12 @@ Maintenance_Problem::Maintenance_Problem(Maintenance_Problem&& mp) : Linear_Prog
Maintenance_Problem::Maintenance_Problem(
Graph& g, Node* source,
Node* target,
std::set<Edge*> critical,
size_t intervals
)
: Linear_Program(true), _g(g)
{
std::set<Edge*> critical = g.gather_edges({"Selected"});
for(std::string attr : std::vector({"Selected", "Upper", "Flow"})){
if(!this->_g.edge_template(attr).first) {
std::cout << this->_g << std::endl;
......@@ -146,7 +147,6 @@ void Maintenance_Problem::operator=(Maintenance_Problem&& mp){
}
std::ostream& operator<<(std::ostream& os, Maintenance_Problem& mp){
os << mp.network() << std::endl;
os << static_cast<Linear_Program&>(mp) << std::endl;
return os;
}
......@@ -15,7 +15,7 @@ public:
Maintenance_Problem();
Maintenance_Problem(Maintenance_Problem& mp);
Maintenance_Problem(Maintenance_Problem&& mp);
Maintenance_Problem(Graph& g, Node* source, Node* target, std::set<Edge*> critical, size_t intervals);
Maintenance_Problem(Graph& g, Node* source, Node* target, size_t intervals);
Graph& network();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment