Ticket #7378: trac_7378ref.patch
File trac_7378ref.patch, 3.0 KB (added by , 11 years ago) 


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 b 5450 5450 5451 5451 INPUT: 5452 5452 5453 The following forms are all accepted to subdivide `8` times5454 the edge between vertices `1` and `2` labeled with5455 ``"my_label"``.5456 5457  ``G.subdivide_edge( 1, 2, 8 )``5458  ``G.subdivide_edge( ( 1, 2), 8)``5459  ``G.subdivide_edge( (1, 2, "my_label"), 8)``5453 The following forms are all accepted to subdivide the edge `(u, v)` 5454 with label `l` into `k` edges. 5455 5456  ``G.subdivide_edge( u, v, k )`` 5457  ``G.subdivide_edge( (u, v), k )`` 5458  ``G.subdivide_edge( (u, v, l), k )`` 5459  ``G.subdivide_edge( u, v, l, k )`` 5460 5460 5461 5461 .. NOTE:: 5462 5462 5463 * If the given edge is labelled with `l`, all the edges5464 created by the subdivision will have the same label.5463 * New edges will have the same label as the edge they 5464 have subdivided. 5465 5465 5466 5466 * If no label is given, the label used will be the one 5467 5467 returned by the method :meth:`edge_label` on the pair … … 5469 5469 5470 5470 EXAMPLE: 5471 5471 5472 Subdividing `5` times an edge in a path of length5473 `3`makes it a path of length `8`::5472 Subdividing an edge in a path of length `3` into `5` edges 5473 makes it a path of length `8`:: 5474 5474 5475 5475 sage: g = graphs.PathGraph(3) 5476 5476 sage: edge = g.edges()[0] … … 5478 5478 sage: g.is_isomorphic(graphs.PathGraph(8)) 5479 5479 True 5480 5480 5481 Subdividing a labelled edge in two ways 5481 Subdividing a labelled edge in two ways:: 5482 5482 5483 5483 sage: g = Graph() 5484 5484 sage: g.add_edge(0,1,"label1") 5485 5485 sage: g.add_edge(1,2,"label2") 5486 sage: printsorted(g.edges())5486 sage: sorted(g.edges()) 5487 5487 [(0, 1, 'label1'), (1, 2, 'label2')] 5488 5488 5489 5489 Specifying the label:: 5490 5490 5491 5491 sage: g.subdivide_edge(0,1,"label1", 3) 5492 sage: printsorted(g.edges())5492 sage: sorted(g.edges()) 5493 5493 [(0, 3, 'label1'), (1, 2, 'label2'), (1, 5, 'label1'), (3, 4, 'label1'), (4, 5, 'label1')] 5494 5494 5495 5495 The lazy way:: 5496 5496 5497 sage: g.subdivide_edge(1,2, "label2",5)5498 sage: printsorted(g.edges())5497 sage: g.subdivide_edge(1,2, 5) 5498 sage: sorted(g.edges()) 5499 5499 [(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')] 5500 5500 5501 5501 If too many arguments are given, an exception is raised ::