# HG changeset patch
# User Alexandre Blondin Masse < alexandre.blondin.masse at gmail.com>
# Date 1269275120 -3600
# Node ID 98a2938bf74039505e6c75eb26095599228e295c
# Parent de040244edb2652600a6b186c226314e622a8cb5
#7569 Review formatting of code and documentation
diff --git a/sage/graphs/generic_graph.py b/sage/graphs/generic_graph.py
a
|
b
|
class GenericGraph(GenericGraph_pyx): |
4579 | 4579 | |
4580 | 4580 | __contains__ = has_vertex |
4581 | 4581 | |
4582 | | def random_vertex(self,**kwds): |
4583 | | r""" |
4584 | | Returns a random vertex. |
4585 | | |
4586 | | INPUT: |
4587 | | |
4588 | | - ``**kwds`` -- arguments to be passed down to the |
| 4582 | def random_vertex(self, **kwds): |
| 4583 | r""" |
| 4584 | Returns a random vertex of self. |
| 4585 | |
| 4586 | INPUT: |
| 4587 | |
| 4588 | - ``**kwds`` - arguments to be passed down to the |
4589 | 4589 | ``vertex_iterator`` method. |
4590 | 4590 | |
4591 | 4591 | EXAMPLE: |
4592 | 4592 | |
4593 | | The returned value belong to the set of vertices:: |
| 4593 | The returned value is a vertex of self:: |
4594 | 4594 | |
4595 | 4595 | sage: g = graphs.PetersenGraph() |
4596 | 4596 | sage: v = g.random_vertex() |
4597 | 4597 | sage: v in g |
4598 | 4598 | True |
4599 | 4599 | """ |
4600 | | |
4601 | 4600 | from sage.misc.prandom import randint |
4602 | 4601 | it = self.vertex_iterator(**kwds) |
4603 | | for i in xrange(0, randint(0,self.order()-1)): |
| 4602 | for i in xrange(0, randint(0, self.order() - 1)): |
4604 | 4603 | it.next() |
4605 | | |
4606 | 4604 | return it.next() |
4607 | 4605 | |
4608 | 4606 | def random_edge(self,**kwds): |
4609 | 4607 | r""" |
4610 | | Returns a random edge. |
4611 | | |
4612 | | INPUT: |
4613 | | |
4614 | | - ``**kwds`` -- arguments to be passed down to the |
| 4608 | Returns a random edge of self. |
| 4609 | |
| 4610 | INPUT: |
| 4611 | |
| 4612 | - ``**kwds`` - arguments to be passed down to the |
4615 | 4613 | ``edge_iterator`` method. |
4616 | 4614 | |
4617 | 4615 | EXAMPLE: |
4618 | 4616 | |
4619 | | The returned value belong to the set of edges:: |
| 4617 | The returned value is an edge of self:: |
4620 | 4618 | |
4621 | 4619 | sage: g = graphs.PetersenGraph() |
4622 | 4620 | sage: u,v = g.random_edge(labels=False) |
… |
… |
class GenericGraph(GenericGraph_pyx): |
4625 | 4623 | |
4626 | 4624 | As the ``edges()`` method would, this function returns |
4627 | 4625 | by default a triple ``(u,v,l)`` of values, in which |
4628 | | ``l`` is the label of edge `u,v` :: |
| 4626 | ``l`` is the label of edge `(u,v)`:: |
4629 | 4627 | |
4630 | 4628 | sage: g.random_edge() |
4631 | 4629 | (...,...,...) |
4632 | 4630 | """ |
4633 | | |
4634 | 4631 | from sage.misc.prandom import randint |
4635 | 4632 | it = self.edge_iterator(**kwds) |
4636 | | for i in xrange(0, randint(0,self.size()-1)): |
| 4633 | for i in xrange(0, randint(0, self.size() - 1)): |
4637 | 4634 | it.next() |
4638 | | |
4639 | 4635 | return it.next() |
4640 | 4636 | |
4641 | 4637 | def vertex_boundary(self, vertices1, vertices2=None): |