def graph_is_valid(self):
"""Checks if the graph is valid."""
# Check if the graph is a DAG
is_dag = is_directed_acyclic_graph(self.graph)
# Check if output nodes are sinks
output_nodes_are_sinks = all([self.is_sink_node(name) for name in self.output_nodes])
# Check inf input nodes are sources
input_nodes_are_sources = all([self.is_source_node(name) for name in self.input_nodes])
# TODO Check whether only input nodes are sources and only output nodes are sinks
# Conclude
is_valid = is_dag and output_nodes_are_sinks and input_nodes_are_sources
return is_valid
评论列表
文章目录