# Ticket #7378: trac_7378-ref.patch

File trac_7378-ref.patch, 3.0 KB (added by rlm, 12 years ago)

Apply after trac_7378.patch

• ## sage/graphs/generic_graph.py

```# HG changeset patch
# User Robert L. Miller <rlm@rlmiller.org>
# Date 1277141856 25200
# Node ID 0eb881d40a6bc4b417858f5a090f3614e2bbe215
# Parent  62c942908fef7bb16007873c6bf5847d3aa5343b
#7378: Referee suggestions.

diff -r 62c942908fef -r 0eb881d40a6b sage/graphs/generic_graph.py```
 a INPUT: The following forms are all accepted to subdivide `8` times the edge between vertices `1` and `2` labeled with ``"my_label"``. - ``G.subdivide_edge( 1, 2, 8 )`` - ``G.subdivide_edge( (1, 2), 8 )`` - ``G.subdivide_edge( (1, 2, "my_label"), 8 )`` The following forms are all accepted to subdivide the edge `(u, v)` with label `l` into `k` edges. - ``G.subdivide_edge( u, v, k )`` - ``G.subdivide_edge( (u, v), k )`` - ``G.subdivide_edge( (u, v, l), k )`` - ``G.subdivide_edge( u, v, l, k )`` .. NOTE:: * If the given edge is labelled with `l`, all the edges created by the subdivision will have the same label. * New edges will have the same label as the edge they have subdivided. * If no label is given, the label used will be the one returned by the method :meth:`edge_label` on the pair EXAMPLE: Subdividing `5` times an edge in a path of length `3` makes it a path of length `8`:: Subdividing an edge in a path of length `3` into `5` edges makes it a path of length `8`:: sage: g = graphs.PathGraph(3) sage: edge = g.edges()[0] sage: g.is_isomorphic(graphs.PathGraph(8)) True Subdividing a labelled edge in two ways :: Subdividing a labelled edge in two ways:: sage: g = Graph() sage: g.add_edge(0,1,"label1") sage: g.add_edge(1,2,"label2") sage: print sorted(g.edges()) sage: sorted(g.edges()) [(0, 1, 'label1'), (1, 2, 'label2')] Specifying the label:: sage: g.subdivide_edge(0,1,"label1", 3) sage: print sorted(g.edges()) sage: sorted(g.edges()) [(0, 3, 'label1'), (1, 2, 'label2'), (1, 5, 'label1'), (3, 4, 'label1'), (4, 5, 'label1')] The lazy way:: sage: g.subdivide_edge(1,2,"label2", 5) sage: print sorted(g.edges()) sage: g.subdivide_edge(1,2, 5) sage: sorted(g.edges()) [(0, 3, 'label1'), (1, 5, 'label1'), (1, 6, 'label2'), (2, 10, 'label2'), (3, 4, 'label1'), (4, 5, 'label1'), (6, 7, 'label2'), (7, 8, 'label2'), (8, 9, 'label2'), (9, 10, 'label2')] If too many arguments are given, an exception is raised ::