Ticket #3703: trac3703-set_edge_label.patch

File trac3703-set_edge_label.patch, 2.0 KB (added by rlm, 13 years ago)
  • sage/graphs/base/sparse_graph.pyx

    # HG changeset patch
    # User Robert L. Miller <rlm@rlmiller.org>
    # Date 1216685783 25200
    # Node ID ac572826f4212184211abdbe0219f5b1b4f179fa
    # Parent  91af4c3f6b92316e4117af342d82be33cf5d949b
    fixed bug in sparse graph backends:set_edge_label
    
    diff -r 91af4c3f6b92 -r ac572826f421 sage/graphs/base/sparse_graph.pyx
    a b class SparseGraphBackend(CGraphBackend): 
    14651465        DOCTEST:
    14661466            sage: G = sage.graphs.base.sparse_graph.SparseGraphBackend(9)
    14671467            sage: G.set_edge_label(1,2,'a',True)
    1468         """       
     1468        """
    14691469        if not self.has_edge(u, v, None):
    14701470            return
    14711471        if self.multiple_edges(None):
    14721472            if len(self.get_edge_label(u, v)) > 1:
    14731473                raise RuntimeError("Cannot set edge label, since there are multiple edges from %s to %s."%(u,v))
     1474        # now we know there is exactly one edge from u to v
    14741475        if directed:
     1476            ll = self.get_edge_label(u,v)
     1477            if ll is not None:
     1478                self._cg.del_arc_label(u, v, ll)
    14751479            self._cg.add_arc_label(u, v, l)
    14761480        else:
     1481            ll = self.get_edge_label(u,v)
     1482            if ll is not None:
     1483                self._cg.del_arc_label(u, v, ll)
     1484                self._cg.del_arc_label(v, u, ll)
    14771485            self._cg.add_arc_label(u, v, l)
    14781486            self._cg.add_arc_label(v, u, l)
    14791487
  • sage/graphs/graph.py

    diff -r 91af4c3f6b92 -r ac572826f421 sage/graphs/graph.py
    a b class GenericGraph(SageObject): 
    27552755            [(0, 1, 5)]
    27562756            sage: dg.incoming_edges(0)
    27572757            [(1, 0, 9)]
     2758
     2759            sage: G = Graph({0:{1:1}}, implementation='c_graph')
     2760            sage: G.num_edges()
     2761            1
     2762            sage: G.set_edge_label(0,1,1)
     2763            sage: G.num_edges()
     2764            1
    27582765
    27592766        """
    27602767        if self.multiple_edges():