def time_slice(self, t_from, t_to=None):
        """Return an new graph containing nodes and interactions present in [t_from, t_to].

            Parameters
            ----------

            t_from : snapshot id, mandatory
            t_to : snapshot id, optional (default=None)
                If None t_to will be set equal to t_from

            Returns
            -------
            H : a DynGraph object
                the graph described by interactions in [t_from, t_to]

            Examples
            --------
            >>> G = dn.DynGraph()
            >>> G.add_path([0,1,2,3], t=0)
            >>> G.add_path([0,4,5,6], t=1)
            >>> G.add_path([7,1,2,3], t=2)
            >>> H = G.time_slice(0)
            >>> H.interactions()
            [(0, 1), (1, 2), (1, 3)]
            >>> H = G.time_slice(0, 1)
            >>> H.interactions()
            [(0, 1), (1, 2), (1, 3), (0, 4), (4, 5), (5, 6)]
        """
        # create new graph and copy subgraph into it
        H = self.__class__()

        if t_to is not None:
            if t_to < t_from:
                raise ValueError("Invalid range: t_to must be grater that t_from")
        else:
            t_to = t_from

        for u, v, ts in self.interactions_iter():
            I = t_to
            F = t_from

            for a, b in ts['t']:
                if I <= a and b <= F:
                    H.add_interaction(u, v, a, b)
                elif a <= I and F <= b:
                    H.add_interaction(u, v, I, F)
                elif a <= I <= b and b <= F:
                    H.add_interaction(u, v, I, b)
                elif I <= a <= F and F <= b:
                    H.add_interaction(u, v, a, F)
        return H
def time_slice ( self , t_from , t_to = None ) : H = self . __class__ ( ) if t_to is not None : if t_to < t_from : raise ValueError ( "Invalid range: t_to must be grater that t_from" ) else : t_to = t_from for u , v , ts in self . interactions_iter ( ) : I = t_to F = t_from for a , b in ts [ 't' ] : if I <= a and b <= F : H . add_interaction ( u , v , a , b ) elif a <= I and F <= b : H . add_interaction ( u , v , I , F ) elif a <= I <= b and b <= F : H . add_interaction ( u , v , I , b ) elif I <= a <= F and F <= b : H . add_interaction ( u , v , a , F ) return H
Return an new graph containing nodes and interactions present in [t_from, t_to].

            Parameters
            ----------

            t_from : snapshot id, mandatory
            t_to : snapshot id, optional (default=None)
                If None t_to will be set equal to t_from

            Returns
            -------
            H : a DynGraph object
                the graph described by interactions in [t_from, t_to]

            Examples
            --------
            >>> G = dn.DynGraph()
            >>> G.add_path([0,1,2,3], t=0)
            >>> G.add_path([0,4,5,6], t=1)
            >>> G.add_path([7,1,2,3], t=2)
            >>> H = G.time_slice(0)
            >>> H.interactions()
            [(0, 1), (1, 2), (1, 3)]
            >>> H = G.time_slice(0, 1)
            >>> H.interactions()
            [(0, 1), (1, 2), (1, 3), (0, 4), (4, 5), (5, 6)]