
Given a workflow of n steps labeled 0 to n - 1, a list of directed edges dependencies where [a, b] means step a must run before step b, a list required_tools where required_tools[i] contains the tool names needed by step i, and a set available_tools, write a function that validates the workflow before execution. Return whether the graph is acyclic and whether every step's required tools are available. If valid, also return one valid execution order; otherwise return the cycle nodes and the steps with missing tools.
Example 1:
Input:
n = 4
dependencies = [[0, 1], [0, 2], [1, 3], [2, 3]]
required_tools = [["search"], ["python"], [], ["search", "python"]]
available_tools = {"search", "python"}
Output:
{"is_valid": true, "order": [0, 1, 2, 3], "cycle_nodes": [], "missing_tools": {}}
Explanation: The graph is a DAG and every required tool is available.
Example 2:
Input:
n = 3
dependencies = [[0, 1], [1, 2], [2, 0]]
required_tools = [[], ["python"], []]
available_tools = {"python"}
Output:
{"is_valid": false, "order": [], "cycle_nodes": [0, 1, 2], "missing_tools": {}}
Explanation: The workflow contains a directed cycle, so it cannot be executed.
1 <= n <= 10^50 <= len(dependencies) <= 2 * 10^50 <= len(required_tools[i]) <= 50dependencies are in the range [0, n - 1]