vg
tools for working with variation graphs
Public Types | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
vg::DiagramExplainer Class Reference

#include <explainer.hpp>

Inheritance diagram for vg::DiagramExplainer:
vg::Explainer

Public Types

using annotation_t = std::vector< std::pair< std::string, std::string > >
 

Public Member Functions

 DiagramExplainer ()
 Construct a DiagramExplainer that will save a diagram to one or more files. More...
 
 ~DiagramExplainer ()
 Close out the files being explained to. More...
 
void add_globals (const annotation_t &annotations)
 Add global annotations (like rankdir) More...
 
void add_node (const std::string &id, const annotation_t &annotations={})
 
void ensure_node (const std::string &id, const annotation_t &annotations={})
 
void add_edge (const std::string &a_id, const std::string &b_id, const annotation_t &annotations={})
 
void ensure_edge (const std::string &a_id, const std::string &b_id, const annotation_t &annotations={})
 
void suggest_edge (const std::string &a_id, const std::string &b_id, const std::string &category, double importance, const annotation_t &annotations={})
 
- Public Member Functions inherited from vg::Explainer
 Explainer ()
 Construct an Explainer that will save to one or more files. More...
 
virtual ~Explainer ()
 Close out the files being explained to. More...
 

Protected Types

using stored_edge_t = std::tuple< std::string, std::string, annotation_t >
 We will need to store edges. More...
 
using edge_ref_t = std::tuple< const std::string &, const std::string &, const annotation_t & >
 And show them to people. More...
 
using suggested_edge_t = std::pair< double, stored_edge_t >
 

Protected Member Functions

void for_each_edge (const std::function< void(const edge_ref_t &)> &iteratee) const
 Loop over all the edges, across all kinds of storage. More...
 
void write_annotations (std::ostream &out, const annotation_t &annotations) const
 Save the annotations for a node or edge, if any. More...
 
void write_node (std::ostream &out, const std::string &id, const annotation_t &annotations) const
 Write out a node. More...
 
void write_edge (std::ostream &out, const std::string &a_id, const std::string &b_id, const annotation_t &annotations) const
 Write out an edge. More...
 
void write_globals (std::ostream &out, const annotation_t &annotations) const
 Write out globals. More...
 
void write_connected_components () const
 Write each connected component to a different file. More...
 

Protected Attributes

annotation_t globals
 Collection of all global diagram key-value pairs (like rankdir) More...
 
std::unordered_map< std::string, annotation_tnodes
 Collection of all nodes, by ID. More...
 
std::unordered_map< std::pair< std::string, std::string >, annotation_tedges
 Collection of all required edges. More...
 
std::unordered_map< std::string, std::vector< suggested_edge_t > > suggested_edges
 Top k most important edges for each suggested edge category. More...
 
- Protected Attributes inherited from vg::Explainer
size_t explanation_number
 What number explanation are we? Distinguishes different objects. More...
 

Static Protected Attributes

static const size_t MAX_DISPLAYED_SUGGESTIONS_PER_CATEGORY {5}
 Limit on suggested edges. More...
 
- Static Protected Attributes inherited from vg::Explainer
static std::atomic< size_t > next_explanation_number {0}
 Counter used to give different explanations their own unique filenames. More...
 

Additional Inherited Members

- Static Public Attributes inherited from vg::Explainer
static bool save_explanations = false
 Determine if explanations should be generated. More...
 

Detailed Description

Widget to log statistics to a GraphViz file.

Member Typedef Documentation

◆ annotation_t

using vg::DiagramExplainer::annotation_t = std::vector<std::pair<std::string, std::string> >

◆ edge_ref_t

using vg::DiagramExplainer::edge_ref_t = std::tuple<const std::string&, const std::string&, const annotation_t&>
protected

And show them to people.

◆ stored_edge_t

using vg::DiagramExplainer::stored_edge_t = std::tuple<std::string, std::string, annotation_t>
protected

We will need to store edges.

◆ suggested_edge_t

using vg::DiagramExplainer::suggested_edge_t = std::pair<double, stored_edge_t>
protected

Constructor & Destructor Documentation

◆ DiagramExplainer()

vg::DiagramExplainer::DiagramExplainer ( )

Construct a DiagramExplainer that will save a diagram to one or more files.

◆ ~DiagramExplainer()

vg::DiagramExplainer::~DiagramExplainer ( )

Close out the files being explained to.

Member Function Documentation

◆ add_edge()

void vg::DiagramExplainer::add_edge ( const std::string &  a_id,
const std::string &  b_id,
const annotation_t annotations = {} 
)

Add an edge. Optionally give it the given annotation, which must be pre-escaped. The edge is assumed not to exist already.

◆ add_globals()

void vg::DiagramExplainer::add_globals ( const annotation_t annotations)

Add global annotations (like rankdir)

◆ add_node()

void vg::DiagramExplainer::add_node ( const std::string &  id,
const annotation_t annotations = {} 
)

Add a node. Optionally give it the given annotation, which must be pre-escaped. The node is assumed not to exist already

◆ ensure_edge()

void vg::DiagramExplainer::ensure_edge ( const std::string &  a_id,
const std::string &  b_id,
const annotation_t annotations = {} 
)

Add an edge. Optionally give it the given annotation, which must be pre-escaped. Deduplicates multiple calls with the same IDs in the same order.

◆ ensure_node()

void vg::DiagramExplainer::ensure_node ( const std::string &  id,
const annotation_t annotations = {} 
)

Add a node. Optionally give it the given annotation, which must be pre-escaped. Deduplicates multiple calls with the same ID.

◆ for_each_edge()

void vg::DiagramExplainer::for_each_edge ( const std::function< void(const edge_ref_t &)> &  iteratee) const
protected

Loop over all the edges, across all kinds of storage.

◆ suggest_edge()

void vg::DiagramExplainer::suggest_edge ( const std::string &  a_id,
const std::string &  b_id,
const std::string &  category,
double  importance,
const annotation_t annotations = {} 
)

Add an optional edge. Optionally give it the given annotation, which must be pre-escaped. Only the k most important edges in each category will actually render

◆ write_annotations()

void vg::DiagramExplainer::write_annotations ( std::ostream &  out,
const annotation_t annotations 
) const
protected

Save the annotations for a node or edge, if any.

◆ write_connected_components()

void vg::DiagramExplainer::write_connected_components ( ) const
protected

Write each connected component to a different file.

◆ write_edge()

void vg::DiagramExplainer::write_edge ( std::ostream &  out,
const std::string &  a_id,
const std::string &  b_id,
const annotation_t annotations 
) const
protected

Write out an edge.

◆ write_globals()

void vg::DiagramExplainer::write_globals ( std::ostream &  out,
const annotation_t annotations 
) const
protected

Write out globals.

◆ write_node()

void vg::DiagramExplainer::write_node ( std::ostream &  out,
const std::string &  id,
const annotation_t annotations 
) const
protected

Write out a node.

Member Data Documentation

◆ edges

std::unordered_map<std::pair<std::string, std::string>, annotation_t> vg::DiagramExplainer::edges
protected

Collection of all required edges.

◆ globals

annotation_t vg::DiagramExplainer::globals
protected

Collection of all global diagram key-value pairs (like rankdir)

◆ MAX_DISPLAYED_SUGGESTIONS_PER_CATEGORY

const size_t vg::DiagramExplainer::MAX_DISPLAYED_SUGGESTIONS_PER_CATEGORY {5}
staticprotected

Limit on suggested edges.

◆ nodes

std::unordered_map<std::string, annotation_t> vg::DiagramExplainer::nodes
protected

Collection of all nodes, by ID.

◆ suggested_edges

std::unordered_map<std::string, std::vector<suggested_edge_t> > vg::DiagramExplainer::suggested_edges
protected

Top k most important edges for each suggested edge category.


The documentation for this class was generated from the following files: