Class DependencyGraph

Class Documentation

class DependencyGraph

This class represents the dependency tree for agent functions, host functions and submodels. Each DependencyNode has its own dependencies/dependents, the purpose of this class is to walk the dependency tree and provide utility such as validation/layering.

See

DependencyNode

Public Functions

DependencyGraph()

Constructors

explicit DependencyGraph(const ModelData *_model)

Used by ModelData for instantiation

explicit DependencyGraph(const DependencyGraph &other)

Deep copy

bool operator==(const DependencyGraph &rhs)

Equality operator, checks whether DependencyGraphs are functionally the same, i.e, do they represent the same execution graph

Note

Instead compare pointers if you wish to check that they are the same instance

Returns

True when both graphs represent the same execution graph

void addRoot(DependencyNode &root)

Add an AgentFunctionDescription, host function or submodel as a root node

Parameters

root – The function or submodel to add to the graph as a root

bool validateDependencyGraph()

Checks the dependency graph for cycles and validates that all agent functions belong to the same model

Returns

True when the graph is valid, i.e. it contains no cycles

void generateLayers(ModelDescription &model)

Generates optimal layers based on the dependencies specified and adds them to the model

Parameters

model – The model the layers should be added to

Throws

InvalidDependencyGraph – if the model already has layers attached

void generateDOTDiagram(std::string outputFileName)

Generates a .gv file containing the DOT representation of the dependencies specified

Parameters

outputFileName – The name of the output file

std::string getConstructedLayersString()

Returns a string representation of the constructed layers

Returns

A string representation of the constructed layers