def _validate(G):
    """
    Validates dependency graph to ensure it has no missing or cyclic dependencies
    """
    for name in G.nodes:
        if "value" not in G.nodes[name] and "template" not in G.nodes[name]:
            msg = 'Dependency unsatisfied in variable "%s"' % name
            raise ParamException(msg)

    if not nx.is_directed_acyclic_graph(G):
        graph_cycles = nx.simple_cycles(G)

        variable_names = []
        for cycle in graph_cycles:
            try:
                variable_name = cycle[0]
            except IndexError:
                continue

            variable_names.append(variable_name)

        variable_names = ", ".join(sorted(variable_names))
        msg = (
            "Cyclic dependency found in the following variables: %s. Likely the variable is "
            "referencing itself" % (variable_names)
        )
        raise ParamException(msg)

    Validates dependency graph to ensure it has no missing or cyclic dependencies
    
st2common/st2common/util/param.py