33#ifndef _CMGRAPHS_DOTGRAPH_H_ 
   34#define _CMGRAPHS_DOTGRAPH_H_ 
   44#include "chomp/system/config.h" 
   45#include "chomp/system/textfile.h" 
   46#include "chomp/cubes/cube.h" 
   62        const chomp::homology::diGraph<> &g,
 
   63        const std::vector<int_t> &sizes,
 
   64        const std::vector<theConleyIndexType> &indices,
 
   65        const std::vector<IndexEigenValues> &eigenValues,
 
   66        const std::vector<int> &wrongIndices,
 
   67        const std::vector<int> &skippedIndices,
 
   68        const std::vector<int> &attractors)
 
   71        int_t nVert = g. countVertices ();
 
   74        std::vector<bool> wrong (nVert, 
false);
 
   75        for (std::vector<int>::const_iterator it = wrongIndices. begin ();
 
   76                it != wrongIndices. end (); ++ it)
 
   80                else if (
static_cast<int_t
> (*it) >= nVert)
 
   81                        throw "Too large Morse set number with wrong index.";
 
   86        std::vector<bool> skipped (nVert, 
false);
 
   87        for (std::vector<int>::const_iterator it = skippedIndices. begin ();
 
   88                it != skippedIndices. end (); ++ it)
 
   92                else if (
static_cast<int_t
> (*it) >= nVert)
 
   93                        throw "Too large number of a skipped index.";
 
   98        std::vector<bool> attr (nVert, 
false);
 
   99        for (std::vector<int>::const_iterator it = attractors. begin ();
 
  100                it != attractors. end (); ++ it)
 
  104                else if (
static_cast<int_t
> (*it) >= nVert)
 
  105                        throw "Too large attractor number.";
 
  110        std::vector<int_t> incomingEdgesCount (nVert, 0);
 
  111        for (int_t v = 0; v < nVert; ++ v)
 
  113                int_t nEdges = g. countEdges (v);
 
  114                for (int_t e = 0; e < nEdges; ++ e)
 
  116                        int_t target = g. getEdge (v, e);
 
  117                        if ((target < 0) || (target >= nVert))
 
  118                                throw "Wrong edge while writing dot graph.";
 
  119                        ++ (incomingEdgesCount [target]);
 
  124        out << 
"digraph G {";
 
  126        for (int_t v = 0; v < nVert; ++ v)
 
  129                out << (first ? 
"" : 
" ") << 
"v" << v << 
" [label=\"";
 
  132                out << v << 
": " << sizes [v] << 
"\\n";
 
  135                bool showindex = !eigenValues [v]. trivial ();
 
  136                int dim = indices [v]. dim ();
 
  137                for (
int d = 0; !showindex && (d <= dim); ++ d)
 
  139                        if (indices [v]. BettiNumber (d) ||
 
  140                                (indices [v]. Coefficient (d, 0) != 0) ||
 
  141                                indices [v]. Map (d) -> getncols ())
 
  150                        out << 
"[index not computed]\\n";
 
  154                        out << 
"[no isolation]\\n";
 
  159                        out << 
"H = (" << indices [v]. HomString () <<
 
  163                        for (
int d = 0; d <= indices [v]. dim (); ++ d)
 
  165                                if (indices [v]. Map (d) -> getncols ())
 
  168                                                MapString (d, 
"\\n");
 
  173                        eigenValues [v]. write (out, 
", ", 
"\\n");
 
  182                        out << 
" shape=box style=filled color=" <<
 
  183                                (wrong [v] ? 
"red" : 
"yellow");
 
  188                else if (incomingEdgesCount [v] == 0)
 
  190                        out << 
" shape=box style=filled color=" <<
 
  191                                (wrong [v] ? 
"red" : 
"greenyellow");
 
  193                else if (!eigenValues [v]. trivial ())
 
  195                        out << 
" style=filled color=" <<
 
  196                                (wrong [v] ? 
"red" : 
"lightblue");
 
  200                        out << 
" style=filled color=red";
 
  209        if (attractors. size () > 1)
 
  211                out << 
" {rank=same;";
 
  212                for (std::vector<int>::const_iterator it =
 
  213                        attractors. begin ();
 
  214                        it != attractors. end (); ++ it)
 
  222        for (int_t v = 0; v < nVert; ++ v)
 
  224                int_t nEdges = g. countEdges (v);
 
  225                for (int_t e = 0; e < nEdges; ++ e)
 
  227                        int_t target = g. getEdge (v, e);
 
  228                        out << 
" v" << v << 
"->v" << target;
 
Choice of configuration settings.
 
std::ostream & writeDotGraph(std::ostream &out, const chomp::homology::diGraph<> &g, const std::vector< int_t > &sizes, const std::vector< theConleyIndexType > &indices, const std::vector< IndexEigenValues > &eigenValues, const std::vector< int > &wrongIndices, const std::vector< int > &skippedIndices, const std::vector< int > &attractors)
Writes the given Conley-Morse graph to the output stream in the format for the 'dot' program.
 
Eigenvalues of the Conley index map.
 
Customizable data types for the Conley-Morse graphs computation program.
 
Data types for the dynamical systems data structures.