Skip to content

get_nodes

Signature/Parameters

def get_nodes(self, exclude_latent = False)

Return the graph node names, optionally omitting latent variables.

Parameters:

Name Type Description Default
exclude_latent bool

If True, latent nodes are excluded from the returned list. Defaults to False.

False

Returns:

Type Description
list[str]

Node names in the current graph. The order corresponds to the insertion order preserved in self.nodes.

Source code in causalinf/gcm.py
def get_nodes(self, exclude_latent=False):
    """
    Return the graph node names, optionally omitting latent variables.

    Parameters
    ----------
    exclude_latent : bool, optional
        If ``True``, latent nodes are excluded from the returned list.
        Defaults to ``False``.

    Returns
    -------
    list[str]
        Node names in the current graph. The order corresponds to the
        insertion order preserved in ``self.nodes``.
    """
    nodes = list(self.nodes)
    latent_nodes = self.latent

    if exclude_latent and latent_nodes:
        nodes = [n for n in nodes if n not in latent_nodes]
    return nodes