def HNN_splitting(A):
        """
        The marked metric graph corresponding to the HNN splitting
        F_N=F_{N-1}*<t>.

        This is rose marked graph with all edges of length 0 except ``A[0]``
        which is of length 1.

        INPUT:

        - ``A`` alphabet

        OUTPUT:

        The marked metric graph corresponding to the HNN splitting

        EXAMPLES::

            sage: A=AlphabetWithInverses(4)
            sage: print MarkedMetricGraph.HNN_splitting(A)
            Marked graph: a: 0->0, b: 0->0, c: 0->0, d: 0->0
            Marking: a->a, b->b, c->c, d->d
            Length: a:1, b:0, c:0, d:0
        """

        length = dict((a, 0) for a in A.positive_letters())
        length[A[0]] = 1

        RA = GraphWithInverses.rose_graph(A)
        RAA = GraphWithInverses.rose_graph(A)
        marking = GraphMap(RA, RAA, dict(
                               (a, Word([a])) for a in A.positive_letters()))

        return MarkedMetricGraph(marking=marking, length=length)
     def rose_marked_graph(alphabet):
          """
          The rose on ``alphabet`` marked with the identity.
          """

          marking=dict((a,a) for a in alphabet.positive_letters())
          return MarkedGraph(graph=GraphWithInverses.rose_graph(alphabet),marking=marking,marking_alphabet=alphabet)
     def HNN_splitting(A):
          """
          The marked metric graph corresponding to the HNN splitting
          F_N=F_{N-1}*<t>.

          The rose marked graph with all edges of length 0 except ``A[0]``
          which is of length 1.
          """

          length=dict((a,0) for a in A.positive_letters())
          length[A[0]]=1

          RA=GraphWithInverses.rose_graph(A)
          RAA=GraphWithInverses.rose_graph(A)
          marking=GraphMap(RA,RAA,edge_map=dict((a,Word([a])) for a in A.positive_letters()))

          return MarkedMetricGraph(marking=marking,length=length)
Esempio n. 4
0
    def rose_map(automorphism):
        """
        Returns the core of the rose and the rose acted upon by the corresponding
        automorphism.
        """

        graph=GraphWithInverses.rose_graph(automorphism._domain._alphabet.copy())
        inv_automorphism=automorphism.inverse()
        return Core(graph,graph,automorphism,inv_automorphism)
Esempio n. 5
0
    def rose_map(automorphism):
        """
        Returns the core of the rose and the rose acted upon by the corresponding
        automorphism.
        """

        graph = GraphWithInverses.rose_graph(
            automorphism._domain._alphabet.copy())
        inv_automorphism = automorphism.inverse()
        return Core(graph, graph, automorphism, inv_automorphism)
     def __init__(self,graph=None,marking=None,alphabet=None,marking_alphabet=None):
         if isinstance(marking,GraphMap):
              GraphWithInverses.__init__(self,marking.codomain(),marking.codomain().alphabet())
              self._marking=marking
         else:
              if isinstance(graph,GraphWithInverses):
                   alphabet=graph._alphabet
              GraphWithInverses.__init__(self,graph,alphabet)

              if marking is None: #computes a (random) marking from a rose equivalent to graph

                   A=graph.alphabet()
                   tree=graph.spanning_tree()

                   j=0
                   letter=dict()
                   for a in A.positive_letters():
                        vi=graph.initial_vertex(a)
                        vt=graph.terminal_vertex(a)
                        if (len(tree[vi])==0 or tree[vi][-1]!=A.inverse_letter(a)) and\
                                 (len(tree[vt])==0 or tree[vt][-1]!=a):
                             letter[j]=a
                             j=j+1



                   B=AlphabetWithInverses(j)
                   RB=GraphWithInverses.rose_graph(B)

                   edge_map=dict()

                   for i in xrange(j):
                        a=letter[i]
                        edge_map[B[i]]=graph.reduce_path(tree[graph.initial_vertex(a)]\
                                                           *Word([a])\
                                                           *graph.reverse_path(tree[graph.terminal_vertex(a)]))

                        marking=GraphMap(RB,graph,edge_map)
              else:
                   marking=GraphMap(GraphWithInverses.rose_graph(marking_alphabet),self,marking)
              self._marking=marking
    def rose_conjugacy_representative(self):
        """
        Topological representative of the conjugacy class of ``self``.

        SEE ALSO:

        This is the same as ``self.rose_representative()`` but the
        base graph of the ``TopologicalRepresentative`` is a
        ``GraphWithInverses`` instead of a ``MarkedGraph``.
        """
        from topological_representative import TopologicalRepresentative
        from inverse_graph import GraphWithInverses

        return TopologicalRepresentative(GraphWithInverses.rose_graph(self._domain.alphabet()),self)
Esempio n. 8
0
    def rose_conjugacy_representative(self):
        """
        Topological representative of the conjugacy class of ``self``.

        SEE ALSO:

        This is the same as ``self.rose_representative()`` but the
        base graph of the ``TopologicalRepresentative`` is a
        ``GraphWithInverses`` instead of a ``MarkedGraph``.
        """
        from topological_representative import TopologicalRepresentative
        from inverse_graph import GraphWithInverses

        return TopologicalRepresentative(
            GraphWithInverses.rose_graph(self._domain.alphabet()), self)
    def rose_marked_graph(alphabet):
        """
        The rose on ``alphabet`` marked with the identity.

        INPUT:

        - ``alphabet`` a alphabet

        OUTPUT:

        The rose on ``alphabet`` marked with the identity.

        EXAMPLES::

            sage: print MarkedGraph.rose_marked_graph(AlphabetWithInverses(2))
            Marked graph: a: 0->0, b: 0->0
            Marking: a->a, b->b
        """

        marking = dict((a, Word([a])) for a in alphabet.positive_letters())
        return MarkedGraph(graph=GraphWithInverses.rose_graph(alphabet),
                           marking=marking, marking_alphabet=alphabet)
    def rose_map(automorphism):
        """
        The graph map of the rose representing the automorphism.

        The rose is built on a copy of the alphabet of the domain of
        ``automorphism``.

        OUTPUT:

        The graph map of the rose representing the automorphism.

        EXAMPLES::

            sage: phi=FreeGroupAutomorphism('a->ab,b->ac,c->a')
            sage: print GraphMap.rose_map(phi)
            Graph map:
            Graph with inverses: a: 0->0, b: 0->0, c: 0->0
            Graph with inverses: a: 0->0, b: 0->0, c: 0->0
            edge map: a->ab, b->ac, c->a
        """

        graph = GraphWithInverses.rose_graph(
            automorphism.domain().alphabet().copy())
        return GraphMap(graph, graph, automorphism)
    def __init__(self, graph=None, marking=None, alphabet=None,
                 marking_alphabet=None):
        """
        INPUT:

        - ``graph`` -- (default None) GraphWithInverses is expected
          or will be combute from ''grap''
        - ``marking`` -- (default None) GraphMap is expected
          or will be compute
        - ``alphabet`` -- (default None) if ``graph`` is GraphWithInverses
          ``alphabet`` will be use for ``self``
        - ``marking_alphabet`` -- (default None) alphabet used in the case of a
          ``MarkedGraph`` is created from a GraphWithInverses`` by
          computing (randomly) a rose equivalent to the graph.

        EXAMPLES::

            sage: G = GraphWithInverses({'a':(0,0),'b':(0,1),'c':(1,0)})
            sage: M = MarkedGraph(graph=G)
            sage: print M
            Marked graph: a: 0->0, c: 1->0, b: 0->1
            Marking: a->a, b->bc
            sage: A = AlphabetWithInverses(2)
            sage: G = GraphWithInverses.rose_graph(A)
            sage: H = GraphWithInverses.rose_graph(A)
            sage: f = GraphMap(G,H,"a->aba,b->ab")
            sage: M = MarkedGraph(marking=f)
            sage: print M
            Marked graph: a: 0->0, b: 0->0
            Marking: a->aba, b->ab
            sage: print MarkedGraph(marking=f, alphabet=A)
            Marked graph: a: 0->0, b: 0->0
            Marking: a->aba, b->ab
            sage: print MarkedGraph(marking=f, marking_alphabet=A)
            Marked graph: a: 0->0, b: 0->0
            Marking: a->aba, b->ab
        """
        if isinstance(marking, GraphMap):
            GraphWithInverses.__init__(self,
                                       marking.codomain(),
                                       marking.codomain().alphabet())
            self._marking = marking
        else:
            if isinstance(graph, GraphWithInverses):
                alphabet = graph.alphabet()
            GraphWithInverses.__init__(self, graph, alphabet)

            if marking is None:  # computes a (random) marking
                # from a rose equivalent to graph

                A = graph.alphabet()
                tree = graph.spanning_tree()

                j = 0
                letter = dict()
                for a in A.positive_letters():
                    vi = graph.initial_vertex(a)
                    vt = graph.terminal_vertex(a)
                    if (len(tree[vi]) == 0 or
                            tree[vi][-1] != A.inverse_letter(a)) \
                            and (len(tree[vt]) == 0 or tree[vt][-1] != a):
                        letter[j] = a
                        j = j + 1

                B = AlphabetWithInverses(j)
                RB = GraphWithInverses.rose_graph(B)

                edge_map = dict()

                for i in xrange(j):
                    a = letter[i]
                    edge_map[B[i]] = graph.reduce_path(
                        tree[graph.initial_vertex(a)] * Word([a]) *
                        graph.reverse_path(tree[graph.terminal_vertex(a)]))
                marking = GraphMap(RB, graph, edge_map)
            else:
                marking = GraphMap(
                    GraphWithInverses.rose_graph(marking_alphabet),
                    self, marking)
            self._marking = marking