362TEMP void THIS::DotWrite(
const std::string& rFileName)
const {
363 FD_DG(
"RabinAutomaton(" <<
this <<
")::DotWrite(" << rFileName <<
")");
365 if(BASE::ReindexOnWrite()) BASE::SetMinStateIndexMap();
367 StateSet::Iterator lit;
370 std::vector<std::string> ColorPalette;
371 ColorPalette.push_back(
"lightblue");
372 ColorPalette.push_back(
"darkblue");
373 ColorPalette.push_back(
"#ffcc80");
374 ColorPalette.push_back(
"#ff9900");
375 ColorPalette.push_back(
"#b0ffb0");
376 ColorPalette.push_back(
"#307030");
377 ColorPalette.push_back(
"#ff9090");
378 ColorPalette.push_back(
"#a00202");
379 ColorPalette.push_back(
"black");
380 if(2*THIS::RabinAcceptance().Size()>ColorPalette.size()-1) {
381 FD_DG(
"RabinAutomaton(" <<
this <<
")::DotWrite(...): to many Rabin pairs");
382 BASE::DotWrite(rFileName);
387 std::ofstream stream;
388 stream.exceptions(std::ios::badbit|std::ios::failbit);
391 stream.open(rFileName.c_str());
392 stream <<
"// dot output generated by libFAUDES RabinAutomaton" << std::endl;
393 stream <<
"digraph \"" << BASE::Name() <<
"\" {" << std::endl;
394 stream <<
" rankdir=LR" << std::endl;
396 stream <<
" node [shape=rectangle, style=rounded];" << std::endl;
400 stream <<
" // initial states" << std::endl;
402 for (lit = BASE::InitStatesBegin(); lit != BASE::InitStatesEnd(); ++lit) {
403 std::string xname= BASE::StateName(*lit);
404 if(xname==
"") xname=
ToStringInteger(
static_cast<long int>(BASE::MinStateIndex(*lit)));
405 stream <<
" dot_dummyinit_" << i <<
" [shape=none, label=\"\" ];" << std::endl;
406 stream <<
" dot_dummyinit_" << i <<
" -> \"" << xname <<
"\";" << std::endl;
413 RabinAcceptance::CIterator rit;
414 for(rit=THIS::RabinAcceptance().Begin();rit!=THIS::RabinAcceptance().End();++rit) {
415 marked = marked + rit->
ISet();
416 marked = marked + rit->
RSet();
421 stream <<
" // plain states" << std::endl;
422 for (lit = BASE::pStates->Begin(); lit != BASE::pStates->End(); ++lit) {
423 if(marked.
Exists(*lit))
continue;
424 std::string xname=BASE::StateName(*lit);
426 stream <<
" \"" << xname <<
"\";" << std::endl;
431 stream <<
" // colored states" << std::endl;
432 for (lit = marked.
Begin(); lit != marked.
End(); ++lit) {
433 std::string xname=BASE::StateName(*lit);
434 if(xname==
"") xname=
ToStringInteger(
static_cast<long int>(BASE::MinStateIndex(*lit)));
435 stream <<
" \"" << xname <<
"\"";
437 RabinAcceptance::CIterator rit;
438 std::vector<int> colvec;
440 for(rit=THIS::RabinAcceptance().Begin();rit!=THIS::RabinAcceptance().End();++rit) {
441 if(rit->
ISet().
Exists(*lit)) colvec.push_back(col);
442 if(rit->
RSet().
Exists(*lit)) colvec.push_back(col+1);
446 if(this->ExistsMarkedState(*lit))
447 colvec.push_back(ColorPalette.size()-1);
449 stream <<
" [label=<<TABLE BORDER=\"0\"><TR>";
451 stream <<
"<TD>" << xname <<
"</TD>";
453 stream <<
"<TD WIDTH=\"5\"></TD>";
456 for(i=0;i<colvec.size();++i) {
457 stream <<
"<TD BGCOLOR=\"" << ColorPalette.at(colvec.at(i)) <<
"\" BORDER=\"0\" WIDTH=\"10\"></TD>";
460 stream <<
"</TR></TABLE>>";
461 stream <<
"];" << std::endl;
465 stream <<
" // transition relation" << std::endl;
467 for(tit = trx1x2ev.
Begin(); tit != trx1x2ev.
End();) {
469 if(!elabel.empty()) elabel = elabel +
", ";
470 if(elabel.length()>9) elabel = elabel +
"\n";
471 elabel=elabel + BASE::EventName(tit->Ev);
477 if(tit==trx1x2ev.
End())
480 flush=((tit->X1 != x1) || (tit->X2 != x2));
483 std::string x1name= BASE::StateName(x1);
485 std::string x2name= BASE::StateName(x2);
487 stream <<
" \"" << x1name <<
"\" -> \"" << x2name
488 <<
"\" [label=\"" << elabel <<
"\"];" << std::endl;
494 stream <<
"}" << std::endl;
497 catch (std::ios::failure&) {
499 "Exception opening/writing dotfile \""+rFileName+
"\"", 3);
501 BASE::ClearMinStateIndexMap();