def path_duration(path):
    """
        Computes the timespan of a given path.

        Parameters
        ----------
        path : a path
            list of interactions forming a path among a node pair

        Returns
        --------
        duration: int
            The duration of the path

        Examples
        --------

        >>> import dynetx as dn
        >>> g = dn.DynGraph()
        >>> g.add_interaction("A", "B", 1, 4)
        >>> g.add_interaction("B", "D", 2, 5)
        >>> g.add_interaction("A", "C", 4, 8)
        >>> g.add_interaction("B", "D", 2, 4)
        >>> g.add_interaction("B", "C", 6, 10)
        >>> g.add_interaction("B", "D", 2, 4)
        >>> g.add_interaction("A", "B", 7, 9)
        >>> paths = al.time_respecting_paths(g, "D", "C", start=1, end=9)
        >>> for p in paths:
        >>>     print(al.path_duration(p))

    """
    return path[-1][-1] - path[0][-1]