def remove_edge(self, e):
        """
        Removes the edge ``e`` (together with its inverse). Removes ``e``
        (and its inverse) from the alphabet.

        INPUT:

        - ``e``  edge  to remove (and its inverse) from the alphabet.



        EXAMPLES::

            sage: G = GraphWithInverses([[0,0,'a'],[0,1,'b'],[1,0,'c']])
            sage: G.remove_edge('b')
            sage: print G
            Graph with inverses: a: 0->0, c: 1->0
        
            sage: G.alphabet()
            Alphabet with inverses on ['a', 'c']
        """
        pe = self._alphabet.to_positive_letter(e)
        ee = self._alphabet.inverse_letter(e)
        DiGraph.delete_edge(self, self.initial_vertex(pe),
                            self.terminal_vertex(pe), pe)
        self._alphabet.remove_letter(e)
        self._initial.pop(e)
        self._initial.pop(ee)
        self._terminal.pop(e)
        self._terminal.pop(ee)
示例#2
0
    def remove_edge(self, e):
        """
        Remove the edge ``e`` (together with its inverse). Removes ``e``
        (and its inverse) from the alphabet.

        INPUT:

        - ``e`` -- edge  to remove (and its inverse) from the alphabet

        EXAMPLES::

            sage: from train_track.inverse_graph import GraphWithInverses
            sage: G = GraphWithInverses([[0,0,'a'],[0,1,'b'],[1,0,'c']])
            sage: G.remove_edge('b')
            sage: print(G)
            a: 0->0, c: 1->0

            sage: G.alphabet()
            Alphabet with inverses on ['a', 'c']
        """
        pe = self._alphabet.to_positive_letter(e)
        ee = self._alphabet.inverse_letter(e)
        DiGraph.delete_edge(self, self.initial_vertex(pe),
                            self.terminal_vertex(pe), pe)
        self._alphabet.remove_letter(e)
        self._initial.pop(e)
        self._initial.pop(ee)
        self._terminal.pop(e)
        self._terminal.pop(ee)
    def set_terminal_vertex(self, e, v):
        """
        Sets the terminal vertex of the edge ``e`` to the vertex
        ``v``.
        
        Consistantly sets the initial vertex of the edge label by
        the inverse of ``e`` to the vertex ``v``.

        INPUT:

        - ``e``  the edge
        - ``v``  the vertex

        EXAMPLES::

            sage: G = GraphWithInverses([[0,0,'a'],[0,1,'b'],[1,0,'c']])
            sage: G.set_terminal_vertex('a',1)
            sage: print G
            Graph with inverses: a: 0->1, b: 0->1, c: 1->0
        """
        w = self.initial_vertex(e)
        ww = self.terminal_vertex(e)
        pe = self._alphabet.to_positive_letter(e)
        if e == pe:
            DiGraph.delete_edge(self, w, ww, pe)
            DiGraph.add_edge(self, w, v, pe)
        else:
            DiGraph.delete_edge(self, ww, w, pe)
            DiGraph.add_edge(self, v, w, pe)

        self._terminal[e] = v
        self._initial[self._alphabet.inverse_letter(e)] = v
示例#4
0
    def set_terminal_vertex(self, e, v):
        """
        Sets the terminal vertex of the edge ``e`` to the vertex
        ``v``.

        Consistantly sets the initial vertex of the edge label by
        the inverse of ``e`` to the vertex ``v``.

        INPUT:

        - ``e`` -- the edge
        - ``v`` -- the vertex

        EXAMPLES::

            sage: from train_track.inverse_graph import GraphWithInverses
            sage: G = GraphWithInverses([[0,0,'a'],[0,1,'b'],[1,0,'c']])
            sage: G.set_terminal_vertex('a',1)
            sage: print(G)
            a: 0->1, b: 0->1, c: 1->0
        """
        w = self.initial_vertex(e)
        ww = self.terminal_vertex(e)
        pe = self._alphabet.to_positive_letter(e)
        if e == pe:
            DiGraph.delete_edge(self, w, ww, pe)
            DiGraph.add_edge(self, w, v, pe)
        else:
            DiGraph.delete_edge(self, ww, w, pe)
            DiGraph.add_edge(self, v, w, pe)

        self._terminal[e] = v
        self._initial[self._alphabet.inverse_letter(e)] = v
 def remove_edge(self,e):
      """
      Removes the edge ``e`` (together with its inverse). Removes ``e``
      (and its inverse) from the alphabet.
      """
      pe=self._alphabet.to_positive_letter(e)
      ee=self._alphabet.inverse_letter(e)
      DiGraph.delete_edge(self,self.initial_vertex(pe),self.terminal_vertex(pe),pe)
      self._alphabet.remove_letter(e)
      self._initial.pop(e)
      self._initial.pop(ee)
      self._terminal.pop(e)
      self._terminal.pop(ee)
示例#6
0
 def remove_edge(self, e):
     """
       Removes the edge ``e`` (together with its inverse). Removes ``e``
       (and its inverse) from the alphabet.
       """
     pe = self._alphabet.to_positive_letter(e)
     ee = self._alphabet.inverse_letter(e)
     DiGraph.delete_edge(self, self.initial_vertex(pe),
                         self.terminal_vertex(pe), pe)
     self._alphabet.remove_letter(e)
     self._initial.pop(e)
     self._initial.pop(ee)
     self._terminal.pop(e)
     self._terminal.pop(ee)
     def set_terminal_vertex(self,e,v):
          """
          Sets the terminal vertex of the edge ``e`` to the vertex
          ``v``.

          Consistantly sets the initial vertex of the edge label by
          the inverse of ``e`` to the vertex ``v``.
          """
          w=self.initial_vertex(e)
          ww=self.terminal_vertex(e)
          pe=self._alphabet.to_positive_letter(e)
          if e==pe:
               DiGraph.delete_edge(self,w,ww,pe)
               DiGraph.add_edge(self,w,v,pe)
          else:
               DiGraph.delete_edge(self,ww,w,pe)
               DiGraph.add_edge(self,v,w,pe)

          self._terminal[e]=v
          self._initial[self._alphabet.inverse_letter(e)]=v
示例#8
0
    def set_terminal_vertex(self, e, v):
        """
          Sets the terminal vertex of the edge ``e`` to the vertex
          ``v``.

          Consistantly sets the initial vertex of the edge label by
          the inverse of ``e`` to the vertex ``v``.
          """
        w = self.initial_vertex(e)
        ww = self.terminal_vertex(e)
        pe = self._alphabet.to_positive_letter(e)
        if e == pe:
            DiGraph.delete_edge(self, w, ww, pe)
            DiGraph.add_edge(self, w, v, pe)
        else:
            DiGraph.delete_edge(self, ww, w, pe)
            DiGraph.add_edge(self, v, w, pe)

        self._terminal[e] = v
        self._initial[self._alphabet.inverse_letter(e)] = v