artemis.meta.Directed_Graph¶
Computation graph data structure for persisting a business process model as a Directed Acyclic Graph.
Includes a topological sorting algorithm for generating Directed Acyclic Graphs given a set of inputs and an output in Menu data types used in Artemis and Cronos.
Defines all possible Sequences or Buisness processes as Nodes and each chain of sequences as a Directed_Graph datatype
A topological sort is applied to these data structures
We used an implementation of Khan’s algorithim to solve the topological sorting problem that this Class addresses https://www.geeksforgeeks.org/topological-sorting-indegree-based-solution/ https://en.wikipedia.org/wiki/Topological_sorting
https://stackoverflow.com/questions/5287516/dependencies-tree-implementation https://stackoverflow.com/questions/11557241/python-sorting-a-dependency-list
Or toposort in PyPi https://bitbucket.org/ericvsmith/toposort
Overall, this class uses the mypy library to enforce type saftey here
mypy library: http://mypy-lang.org/
Module Contents¶
-
class
artemis.meta.Directed_Graph.Node(parents: List, algos: Tuple[str], id: str)¶ Node (prev. Sequence) class
input ids = list of input element ids or input Directed_graphs, if node get last element name from a previous Girected_Graph
algos = tuple of the function names to execute
Sequence object should be an iterable, immutable object
-
__str__(self)¶
-
property
parents(self)¶ list of input parent ids in the dependency graphs mutable list since inputs should easily extended
-
property
algos(self)¶
-
property
id(self)¶ Represents the name of a unique id in the dependency graph This is the name of the Node in this context
-
change_id(self, new_id: str)¶
-
__len__(self)¶
-
__getitem__(self, position: int)¶
-
-
class
artemis.meta.Directed_Graph.Directed_Graph(id: str, root: List = ['initial'])¶ List of nodes (or a “chain” of action nodes(sequences) which must occur in an order))
A Directed_Graph must start with the initial element Each sequence must relate to previous sequence by element
A Directed graph can have many leafs, this is because the leaf is a list of strings which represent the nodes that it terminates to
Note: Chain could originate from previous chain, or multiple chain allowing for predefined chains to used by others
-
__repr__(self)¶
-
__str__(self)¶
-
property
id(self)¶ Return the chain name
-
property
nodes(self)¶
-
property
leaf(self)¶ Returns the list(str) of the leaves of this Directed_Graph
-
property
root(self)¶
-
change_id(self, new_id: str)¶
-
__len__(self)¶
-
__getitem__(self, position: int)¶
-
add(self, node: Node)¶
-
attempted_built(self)¶
-
create_vis(self, terminal_print=False, prefix=None)¶
-
build(self)¶ Builds the graph from the private member information
-
-
class
artemis.meta.Directed_Graph.GraphMenu(name: str)¶ List of Chains (Directed_Graphs) which describe the various processing for the given inputs
Data structures
Dependency graph Topological sorted list of elements Dictionary of Elements and list of algorithms which produce the element
Final data structure is an OrderedDict OrderedDict menu = {} menu[“Initial”] = (Algo_Create Initial Node Algo)” menu[“Element”] = (Tuple of Algos)
Dictionary of sequences OutputElement: (tuple of sequences)
-
property
graphs(self)¶
-
property
ordered_sequence(self)¶
-
add(self, directed_graph: Directed_Graph)¶
-
create_vis(self, terminal_print: bool = False, prefix=None)¶ Creates a pygraphviz from the menu of buisness processes We may have to move the following code depending on what graph (either sorted or unsorted we want to visualize) We begin by using the unsorted graph and then adding all of the parent/child relationships this way
-
build(self)¶ Similar to Chain.build Get root –> expect to be initial Get leaves –> Can be multiple “one to many” idea of the Directed_Graph and Menu classes
-
get_leaves(self)¶ This fucntion returns a list of the leaf nodes of a Directed_Graph
Input: self object Return: List of str, each bieng the id of a leaf node, in no specified order
-
to_graph(self)¶ The name of this function is misleading, this function is used for steering and returns a dictionary of node -> algorithims used
Generates ordered dictionary of node and algorithms Execution graph for Steering
Perhaps this is what is called in steering
-
to_tree(self)¶ Generates the dictionary of children and parents I am not sure where this is used
-
to_msg(self)¶ Writes the Map to a protocol buffer message
Reads in a menu from a protocol buffer message
Due to how the menus are represented in protocol buffers, it is only possible to create the _ordered_sequence from the protocol buffers
-
property
-
class
artemis.meta.Directed_Graph.Directed_GraphDef(items)¶ User defined class for generating the actual graph
Ported over from dag.py
Unsure of it’s true use but keeping for futureproof/legacy reasons
Seems to be deprecated or an unfinished prototype
-
graph(item, inputElement='initial')¶ takes the menu item name and default list of inputs inputElement can be of type Chain: inputElement = chain.leaf()
-