def to_CAG(self):
        """ Export to a Causal Analysis Graph (CAG) PyGraphviz AGraph object.
        The CAG shows the influence relationships between the variables and
        elides the function nodes."""

        G = nx.DiGraph()
        for (name, attrs) in self.nodes(data=True):
            if attrs["type"] == "variable":
                for pred_fn in self.predecessors(name):
                    if not any(
                        fn_type in pred_fn
                        for fn_type in ("condition", "decision")
                    ):
                        for pred_var in self.predecessors(pred_fn):
                            G.add_node(
                                self.nodes[pred_var]["basename"],
                                **self.nodes[pred_var],
                            )
                            G.add_node(attrs["basename"], **attrs)
                            G.add_edge(
                                self.nodes[pred_var]["basename"],
                                attrs["basename"],
                            )
                if attrs["is_loop_index"]:
                    G.add_edge(attrs["basename"], attrs["basename"])

        return G
Export to a Causal Analysis Graph (CAG) PyGraphviz AGraph object.
        The CAG shows the influence relationships between the variables and
        elides the function nodes.