Exemplo n.º 1
0
     def fold(self,edges_full,edges_partial):
          """
          Folds the list of edges.

          Some edges are fully folded and some are only partially
          folded. All edges are assumed to start form the same vertex.
          Edges are given by their label. In the terminology of
          Stallings folds the partially fold edges are subdivided and
          then fold.

          The first element of ``edges_full`` is allowed to be a tuple
          ``(path,'path')`` and not an ``edge_label``. Then the other
          edges will be folded to the whole ``path``. In Stallings
          terminology, this is a sequence of folds of the successive
          edges of ``path``.

          INPUT:
          
          ``edges_full``, ``edges_partial`` are list of edges (each
          possibly empty, but the union must have at least two edges).


          OUTPUT:

          A dictionnary that maps old edges to new graph paths.

          SEE ALSO:

          ``GraphWithInverses.fold()``
          """

          fold_map=GraphWithInverses.fold(self,edges_full,edges_partial)
          fold_morph=WordMorphism(fold_map)
          self._marking.set_edge_map(fold_morph*self._marking._edge_map)
          return fold_map
    def fold(self, edges_full, edges_partial):
        """
        Folds the list of edges.

        Some edges are fully folded and some are only partially
        folded. All edges are assumed to start form the same vertex.
        Edges are given by their label. In the terminology of
        Stallings folds the partially fold edges are subdivided and
        then fold.

        The first element of ``edges_full`` is allowed to be a tuple
        ``(path,'path')`` and not an ``edge_label``. Then the other
        edges will be folded to the whole ``path``. In Stallings
        terminology, this is a sequence of folds of the successive
        edges of ``path``.

        INPUT:
          
        - ``edges_full``, are list of edges
        - ``edges_partial`` are list of edges (each
          possibly empty, but the union must have at least two edges).


        OUTPUT:

        A dictionary that maps old edges to new graph paths.

        EXAMPLES::

            sage: G = GraphWithInverses([[0,0,'a'],[0,1,'b'],[1,1,'c']])
            sage: G = MarkedGraph(G)
            sage: G.fold(['b'],['a'])
            {'A': word: AB,
             'B': word: B,
             'C': word: C,
             'a': word: ba,
             'b': word: b,
             'c': word: c}
            sage: print G
            Marked graph: a: 1->0, b: 0->1, c: 1->1
            Marking: a->ba, b->bcB

        SEE ALSO:

        ``GraphWithInverses.fold()``
        """

        fold_map = GraphWithInverses.fold(self, edges_full, edges_partial)
        fold_morph = WordMorphism(fold_map)
        self._marking.set_edge_map(fold_morph * self._marking._edge_map)
        return fold_map
     def fold(self,edges_full,edges_partial):
          """
          Folds the edges.

          OUTPUT:

          A dictionnary that maps old edges to new graph paths.

          SEE ALSO:

          ``GraphWithInverses.fold()``
          """

          fold_map=GraphWithInverses.fold(self,edges_full,edges_partial)
          fold_morph=WordMorphism(fold_map)
          self._marking.set_edge_map(fold_morph*self._marking._edge_map)
          return fold_map