|
vg
tools for working with variation graphs
|
#include <explainer.hpp>
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. 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 (bool enabled) | |
| Construct an Explainer that will save to one or more files. More... | |
| virtual | ~Explainer () |
| Close out the files being explained to. More... | |
| operator bool () const | |
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 Member Functions inherited from vg::Explainer | |
| bool | explaining () const |
| Function to check if we should be explaining. More... | |
Protected Attributes | |
| annotation_t | globals |
| Collection of all global diagram key-value pairs (like rankdir) More... | |
| std::unordered_map< std::string, annotation_t > | nodes |
| Collection of all nodes, by ID. More... | |
| std::unordered_map< std::pair< std::string, std::string >, annotation_t > | edges |
| 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... | |
| bool | enabled |
| Determines if this explainer should generate explanations. 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... | |
| static thread_local size_t | next_context_explanation_number {0} |
| static thread_local std::string | current_context = "" |
| Current thing (possibly a read name) being explained (for organizing into directories) More... | |
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. More... | |
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) |
Widget to log statistics to a GraphViz file.
| using vg::DiagramExplainer::annotation_t = std::vector<std::pair<std::string, std::string> > |
|
protected |
And show them to people.
|
protected |
We will need to store edges.
|
protected |
| vg::DiagramExplainer::DiagramExplainer | ( | bool | enabled | ) |
Construct a DiagramExplainer that will save a diagram to one or more files.
| vg::DiagramExplainer::~DiagramExplainer | ( | ) |
Close out the files being explained to.
| 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.
| void vg::DiagramExplainer::add_globals | ( | const annotation_t & | annotations | ) |
Add global annotations (like rankdir)
| 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
| 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.
| 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.
|
protected |
Loop over all the edges, across all kinds of storage.
| 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
|
protected |
Save the annotations for a node or edge, if any.
|
protected |
Write each connected component to a different file.
|
protected |
Write out an edge.
|
protected |
Write out globals.
|
protected |
Write out a node.
|
protected |
Collection of all required edges.
|
protected |
Collection of all global diagram key-value pairs (like rankdir)
|
staticprotected |
Limit on suggested edges.
|
protected |
Collection of all nodes, by ID.
|
protected |
Top k most important edges for each suggested edge category.
1.8.17