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 () | |
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_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... | |
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... | |
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 | ( | ) |
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.