Commit 751b97db authored by Jonas Seidel's avatar Jonas Seidel

Graph IO

parent 3cb93a32
......@@ -151,6 +151,11 @@ public:
// _debug_helpers (Graph.ipp)
void dump();
// friendships:
friend std::ostream& operator<<(std::ostream& os, Graph& g);
friend std::istream& operator>>(std::istream& is, Graph& g);
};
std::ostream& operator<<(std::ostream& os, Graph& g);
......
......@@ -91,6 +91,14 @@ std::ostream& operator<<(std::ostream& os, Graph& g){
for(Edge* e : g.edges()){
os << *e << "\n";
}
os << "} \nNode_Defaults { ";
for(std::pair<std::string, Attribute> attr : g._template_node_attributes){
os << attr.first << " = " << attr.second << " ";
}
os << "} \nEdge_Defaults { ";
for(std::pair<std::string, Attribute> attr : g._template_edge_attributes){
os << attr.first << " = " << attr.second << " ";
}
os << "} }";
}
return os;
......
......@@ -33,6 +33,32 @@ Graph::Graph(std::istream& is){
pos = is.tellg();
is >> curr;
}
is >> curr;
assert(curr == "Node_Defaults");
is >> curr;
assert(curr == "{");
is >> curr;
while(curr != "}"){
std::string name = curr;
is >> curr;
assert(curr == "=");
Attribute tmp(is);
this->_template_node_attributes.insert({name, tmp});
is >> curr;
}
is >> curr;
assert(curr == "Edge_Defaults");
is >> curr;
assert(curr == "{");
is >> curr;
while(curr != "}"){
std::string name = curr;
is >> curr;
assert(curr == "=");
Attribute tmp(is);
this->_template_edge_attributes.insert({name, tmp});
is >> curr;
}
}
void Graph::conditional_bfs_all_components(
......
......@@ -86,14 +86,14 @@ std::ostream& operator<<(std::ostream& os, Polyeder& polyeder){
os << constraint << "\n";
}
os << "Bounds\n";
for(size_t index = 0; index < polyeder.variables().size(); ++index){
if(polyeder.variable(index).lower_bound().first || polyeder.variable(index).upper_bound().first){
if(polyeder.variable(index).lower_bound().first){
os << polyeder.variable(index).lower_bound().second << " <= ";
for(auto var : polyeder._variables){
if(var.left->lower_bound().first || var.left->upper_bound().first){
if(var.left->lower_bound().first){
os << var.left->lower_bound().second << " <= ";
}
os << polyeder.variable_identifier(index);
if(polyeder.variable(index).upper_bound().first){
os << " <= " << polyeder.variable(index).upper_bound().second;
os << var.left->description();
if(var.left->upper_bound().first){
os << " <= " << var.left->upper_bound().second;
}
os << "\n";
}
......
......@@ -38,6 +38,8 @@ public:
void operator=(Polyeder&& p);
~Polyeder();
friend std::ostream& operator<<(std::ostream& os, Polyeder& polyeder);
};
std::ostream& operator<<(std::ostream& os, Polyeder& polyeder);
......
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