new graph

This commit is contained in:
Rene Hopf
2015-01-29 19:34:01 +01:00
parent d757b37cbe
commit d10c9edee6
+21 -20
View File
@@ -10,8 +10,7 @@
using namespace std;
typedef struct{
vector<string> inputs;
vector<string> outputs;
vector<string> pins;
}comp_t;
int main(){
@@ -24,17 +23,17 @@ int main(){
//m[] 1 2 3 4 5
regex e("(\\w+).(\\w+) <= (\\w+).(\\w+) = (.+)");
while(std::regex_search (s,m,e)){
//if not connected to itself
if(m[1].str() != m[3].str() && m[2].str() != m[4].str()){
comps[m[3].str()].outputs.push_back(m[4].str());
comps[m[1].str()].inputs.push_back(m[2].str());
comps[m[1].str()].pins.push_back(m[2].str());
if(m[1].str() == m[3].str() && m[2].str() == m[4].str()){//if connected to itself
//wert foo
}else{
string link;
link.append(m[3].str());
link.append(":");
link.append("_");
link.append(m[4].str());
link.append(" -> ");
link.append(m[1].str());
link.append(":");
link.append("_");
link.append(m[2].str());
link.append("[label=\"");
link.append(m[5].str());
@@ -45,20 +44,22 @@ int main(){
}
dotfile << "digraph G {" << endl;
dotfile << "graph [rankdir = LR];" << endl;
dotfile << "node[shape=record];" << endl;
dotfile << "rankdir = LR;" << endl;
dotfile << "splines = spline;" << endl;
dotfile << "ratio = 1;" << endl;
dotfile << "overlap = false;" << endl;
dotfile << "start = regular;" << endl;
dotfile << "forcelabels = true;" << endl;
for(auto &comp:comps){
dotfile << comp.first << "[label=\"{{";
for(auto &input:comp.second.inputs){
dotfile << "<" << input << ">" << input << "|";
}
dotfile << "}|" << comp.first << "|{";
for(auto &output:comp.second.outputs){
dotfile << "<" << output << ">" << output << "|";
}
dotfile << "}}\"];" << endl;
dotfile << "subgraph cluster_" << comp.first << "{" << endl;
dotfile << " style = rounded;" << endl;
dotfile << " label = \"" << comp.first << "\";" << endl;
for(auto &pin:comp.second.pins){
dotfile << " " << comp.first << "_" << pin << " [shape = box, style = filled, color = lightgrey, label = \"" << pin << "\"];" << endl;
}
dotfile << "}" << endl;
}
for(auto &link:links){