Lumiera  0.pre.03
»edit your freedom«
dot-gen.hpp File Reference

Go to the source code of this file.

Description

Support for generation of Graphviz-DOT code for structure visualisation.

The dot language offers a simple notation to represent structural information as diagrams of abstract graphs and networks. The Graphviz layout programs translate these into automatically arranged diagrams graphs, relying on basic layout schemes like directed and undirected graphs, force-directed placement, radial arrangements, clustered graphs or squarified treemap layout. These visualisations can be rendered as images, vector graphic SVG or PDF and a lot of further formats.

The namespace lib::dot_gen contains a set of integrated builder DSL functions to simplify the task of syntax generation; notable it is possible to set up several sections, which can then be gradually populated with definition clauses while traversing a data structure.

Todo:
11/2023 this is an initial draft, shaped by the immediate need to visualise random generated computation patterns for Scheduler load testing. The abstraction level of this DSL is low and structures closely match some clauses of the DOT language; this approach may not yet be adequate to generate more complex graph structures and was extracted as a starting point for further refinements.

The top-level entrance point is lib::dot_get::digraph(), allowing to combine a series of lib::dot_gen::Section definitions into a DOT script, which can then be retrieved by string conversion (or sent to standard output)

  • Section is an accumulator of lines with DOT language specs
  • Code is a string with syntax, used as base for some pre-configured terms
  • Node defines a variable name, but can be augmented with attributes to build a node-statement
  • Scope is meant as a device to group several nodes together, typically to form a cluster or stratum in the generated layout
See also
TestChainLoad_test
SchedulerStress_test

Definition in file dot-gen.hpp.

#include "lib/format-util.hpp"
#include "lib/util.hpp"
#include <utility>
#include <sstream>
#include <string>
#include <vector>

Classes

struct  Code
 markup to generate a piece of code More...
 
class  DotOut
 Helper to collect DOT-Graphviz code for output. More...
 
struct  Node
 generate a Node name or a node_statement defining attributes of that node. More...
 
struct  Scope
 accumulator to collect nodes grouped into a scope More...
 
struct  Section
 Accumulator to collect lines of DOT code. More...
 

Functions

Code connect (size_t src, size_t dest)
 generate a directed node connectivity clause
 
template<class... COD>
DotOut digraph (COD ...parts)
 Entrance-point: generate a graph spec in DOT-Language. More...
 
Node node (size_t id)
 
Scope scope (size_t id)
 

Namespaces

 lib
 Implementation namespace for support and library code.
 

Function Documentation

◆ digraph()

DotOut lib::dot_gen::digraph ( COD ...  parts)
inline

Entrance-point: generate a graph spec in DOT-Language.

Parameters
partsa sequence of Section or Code objects to be combined and rendered
Returns
DotOut object holding the script rendered into a stringstream-buffer

Definition at line 237 of file dot-gen.hpp.

References lib::dot_gen::digraph().

Referenced by lib::dot_gen::digraph().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: