# 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
|
|
| 1465 | 1465 | DOCTEST: |
| 1466 | 1466 | sage: G = sage.graphs.base.sparse_graph.SparseGraphBackend(9) |
| 1467 | 1467 | sage: G.set_edge_label(1,2,'a',True) |
| 1468 | | """ |
| | 1468 | """ |
| 1469 | 1469 | if not self.has_edge(u, v, None): |
| 1470 | 1470 | return |
| 1471 | 1471 | if self.multiple_edges(None): |
| 1472 | 1472 | if len(self.get_edge_label(u, v)) > 1: |
| 1473 | 1473 | 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 |
| 1474 | 1475 | 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) |
| 1475 | 1479 | self._cg.add_arc_label(u, v, l) |
| 1476 | 1480 | 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) |
| 1477 | 1485 | self._cg.add_arc_label(u, v, l) |
| 1478 | 1486 | self._cg.add_arc_label(v, u, l) |
| 1479 | 1487 | |
diff -r 91af4c3f6b92 -r ac572826f421 sage/graphs/graph.py
|
a
|
b
|
|
| 2755 | 2755 | [(0, 1, 5)] |
| 2756 | 2756 | sage: dg.incoming_edges(0) |
| 2757 | 2757 | [(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 |
| 2758 | 2765 | |
| 2759 | 2766 | """ |
| 2760 | 2767 | if self.multiple_edges(): |