compass.common.tree.describe_graph#

describe_graph(graph)[source]#

Questions and branches of a decision-tree graph, for event logs

Prompts are kept as templates (placeholders such as {text} are left unfilled), so the description stays small and is the same for every document the tree runs on.

Parameters:

graph (networkx.DiGraph) – Decision-tree graph whose nodes have a “prompt” attribute and whose edges may have a “condition” callable.

Returns:

dict – nodes (each with an id and prompt) and edges (each with a source, target, and condition), in the order the tree checks them. condition is the condition function’s name, or None for an edge taken when no other condition matches.