# HG changeset patch
# User Nathann Cohen <nathann.cohen@gmail.com>
# Date 1371902834 7200
# Sat Jun 22 14:07:14 2013 +0200
# Node ID 0eee5ed9955fd55b5fb02b524b1c9a59067234eb
# Parent 5d8c13e7b81a1e152855073f97a4d48ee97255d1
Adds sage.graphs.base.graph_backend to the documentation
diff git a/doc/en/reference/graphs/index.rst b/doc/en/reference/graphs/index.rst
a

b


38  38  sage/graphs/base/sparse_graph 
39  39  sage/graphs/base/dense_graph 
40  40  sage/graphs/base/static_sparse_graph 
 41  sage/graphs/base/graph_backends 
41  42  
42  43  Hypergraphs 
43  44   
diff git a/sage/graphs/base/graph_backends.py b/sage/graphs/base/graph_backends.py
a

b


20  20  extensions of this class. Note, this graph has a number of placeholder 
21  21  functions, so the doctests are rather silly. 
22  22  
23   DOCTEST: 
 23  TESTS:: 
 24  
24  25  sage: import sage.graphs.base.graph_backends 
25  26  
26  27  """ 
… 
… 

31  32  """ 
32  33  Add an edge (u,v) to self, with label l. If directed is True, this is 
33  34  interpreted as an arc from u to v. 
34   
35   INPUT: 
36   u,v: vertices 
37   l: edge label 
38   directed: boolean 
39   
40   DOCTEST: 
 35  
 36  INPUT:: 
 37  
 38   ``u,v``  vertices 
 39   ``l``  edge label 
 40   ``directed``  boolean 
 41  
 42  TESTS:: 
 43  
41  44  sage: G = sage.graphs.base.graph_backends.GenericGraphBackend() 
42  45  sage: G.add_edge(1,2,'a',True) 
43  46  Traceback (most recent call last): 
… 
… 

49  52  """ 
50  53  Add a sequence of edges to self. If directed is True, these are 
51  54  interpreted as arcs. 
52   
 55  
53  56  INPUT: 
54   edges: iterator 
55   directed: boolean 
56   
57   DOCTEST: 
 57  
 58   ``edges``  list/iterator of edges to be added. 
 59  
 60   ``directed``  boolean 
 61  
 62  TESTS:: 
 63  
58  64  sage: G = sage.graphs.base.graph_backends.GenericGraphBackend() 
59  65  sage: G.add_edges([],True) 
60  66  Traceback (most recent call last): 
61  67  ... 
62  68  NotImplementedError 
63   """ 
 69  """ 
64  70  raise NotImplementedError() 
 71  
65  72  def add_vertex(self, name): 
66  73  """ 
67  74  Add a labelled vertex to self. 
68   
 75  
69  76  INPUT: 
70  77  
71  78   ``name``  vertex label 
72   
 79  
73  80  OUTPUT: 
74  81  
75   If ``name``=``None``, the new vertex name is returned, ``None`` otherwise. 
 82  If ``name=None``, the new vertex name is returned, ``None`` otherwise. 
76  83  
77   DOCTEST: 
 84  TESTS:: 
 85  
78  86  sage: G = sage.graphs.base.graph_backends.GenericGraphBackend() 
79  87  sage: G.add_vertex(0) 
80  88  Traceback (most recent call last): 
81  89  ... 
82  90  NotImplementedError 
83   """ 
 91  """ 
84  92  raise NotImplementedError() 
85  93  def add_vertices(self, vertices): 
86  94  """ 
87  95  Add labelled vertices to self. 
88   
 96  
89  97  INPUT: 
90  98  
91    ``vertices``: iterator of vertex labels. A new label is created, used and returned in 
92   the output list for all ``None`` values in ``vertices``. 
 99   ``vertices``  iterator of vertex labels. A new label is created, 
 100  used and returned in the output list for all ``None`` values in 
 101  ``vertices``. 
93  102  
94  103  OUTPUT: 
95  104  
… 
… 

103  112  Traceback (most recent call last): 
104  113  ... 
105  114  NotImplementedError 
106   """ 
 115  """ 
107  116  raise NotImplementedError() 
108  117  def degree(self, v, directed): 
109  118  """ 
110  119  Returns the total number of vertices incident to v. 
111   
 120  
112  121  INPUT: 
113   v: a vertex label 
114   directed: boolean 
 122  
 123   ``v``  a vertex label 
 124   ``directed``  boolean 
 125  
115  126  OUTPUT: 
 127  
116  128  degree of v 
117   
118   DOCTEST: 
 129  
 130  TESTS:: 
 131  
119  132  sage: G = sage.graphs.base.graph_backends.GenericGraphBackend() 
120  133  sage: G.degree(1, False) 
121  134  Traceback (most recent call last): 
122  135  ... 
123  136  NotImplementedError 
124   """ 
 137  """ 
125  138  raise NotImplementedError() 
126  139  def del_edge(self, u, v, l, directed): 
127  140  """ 
128  141  Deletes the edge (u,v) with label l. 
129  142  
130  143  INPUT: 
131   u,v: vertices 
132   l: edge label 
133   directed: boolean 
134   
135   DOCTEST: 
 144  
 145   ``u,v``  vertices 
 146   ``l``  edge label 
 147   ``directed``  boolean 
 148  
 149  TESTS:: 
 150  
136  151  sage: G = sage.graphs.base.graph_backends.GenericGraphBackend() 
137  152  sage: G.del_edge(1,2,'a',True) 
138  153  Traceback (most recent call last): 
139  154  ... 
140  155  NotImplementedError 
141   """ 
 156  """ 
142  157  raise NotImplementedError() 
143  158  def del_vertex(self, v): 
144  159  """ 
145  160  Delete a labelled vertex in self. 
146   
 161  
147  162  INPUT: 
148   v: vertex label 
149   
150   DOCTEST: 
 163  
 164   ``v``  vertex label 
 165  
 166  TESTS:: 
 167  
151  168  sage: G = sage.graphs.base.graph_backends.GenericGraphBackend() 
152  169  sage: G.del_vertex(0) 
153  170  Traceback (most recent call last): 
154  171  ... 
155  172  NotImplementedError 
156   """ 
 173  """ 
157  174  raise NotImplementedError() 
158  175  def del_vertices(self, vertices): 
159  176  """ 
160  177  Delete labelled vertices in self. 
161   
 178  
162  179  INPUT: 
163   vertices: iterator of vertex labels 
164   
165   DOCTEST: 
 180  
 181   ``vertices``  iterator of vertex labels 
 182  
 183  TESTS:: 
 184  
166  185  sage: G = sage.graphs.base.graph_backends.GenericGraphBackend() 
167  186  sage: G.del_vertices([1,2,3]) 
168  187  Traceback (most recent call last): 
169  188  ... 
170  189  NotImplementedError 
171   """ 
 190  """ 
172  191  raise NotImplementedError() 
173  192  def get_edge_label(self, u, v): 
174  193  """ 
175  194  Returns the edge label of (u,v). 
176  195  
177  196  INPUT: 
178   u,v: vertex labels 
179   
 197  
 198   ``u,v``  vertex labels 
 199  
180  200  OUTPUT: 
 201  
181  202  label of (u,v) 
182   
183   DOCTEST: 
 203  
 204  TESTS:: 
 205  
184  206  sage: G = sage.graphs.base.graph_backends.GenericGraphBackend() 
185  207  sage: G.get_edge_label(1,2) 
186  208  Traceback (most recent call last): 
187  209  ... 
188  210  NotImplementedError 
189   """ 
 211  """ 
190  212  raise NotImplementedError() 
191  213  def has_edge(self, u, v, l): 
192  214  """ 
193  215  True if self has an edge (u,v) with label l. 
194  216  
195  217  INPUT: 
196   u,v: vertex labels 
197   l: label 
198   
 218  
 219   ``u,v``  vertex labels 
 220   ``l``  label 
 221  
199  222  OUTPUT: 
 223  
200  224  boolean 
201   
202   DOCTEST: 
 225  
 226  TESTS:: 
 227  
203  228  sage: G = sage.graphs.base.graph_backends.GenericGraphBackend() 
204  229  sage: G.has_edge(1,2,'a') 
205  230  Traceback (most recent call last): 
206  231  ... 
207  232  NotImplementedError 
208   """ 
 233  """ 
209  234  raise NotImplementedError() 
210  235  def has_vertex(self, v): 
211  236  """ 
212  237  True if self has a vertex with label v. 
213  238  
214  239  INPUT: 
215   v: vertex label 
216   
 240  
 241   ``v``  vertex label 
 242  
217  243  OUTPUT: 
218  244  boolean 
219   
220   DOCTEST: 
 245  
 246  TESTS:: 
 247  
221  248  sage: G = sage.graphs.base.graph_backends.GenericGraphBackend() 
222  249  sage: G.has_vertex(0) 
223  250  Traceback (most recent call last): 
224  251  ... 
225  252  NotImplementedError 
226   """ 
 253  """ 
227  254  raise NotImplementedError() 
228  255  def iterator_edges(self, vertices, labels): 
229  256  """ 
230  257  Iterate over the edges incident to a sequence of vertices. Edges are 
231  258  assumed to be undirected. 
232   
 259  
233  260  INPUT: 
234   vertices: a list of vertex labels 
235   labels: boolean 
236   
 261  
 262   ``vertices``  a list of vertex labels 
 263   ``labels``  boolean 
 264  
237  265  OUTPUT: 
238   a generator which yields edges, with or without labels 
 266  
 267  a generator which yields edges, with or without labels 
239  268  depending on the labels parameter. 
240   
241   DOCTEST: 
 269  
 270  TESTS:: 
 271  
242  272  sage: G = sage.graphs.base.graph_backends.GenericGraphBackend() 
243  273  sage: G.iterator_edges([],True) 
244  274  Traceback (most recent call last): 
… 
… 

249  279  def iterator_in_edges(self, vertices, labels): 
250  280  """ 
251  281  Iterate over the incoming edges incident to a sequence of vertices. 
252   
 282  
253  283  INPUT: 
254   vertices: a list of vertex labels 
255   labels: boolean 
256   
 284  
 285   ``vertices``  a list of vertex labels 
 286   ``labels``  boolean 
 287  
257  288  OUTPUT: 
258   a generator which yields edges, with or without labels 
 289  a generator which yields edges, with or without labels 
259  290  depending on the labels parameter. 
260   
261   DOCTEST: 
 291  
 292  TESTS:: 
 293  
262  294  sage: G = sage.graphs.base.graph_backends.GenericGraphBackend() 
263  295  sage: G.iterator_in_edges([],True) 
264  296  Traceback (most recent call last): 
… 
… 

269  301  def iterator_out_edges(self, vertices, labels): 
270  302  """ 
271  303  Iterate over the outbound edges incident to a sequence of vertices. 
272   
 304  
273  305  INPUT: 
274   vertices: a list of vertex labels 
275   labels: boolean 
276   
 306  
 307   ``vertices``  a list of vertex labels 
 308   ``labels``  boolean 
 309  
277  310  OUTPUT: 
278   a generator which yields edges, with or without labels 
 311  
 312  a generator which yields edges, with or without labels 
279  313  depending on the labels parameter. 
280   
281   DOCTEST: 
 314  
 315  TESTS:: 
 316  
282  317  sage: G = sage.graphs.base.graph_backends.GenericGraphBackend() 
283  318  sage: G.iterator_out_edges([],True) 
284  319  Traceback (most recent call last): 
… 
… 

289  324  def iterator_nbrs(self, v): 
290  325  """ 
291  326  Iterate over the vertices adjacent to v. 
292   
 327  
293  328  INPUT: 
294   v: vertex label 
295   
 329  
 330   ``v``  vertex label 
 331  
296  332  OUTPUT: 
 333  
297  334  a generator which yields vertex labels 
298   
299   DOCTEST: 
 335  
 336  TESTS:: 
 337  
300  338  sage: G = sage.graphs.base.graph_backends.GenericGraphBackend() 
301  339  sage: G.iterator_nbrs(0) 
302  340  Traceback (most recent call last): 
… 
… 

308  346  """ 
309  347  Iterate over the vertices u such that the edge (u,v) is in self 
310  348  (that is, predecessors of v). 
311   
 349  
312  350  INPUT: 
313   v: vertex label 
314   
 351  
 352   ``v``  vertex label 
 353  
315  354  OUTPUT: 
 355  
316  356  a generator which yields vertex labels 
317   
318   DOCTEST: 
 357  
 358  TESTS:: 
 359  
319  360  sage: G = sage.graphs.base.graph_backends.GenericGraphBackend() 
320  361  sage: G.iterator_in_nbrs(0) 
321  362  Traceback (most recent call last): 
… 
… 

327  368  """ 
328  369  Iterate over the vertices u such that the edge (v,u) is in self 
329  370  (that is, successors of v). 
330   
 371  
331  372  INPUT: 
332   v: vertex label 
333   
 373  
 374   ``v``  vertex label 
 375  
334  376  OUTPUT: 
 377  
335  378  a generator which yields vertex labels 
336   
337   DOCTEST: 
 379  
 380  TESTS:: 
 381  
338  382  sage: G = sage.graphs.base.graph_backends.GenericGraphBackend() 
339  383  sage: G.iterator_out_nbrs(0) 
340  384  Traceback (most recent call last): 
… 
… 

345  389  def iterator_verts(self, verts): 
346  390  """ 
347  391  Iterate over the vertices v with labels in verts. 
348   
 392  
349  393  INPUT: 
350   vertex: vertex labels 
351   
 394  
 395   ``vertex``  vertex labels 
 396  
352  397  OUTPUT: 
 398  
353  399  a generator which yields vertices 
354   
355   DOCTEST: 
 400  
 401  TESTS:: 
 402  
356  403  sage: G = sage.graphs.base.graph_backends.GenericGraphBackend() 
357  404  sage: G.iterator_verts(0) 
358  405  Traceback (most recent call last): 
… 
… 

360  407  NotImplementedError 
361  408  """ 
362  409  raise NotImplementedError() 
363   def loops(self, new): 
 410  
 411  def loops(self, new=None): 
364  412  """ 
365   Get/set whether or not self allows loops. 
366   
 413  Get/set whether or not self allows loops. 
 414  
367  415  INPUT: 
368   new: boolean or None 
369   
370   DOCTEST: 
 416  
 417   ``new``  can be a boolean (in which case it sets the value) or 
 418  ``None``, in which case the current value is returned. It is set to 
 419  ``None`` by default. 
 420  
 421  TESTS:: 
 422  
371  423  sage: G = sage.graphs.base.graph_backends.GenericGraphBackend() 
372  424  sage: G.loops(True) 
373  425  Traceback (most recent call last): 
… 
… 

379  431  NotImplementedError 
380  432  """ 
381  433  raise NotImplementedError() 
382   def multiple_edges(self, new): 
 434  def multiple_edges(self, new=None): 
383  435  """ 
384  436  Get/set whether or not self allows multiple edges. 
385   
 437  
386  438  INPUT: 
387   new: boolean or None 
388   
389   DOCTEST: 
 439  
 440   ``new``  can be a boolean (in which case it sets the value) or 
 441  ``None``, in which case the current value is returned. It is set to 
 442  ``None`` by default. 
 443  
 444  TESTS:: 
 445  
390  446  sage: G = sage.graphs.base.graph_backends.GenericGraphBackend() 
391  447  sage: G.multiple_edges(True) 
392  448  Traceback (most recent call last): 
… 
… 

398  454  NotImplementedError 
399  455  """ 
400  456  raise NotImplementedError() 
401   def name(self, new): 
 457  def name(self, new=None): 
402  458  """ 
403  459  Get/set name of self. 
404   
 460  
405  461  INPUT: 
406   new: string or None 
407   
408   DOCTEST: 
 462  
 463   ``new``  can be a string (in which case it sets the value) or 
 464  ``None``, in which case the current value is returned. It is set to 
 465  ``None`` by default. 
 466  
 467  TESTS:: 
 468  
409  469  sage: G = sage.graphs.base.graph_backends.GenericGraphBackend() 
410  470  sage: G.name("A Generic Graph") 
411  471  Traceback (most recent call last): 
… 
… 

420  480  def num_edges(self, directed): 
421  481  """ 
422  482  The number of edges in self 
423   
 483  
424  484  INPUT: 
425   directed: boolean 
426   
427   DOCTEST: 
 485  
 486   ``directed``  boolean 
 487  
 488  TESTS:: 
 489  
428  490  sage: G = sage.graphs.base.graph_backends.GenericGraphBackend() 
429  491  sage: G.num_edges(True) 
430  492  Traceback (most recent call last): 
… 
… 

439  501  def num_verts(self): 
440  502  """ 
441  503  The number of vertices in self 
442   
443   DOCTEST: 
 504  
 505  TESTS:: 
 506  
444  507  sage: G = sage.graphs.base.graph_backends.GenericGraphBackend() 
445  508  sage: G.num_verts() 
446  509  Traceback (most recent call last): 
… 
… 

451  514  def relabel(self, perm, directed): 
452  515  """ 
453  516  Relabel the vertices of self by a permutation. 
 517  
454  518  INPUT: 
455   perm: permutation 
456   directed: boolean 
457   
458   DOCTEST: 
 519  
 520   ``perm``  permutation 
 521   ``directed``  boolean 
 522  
 523  TESTS:: 
 524  
459  525  sage: G = sage.graphs.base.graph_backends.GenericGraphBackend() 
460  526  sage: G.relabel([],False) 
461  527  Traceback (most recent call last): 
… 
… 

466  532  def set_edge_label(self, u, v, l, directed): 
467  533  """ 
468  534  Label the edge (u,v) by l. 
469   
 535  
470  536  INPUT: 
471   u,v: vertices 
472   l: edge label 
473   directed: boolean 
474   
475   DOCTEST: 
 537  
 538   ``u,v``  vertices 
 539   ``l``  edge label 
 540   ``directed``  boolean 
 541  
 542  TESTS:: 
 543  
476  544  sage: G = sage.graphs.base.graph_backends.GenericGraphBackend() 
477  545  sage: G.set_edge_label(1,2,'a',True) 
478  546  Traceback (most recent call last): 
479  547  ... 
480  548  NotImplementedError 
481   """ 
 549  """ 
482  550  raise NotImplementedError() 
483  551  
484  552  class NetworkXGraphDeprecated(SageObject): 
485  553  """ 
486  554  Class for unpickling old networkx.XGraph formats 
487  555  
488   DOCTEST:: 
 556  TESTS:: 
489  557  
490  558  sage: from sage.graphs.base.graph_backends import NetworkXGraphDeprecated as NXGD 
491  559  sage: X = NXGD() 
492  560  doctest:... 
493   
 561  
494  562  """ 
495  563  
496  564  def __init__(self): 
… 
… 

557  625  """ 
558  626  Class for unpickling old networkx.XDiGraph formats 
559  627  
560   DOCTEST: 
 628  TESTS:: 
 629  
561  630  sage: import sage.graphs.base.graph_backends 
562  631  """ 
563  632  
… 
… 

629  698  """ 
630  699  A wrapper for NetworkX as the backend of a graph. 
631  700  
632   DOCTEST: 
 701  TESTS:: 
 702  
633  703  sage: import sage.graphs.base.graph_backends 
634  704  
635  705  """ 
… 
… 

639  709  def __init__(self, N=None): 
640  710  """ 
641  711  Initialize the backend with NetworkX graph N. 
642   
643   DOCTEST: 
 712  
 713  TESTS:: 
 714  
644  715  sage: G = sage.graphs.base.graph_backends.NetworkXGraphBackend() 
645  716  sage: G.iterator_edges([],True) 
646  717  <generator object iterator_edges at ...> 
… 
… 

659  730  """ 
660  731  Add an edge (u,v) to self, with label l. If directed is True, this is 
661  732  interpreted as an arc from u to v. 
662   
 733  
663  734  INPUT: 
664   u,v: vertices 
665   l: edge label 
666   directed: boolean 
667   
668   DOCTEST: 
 735  
 736   ``u,v``  vertices 
 737   ``l``  edge label 
 738   ``directed``  boolean 
 739  
 740  TESTS:: 
 741  
669  742  sage: G = sage.graphs.base.graph_backends.NetworkXGraphBackend() 
670  743  sage: G.add_edge(1,2,'a',True) 
671  744  """ 
… 
… 

687  760  """ 
688  761  Add a sequence of edges to self. If directed is True, these are 
689  762  interpreted as arcs. 
690   
 763  
691  764  INPUT: 
692   edges: iterator 
693   directed: boolean 
694   
695   DOCTEST: 
 765  
 766   ``edges``  list/iterator of edges to be added. 
 767   ``directed``  boolean 
 768  
 769  TESTS:: 
 770  
696  771  sage: G = sage.graphs.base.graph_backends.NetworkXGraphBackend() 
697  772  sage: G.add_edges([],True) 
698  773  """ 
… 
… 

707  782  def add_vertex(self, name): 
708  783  """ 
709  784  Add a labelled vertex to self. 
710   
 785  
711  786  INPUT: 
712  787  
713  788   ``name``: vertex label 
714   
 789  
715  790  OUTPUT: 
716  791  
717   If ``name``=``None``, the new vertex name is returned. ``None`` otherwise. 
 792  If ``name=None``, the new vertex name is returned. ``None`` otherwise. 
718  793  
719   DOCTEST: 
 794  TESTS:: 
720  795  
721  796  sage: G = sage.graphs.base.graph_backends.NetworkXGraphBackend() 
722  797  sage: G.add_vertex(0) 
… 
… 

785  860  def degree(self, v, directed): 
786  861  """ 
787  862  Returns the total number of vertices incident to v. 
788   
 863  
789  864  INPUT: 
790   v: a vertex label 
791   directed: boolean 
 865  
 866   ``v``  a vertex label 
 867   ``directed``  boolean 
 868  
792  869  OUTPUT: 
 870  
793  871  degree of v 
794   
795   DOCTEST: 
 872  
 873  TESTS:: 
 874  
796  875  sage: G = sage.graphs.base.graph_backends.NetworkXGraphBackend() 
797  876  sage: G.add_vertices(range(3)) 
798  877  sage: G.degree(1, False) 
… 
… 

810  889  Deletes the edge (u,v) with label l. 
811  890  
812  891  INPUT: 
813   u,v: vertices 
814   l: edge label 
815   directed: boolean 
816   
817   DOCTEST: 
 892  
 893   ``u,v``  vertices 
 894   ``l``  edge label 
 895   ``directed``  boolean 
 896  
 897  TESTS:: 
 898  
818  899  sage: G = sage.graphs.base.graph_backends.NetworkXGraphBackend() 
819  900  sage: G.del_edge(1,2,'a',True) 
820  901  """ 
… 
… 

840  921  def del_vertex(self, v): 
841  922  """ 
842  923  Delete a labelled vertex in self. 
843   
 924  
844  925  INPUT: 
845   v: vertex label 
846   
847   DOCTEST: 
 926  
 927   ``v``  vertex label 
 928  
 929  TESTS:: 
 930  
848  931  sage: G = sage.graphs.base.graph_backends.NetworkXGraphBackend() 
849  932  sage: G.del_vertex(0) 
850  933  Traceback (most recent call last): 
… 
… 

861  944  def del_vertices(self, vertices): 
862  945  """ 
863  946  Delete labelled vertices in self. 
864   
 947  
865  948  INPUT: 
866   vertices: iterator of vertex labels 
867   
868   DOCTEST: 
 949  
 950   ``vertices``  iterator of vertex labels 
 951  
 952  TESTS:: 
 953  
869  954  sage: G = sage.graphs.base.graph_backends.NetworkXGraphBackend() 
870  955  sage: G.del_vertices([1,2,3]) 
871  956  Traceback (most recent call last): 
… 
… 

885  970  Returns the edge label of (u,v). 
886  971  
887  972  INPUT: 
888   u,v: vertex labels 
889   
 973  
 974   ``u,v``  vertex labels 
 975  
890  976  OUTPUT: 
891  977  label of (u,v) 
892   
893   DOCTEST: 
 978  
 979  TESTS:: 
 980  
894  981  sage: G = sage.graphs.base.graph_backends.NetworkXGraphBackend() 
895  982  sage: G.get_edge_label(1,2) 
896  983  Traceback (most recent call last): 
… 
… 

918  1005  True if self has an edge (u,v) with label l. 
919  1006  
920  1007  INPUT: 
921   u,v: vertex labels 
922   l: label 
923   
 1008  
 1009   ``u,v``  vertex labels 
 1010   ``l``  label 
 1011  
924  1012  OUTPUT: 
925  1013  boolean 
926   
927   DOCTEST: 
 1014  
 1015  TESTS:: 
 1016  
928  1017  sage: G = sage.graphs.base.graph_backends.NetworkXGraphBackend() 
929  1018  sage: G.has_edge(1,2,'a') 
930  1019  False 
… 
… 

948  1037  True if self has a vertex with label v. 
949  1038  
950  1039  INPUT: 
951   v: vertex label 
952   
 1040  
 1041   ``v``  vertex label 
 1042  
953  1043  OUTPUT: 
954  1044  boolean 
955   
956   DOCTEST: 
 1045  
 1046  TESTS:: 
 1047  
957  1048  sage: G = sage.graphs.base.graph_backends.NetworkXGraphBackend() 
958  1049  sage: G.has_vertex(0) 
959  1050  False 
… 
… 

969  1060  """ 
970  1061  Iterate over the edges incident to a sequence of vertices. Edges are 
971  1062  assumed to be undirected. 
972   
 1063  
973  1064  INPUT: 
974   vertices: a list of vertex labels 
975   labels: boolean 
976   
 1065  
 1066   ``vertices``  a list of vertex labels 
 1067   ``labels``  boolean 
 1068  
977  1069  OUTPUT: 
978   a generator which yields edges, with or without labels 
 1070  a generator which yields edges, with or without labels 
979  1071  depending on the labels parameter. 
980   
981   DOCTEST: 
 1072  
 1073  TESTS:: 
 1074  
982  1075  sage: G = sage.graphs.base.graph_backends.NetworkXGraphBackend() 
983  1076  sage: G.iterator_edges([],True) 
984  1077  <generator object iterator_edges at ...> 
… 
… 

1019  1112  def iterator_in_edges(self, vertices, labels): 
1020  1113  """ 
1021  1114  Iterate over the incoming edges incident to a sequence of vertices. 
1022   
 1115  
1023  1116  INPUT: 
1024   vertices: a list of vertex labels 
1025   labels: boolean 
1026   
 1117  
 1118   ``vertices``  a list of vertex labels 
 1119   ``labels``  boolean 
 1120  
1027  1121  OUTPUT: 
1028   a generator which yields edges, with or without labels 
 1122  a generator which yields edges, with or without labels 
1029  1123  depending on the labels parameter. 
1030   
1031   DOCTEST: 
 1124  
 1125  TESTS:: 
 1126  
1032  1127  sage: G = sage.graphs.base.graph_backends.NetworkXGraphBackend() 
1033  1128  sage: i = G.iterator_in_edges([],True) 
1034  1129  """ 
… 
… 

1067  1162  def iterator_out_edges(self, vertices, labels): 
1068  1163  """ 
1069  1164  Iterate over the outbound edges incident to a sequence of vertices. 
1070   
 1165  
1071  1166  INPUT: 
1072   vertices: a list of vertex labels 
1073   labels: boolean 
1074   
 1167  
 1168   ``vertices``  a list of vertex labels 
 1169   ``labels``  boolean 
 1170  
1075  1171  OUTPUT: 
1076   a generator which yields edges, with or without labels 
 1172  a generator which yields edges, with or without labels 
1077  1173  depending on the labels parameter. 
1078   
1079   DOCTEST: 
 1174  
 1175  TESTS:: 
 1176  
1080  1177  sage: G = sage.graphs.base.graph_backends.NetworkXGraphBackend() 
1081  1178  sage: i = G.iterator_out_edges([],True) 
1082  1179  """ 
… 
… 

1096  1193  def iterator_nbrs(self, v): 
1097  1194  """ 
1098  1195  Iterate over the vertices adjacent to v. 
1099   
 1196  
1100  1197  INPUT: 
1101   v: vertex label 
1102   
 1198  
 1199   ``v``  vertex label 
 1200  
1103  1201  OUTPUT: 
1104  1202  a generator which yields vertex labels 
1105   
1106   DOCTEST: 
 1203  
 1204  TESTS:: 
 1205  
1107  1206  sage: G = sage.graphs.base.graph_backends.NetworkXGraphBackend() 
1108  1207  sage: G.add_vertex(0) 
1109  1208  sage: G.iterator_nbrs(0) 
… 
… 

1120  1219  """ 
1121  1220  Iterate over the vertices u such that the edge (u,v) is in self 
1122  1221  (that is, predecessors of v). 
1123   
 1222  
1124  1223  INPUT: 
1125   v: vertex label 
1126   
 1224  
 1225   ``v``  vertex label 
 1226  
1127  1227  OUTPUT: 
1128  1228  a generator which yields vertex labels 
1129   
1130   DOCTEST: 
 1229  
 1230  TESTS:: 
 1231  
1131  1232  sage: G = sage.graphs.base.graph_backends.NetworkXGraphBackend() 
1132  1233  sage: G.iterator_in_nbrs(0) 
1133  1234  Traceback (most recent call last): 
… 
… 

1145  1246  """ 
1146  1247  Iterate over the vertices u such that the edge (v,u) is in self 
1147  1248  (that is, successors of v). 
1148   
 1249  
1149  1250  INPUT: 
1150   v: vertex label 
1151   
 1251  
 1252   ``v``  vertex label 
 1253  
1152  1254  OUTPUT: 
1153  1255  a generator which yields vertex labels 
1154   
1155   DOCTEST: 
 1256  
 1257  TESTS:: 
 1258  
1156  1259  sage: G = sage.graphs.base.graph_backends.NetworkXGraphBackend() 
1157  1260  sage: G.iterator_out_nbrs(0) 
1158  1261  Traceback (most recent call last): 
… 
… 

1169  1272  def iterator_verts(self, verts): 
1170  1273  """ 
1171  1274  Iterate over the vertices v with labels in verts. 
1172   
 1275  
1173  1276  INPUT: 
1174   vertex: vertex labels 
1175   
 1277  
 1278   ``vertex``  vertex labels 
 1279  
1176  1280  OUTPUT: 
1177  1281  a generator which yields vertices 
1178   
1179   DOCTEST: 
 1282  
 1283  TESTS:: 
 1284  
1180  1285  sage: G = sage.graphs.base.graph_backends.NetworkXGraphBackend() 
1181  1286  sage: G.iterator_verts(0) 
1182  1287  <generator object bunch_iter at ...> 
… 
… 

1188  1293  
1189  1294  return self._nxg.nbunch_iter(verts) 
1190  1295  
1191   def loops(self, new): 
 1296  def loops(self, new=None): 
1192  1297  """ 
1193   Get/set whether or not self allows loops. 
1194   
 1298  Get/set whether or not self allows loops. 
 1299  
1195  1300  INPUT: 
1196   new: boolean or None 
1197   
1198   DOCTEST: 
 1301  
 1302   ``new``  can be a boolean (in which case it sets the value) or 
 1303  ``None``, in which case the current value is returned. It is set to 
 1304  ``None`` by default. 
 1305  
 1306  TESTS:: 
 1307  
1199  1308  sage: G = sage.graphs.base.graph_backends.NetworkXGraphBackend() 
1200  1309  sage: G.loops(True) 
1201  1310  sage: G.loops(None) 
… 
… 

1208  1317  else: 
1209  1318  self._loops = False 
1210  1319  
1211   def multiple_edges(self, new): 
 1320  def multiple_edges(self, new=None): 
1212  1321  """ 
1213  1322  Get/set whether or not self allows multiple edges. 
1214   
 1323  
1215  1324  INPUT: 
1216   new: boolean or None 
1217   
1218   DOCTEST: 
 1325  
 1326   ``new``  can be a boolean (in which case it sets the value) or 
 1327  ``None``, in which case the current value is returned. It is set to 
 1328  ``None`` by default. 
 1329  
 1330  TESTS:: 
 1331  
1219  1332  sage: G = sage.graphs.base.graph_backends.NetworkXGraphBackend() 
1220  1333  sage: G.multiple_edges(True) 
1221  1334  sage: G.multiple_edges(None) 
… 
… 

1242  1355  else: 
1243  1356  self._nxg = Graph(self._nxg) 
1244  1357  
1245   def name(self, new): 
 1358  def name(self, new=None): 
1246  1359  """ 
1247  1360  Get/set name of self. 
1248   
 1361  
1249  1362  INPUT: 
1250   new: string or None 
1251   
1252   DOCTEST: 
 1363  
 1364   ``new``  can be a string (in which case it sets the value) or 
 1365  ``None``, in which case the current value is returned. It is set to 
 1366  ``None`` by default. 
 1367  
 1368  TESTS:: 
 1369  
1253  1370  sage: G = sage.graphs.base.graph_backends.NetworkXGraphBackend() 
1254  1371  sage: G.name("A NetworkX Graph") 
1255  1372  sage: G.name(None) 
… 
… 

1267  1384  def num_edges(self, directed): 
1268  1385  """ 
1269  1386  The number of edges in self 
1270   
 1387  
1271  1388  INPUT: 
1272   directed: boolean 
1273   
1274   DOCTEST: 
 1389  
 1390   ``directed``  boolean 
 1391  
 1392  TESTS:: 
 1393  
1275  1394  sage: G = sage.graphs.base.graph_backends.NetworkXGraphBackend() 
1276  1395  sage: G.num_edges(True) 
1277  1396  0 
… 
… 

1288  1407  def num_verts(self): 
1289  1408  """ 
1290  1409  The number of vertices in self 
1291   
1292   DOCTEST: 
 1410  
 1411  TESTS:: 
 1412  
1293  1413  sage: G = sage.graphs.base.graph_backends.NetworkXGraphBackend() 
1294  1414  sage: G.num_verts() 
1295  1415  0 
… 
… 

1304  1424  def relabel(self, perm, directed): 
1305  1425  """ 
1306  1426  Relabel the vertices of self by a permutation. 
 1427  
1307  1428  INPUT: 
1308   perm: permutation 
1309   directed: boolean 
1310   
1311   DOCTEST: 
 1429  
 1430   ``perm``  permutation 
 1431   ``directed``  boolean 
 1432  
 1433  TESTS:: 
 1434  
1312  1435  sage: G = sage.graphs.base.graph_backends.NetworkXGraphBackend() 
1313  1436  sage: G.relabel([],False) 
1314  1437  """ 
… 
… 

1356  1479  def set_edge_label(self, u, v, l, directed): 
1357  1480  """ 
1358  1481  Label the edge (u,v) by l. 
1359   
 1482  
1360  1483  INPUT: 
1361   u,v: vertices 
1362   l: edge label 
1363   directed: boolean 
1364   
1365   DOCTEST: 
 1484  
 1485   ``u,v``  vertices 
 1486   ``l``  edge label 
 1487   ``directed``  boolean 
 1488  
 1489  TESTS:: 
 1490  
1366  1491  sage: G = sage.graphs.base.graph_backends.NetworkXGraphBackend() 
1367  1492  sage: G.set_edge_label(1,2,'a',True) 
1368  1493  """ 