Data¶
- data_loader.generate_random_dag(num_nodes: int, max_duration: int, density_level=2)¶
Generates a random Directed Acyclic Graph (DAG) with specified number of nodes, maximum duration for each node, and density level for edge creation.
- Parameters:
num_nodes (int) – The number of nodes in the DAG.
max_duration (int) – The maximum duration of each node as a limit for random generation.
density_level (int, optional) – Controls the density of edges in the DAG. Higher values result in a sparser graph. Defaults to 2.
- Returns:
A networkx DiGraph object representing the generated DAG.
- Return type:
nx.DiGraph
- data_loader.load_dag_from_json(filepath: str)¶
Loads a DAG from a JSON file. The JSON format is expected to contain nodes with durations and their dependencies.
- Parameters:
filepath (str) – The path to the JSON file containing the DAG information.
- Returns:
A networkx DiGraph object representing the loaded DAG.
- Return type:
nx.DiGraph
- data_loader.load_dag_from_json_rx(filepath)¶
Loads a DAG from a JSON file into a retworkx PyDiGraph and a durations dictionary, tailored for high performance.
- Parameters:
filepath (str) – The path to the JSON file containing the DAG information.
- Returns:
A tuple containing the retworkx PyDiGraph and a dictionary mapping node IDs to their durations.
- Return type:
tuple
- data_loader.plot_dag(dag)¶
Plots a Directed Acyclic Graph (DAG) using graphviz layout and networkx drawing tools.
- Parameters:
dag (nx.DiGraph) – The directed acyclic graph to plot.
- Returns:
This function displays the plot but does not return any value.
- Return type:
None