# Ticket #10900: trac_10900.patch

File trac_10900.patch, 7.4 KB (added by ncohen, 10 years ago)
• ## sage/graphs/base/c_graph.pyx

```# HG changeset patch
# User Nathann Cohen <nathann.cohen@gmail.com>
# Date 1299736826 -28800
# Node ID 299c2995b46c8fb70a1785c46017e67227c67ea5
trac 10900 -- 100% doctest coverage for graphs

diff -r 361a4ad7d52c -r 299c2995b46c sage/graphs/base/c_graph.pyx```
 a - ``test_in`` -- boolean; whether we want to consider the in-neighbors of the graph to be traversed. For undirected graphs, we consider both the in- and out-neighbors. EXAMPLE:: sage: g = graphs.PetersenGraph() sage: list(g.breadth_first_search(0)) [0, 1, 4, 5, 2, 6, 3, 9, 7, 8] """ cdef graph - ``ignore_direction`` -- boolean (default: ``False``). This is only relevant to digraphs. If ``graph`` is a digraph, ignore all orientations and consider the graph as undirected. EXAMPLE:: sage: g = graphs.PetersenGraph() sage: list(g.breadth_first_search(0)) [0, 1, 4, 5, 2, 6, 3, 9, 7, 8] """ self.graph = graph self.direction = direction def __iter__(self): r""" Return an iterator object over a traversal of a graph. EXAMPLE:: sage: g = graphs.PetersenGraph() sage: g.breadth_first_search(0)
• ## sage/graphs/base/dense_graph.pyx

`diff -r 361a4ad7d52c -r 299c2995b46c sage/graphs/base/dense_graph.pyx`
 a Memory usage is O(  (nverts + extra_vertices)^2  ). EXAMPLE:: sage: from sage.graphs.base.dense_graph import DenseGraph sage: D = DenseGraph(nverts = 10, extra_vertices = 10) """ if nverts == 0 and extra_vertices == 0: raise RuntimeError('Dense graphs must allocate space for vertices!')
• ## sage/graphs/base/graph_backends.py

`diff -r 361a4ad7d52c -r 299c2995b46c sage/graphs/base/graph_backends.py`
 a def __init__(self): """ Issue deprecation warnings for the old networkx XGraph formats EXAMPLE:: sage: from sage.graphs.base.graph_backends import NetworkXGraphDeprecated sage: NetworkXGraphDeprecated() doctest:... """ import warnings from sage.misc.misc import deprecation def __init__(self): """ Issue deprecation warnings for the old networkx XDiGraph formats EXAMPLE:: sage: from sage.graphs.base.graph_backends import NetworkXDiGraphDeprecated sage: NetworkXDiGraphDeprecated() doctest:... """ import warnings from sage.misc.misc import deprecation """ Iterate over the incoming edges incident to a sequence of vertices. Special case, only for internal use. EXAMPLE:: sage: g = DiGraph(graphs.PetersenGraph(), implementation="networkx")._backend sage: sorted(list(g.iterator_in_edges([0,1], True))) [(0, 1, None), (1, 0, None), (2, 1, None), (4, 0, None), (5, 0, None), (6, 1, None)] """ try: assert(not isinstance(self._nxg, (NetworkXGraphDeprecated, NetworkXDiGraphDeprecated))) """ Iterate over the outbound edges incident to a sequence of vertices. Special case, only for internal use. EXAMPLE:: sage: g = DiGraph(graphs.PetersenGraph(), implementation="networkx")._backend sage: sorted(list(g.iterator_out_edges([0,1], True))) [(0, 1, None), (0, 4, None), (0, 5, None), (1, 0, None), (1, 2, None), (1, 6, None)] """ try: assert(not isinstance(self._nxg, (NetworkXGraphDeprecated, NetworkXDiGraphDeprecated)))
• ## sage/graphs/base/sparse_graph.pyx

`diff -r 361a4ad7d52c -r 299c2995b46c sage/graphs/base/sparse_graph.pyx`
 a Memory usage is roughly O(  (nverts + extra_vertices)*expected_degree + num_arcs  ). """ EXAMPLE:: sage: from sage.graphs.base.sparse_graph import SparseGraph sage: S = SparseGraph(nverts = 10, expected_degree = 3, extra_vertices = 10) """ cdef int i = 1 if nverts == 0 and extra_vertices == 0: raise RuntimeError('Sparse graphs must allocate space for vertices!')
• ## sage/graphs/generic_graph.py

`diff -r 361a4ad7d52c -r 299c2995b46c sage/graphs/generic_graph.py`
 a def _keys_for_vertices(self): """ Returns a function mapping each vertex to a unique and hopefully readable string Returns a function mapping each vertex to a unique and hopefully readable string EXAMPLE:: sage: g = graphs.Grid2dGraph(5,5) sage: g._keys_for_vertices()
• ## sage/graphs/generic_graph_pyx.pyx

`diff -r 361a4ad7d52c -r 299c2995b46c sage/graphs/generic_graph_pyx.pyx`
 a This constructor only checks there is no inconsistency in the input : `G` and `H` are both graphs or both digraphs. EXAMPLE:: sage: g = graphs.PetersenGraph() sage: g.subgraph_search(graphs.CycleGraph(5)) Subgraph of (Petersen graph): Graph on 5 vertices """ if sum([G.is_directed(), H.is_directed()]) == 1: raise ValueError("One graph can not be directed while the other is not.") Cython constructor This method initializes all the C values. EXAMPLE:: sage: g = graphs.PetersenGraph() sage: g.subgraph_search(graphs.CycleGraph(5)) Subgraph of (Petersen graph): Graph on 5 vertices """ # Storing the number of vertices