vg
tools for working with variation graphs
Loading...
Searching...
No Matches
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 (bool enabled)
 Construct a DiagramExplainer that will save a diagram to one or more files.
 ~DiagramExplainer ()
 Close out the files being explained to.
void add_globals (const annotation_t &annotations)
 Add global annotations (like rankdir).
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 (bool enabled)
 Construct an Explainer that will save to one or more files.
virtual ~Explainer ()
 Close out the files being explained to.
 operator bool () const

Protected Types

using stored_edge_t = std::tuple<std::string, std::string, annotation_t>
 We will need to store edges.
using edge_ref_t = std::tuple<const std::string&, const std::string&, const annotation_t&>
 And show them to people.
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.
void write_annotations (std::ostream &out, const annotation_t &annotations) const
 Save the annotations for a node or edge, if any.
void write_node (std::ostream &out, const std::string &id, const annotation_t &annotations) const
 Write out a node.
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.
void write_globals (std::ostream &out, const annotation_t &annotations) const
 Write out globals.
void write_connected_components () const
 Write each connected component to a different file.
Protected Member Functions inherited from vg::Explainer
bool explaining () const
 Function to check if we should be explaining.

Protected Attributes

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

Static Protected Attributes

static const size_t MAX_DISPLAYED_SUGGESTIONS_PER_CATEGORY {5}
 Limit on suggested edges.
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.
static size_t next_context_explanation_number {0}
static std::string current_context = ""
 Current thing (possibly a read name) being explained (for organizing into directories).

Additional Inherited Members

Static Public Member Functions inherited from vg::Explainer
static void set_context (const std::string &context)
static void clear_context ()
 Clear the current per-thread context.
Static Public Attributes inherited from vg::Explainer
static bool save_explanations = false
Static Protected Member Functions inherited from vg::Explainer
static size_t get_new_explanation_number ()
static std::string make_filename (const std::string &base_name, const std::string &extension)

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 ( bool enabled)

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: