Skip to content

set_node_position

Signature/Parameters

def set_node_position(self, position)

Assign layout coordinates to nodes in-place.

Parameters:

Name Type Description Default
position dict[str, tuple[float, float]]

Mapping from node names to (x, y) coordinate tuples. Keys should be the node name, the value its position.

required

Examples:

>>> G = DAG(graph="X -> Y")
>>> G.set_node_position({"X": (0.0, 0.5), "Y": (1.0, 0.5)})
Source code in causalinf/gcm.py
def set_node_position(self, position):
    """
    Assign layout coordinates to nodes in-place.

    Parameters
    ----------
    position : dict[str, tuple[float, float]]
        Mapping from node names to (x, y) coordinate tuples.
        Keys should be the node name, the value its position.

    Examples
    --------
    >>> G = DAG(graph="X -> Y")
    >>> G.set_node_position({"X": (0.0, 0.5), "Y": (1.0, 0.5)})
    """
    for node, p in position.items():
        self.position[node] = p