# HG changeset patch
# User Nathann Cohen <nathann.cohen@gmail.com>
# Date 1261055001 3600
# Node ID 01a94a133140b387dc49572aed256353c1f5a486
# Parent 964c2f4ce74db0417a771de0b0cfc951b1fab73c
Circuit digraph
diff r 964c2f4ce74d r 01a94a133140 sage/graphs/graph_generators.py
a

b


48  48   CircularLadderGraph 
49  49   ClawGraph 
50  50   CycleGraph 
 51   Circuit 
51  52   DiamondGraph 
52  53   EmptyGraph 
53  54   Grid2dGraph 
… 
… 

186  187   CircularLadderGraph 
187  188   ClawGraph 
188  189   CycleGraph 
 190   Circuit 
189  191   DiamondGraph 
190  192   EmptyGraph 
191  193   Grid2dGraph 
… 
… 

4157  4159  raise NotImplementedError, "vertices must be 'strings' or 'vectors'." 
4158  4160  return graph.DiGraph(butterfly) 
4159  4161  
 4162  def Circuit(self,n): 
 4163  r""" 
 4164  Returns the circuit on `n` vertices 
 4165  
 4166  The circuit is an oriented ``CycleGraph`` 
 4167  
 4168  EXAMPLE: 
 4169  
 4170  A circuit is the smallest strongly connected digraph:: 
 4171  
 4172  sage: circuit = digraphs.Circuit(15) 
 4173  sage: len(circuit.strongly_connected_components()) == 1 
 4174  True 
 4175  """ 
 4176  if n<0: 
 4177  raise ValueError("The number of vertices must be a positive integer.") 
 4178  
 4179  from sage.graphs.graph import DiGraph 
 4180  g = DiGraph() 
 4181  g.name("Circuit on "+str(n)+" vertices") 
 4182  
 4183  if n==0: 
 4184  return g 
 4185  elif n == 1: 
 4186  g.allow_loops(True) 
 4187  g.add_edge(0,0) 
 4188  return g 
 4189  else: 
 4190  g.add_edges([(i,i+1) for i in xrange(n1)]) 
 4191  g.add_edge(n1,0) 
 4192  return g 
 4193  
4160  4194  def DeBruijn(self,n,k): 
4161  4195  r""" 
4162  4196  Returns the De Bruijn diraph with parameters `n,k`. 