From d10c9edee6d993faec67b647122001ea565e2e8c Mon Sep 17 00:00:00 2001 From: Rene Hopf Date: Thu, 29 Jan 2015 19:34:01 +0100 Subject: [PATCH] new graph --- graphviz/test.cpp | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/graphviz/test.cpp b/graphviz/test.cpp index a45bc82a..e21583c7 100644 --- a/graphviz/test.cpp +++ b/graphviz/test.cpp @@ -10,8 +10,7 @@ using namespace std; typedef struct{ - vector inputs; - vector outputs; + vector 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){