# HG changeset patch
# User Nathann Cohen <nathann.cohen@gmail.com>
# Date 1356732030 3600
# Node ID ac63e3e49a67771c4295a891ef0a6bc5c15151bd
# Parent 36fba6c1a13fc3695bb19fb25ea69222f024a5b0
A constructor for folded cube graphs
diff git a/sage/graphs/generators/families.py b/sage/graphs/generators/families.py
a

b


349  349  
350  350  return g 
351  351  
352   
353   ########################################################################### 
354   # Families of Graphs 
355   ########################################################################### 
356   
357  352  def BalancedTree(r, h): 
358  353  r""" 
359  354  Returns the perfectly balanced tree of height `h \geq 1`, 
… 
… 

713  708  
714  709  return r 
715  710  
 711  def FoldedCubeGraph(n): 
 712  r""" 
 713  Returns the folded cube graph of order `2^{n1}`. 
 714  
 715  The folded cube graph on `2^{n1}` vertices can be obtained from a cube 
 716  graph on `2^n` vertices by merging together opposed 
 717  vertices. Alternatively, it can be obtained from a cube graph on 
 718  `2^{n1}` vertices by adding an edge between opposed vertices. This 
 719  second construction is the one produced by this method. 
 720  
 721  For more information on folded cube graphs, see the corresponding 
 722  :wikipedia:`Wikipedia page <Folded_cube_graph>`. 
 723  
 724  EXAMPLES: 
 725  
 726  The folded cube graph of order five is the Clebsch graph:: 
 727  
 728  sage: fc = graphs.FoldedCubeGraph(5) 
 729  sage: clebsch = graphs.ClebschGraph() 
 730  sage: fc.is_isomorphic(clebsch) 
 731  True 
 732  """ 
 733  
 734  if n < 1: 
 735  raise ValueError("The value of n must be at least 2") 
 736  
 737  g = CubeGraph(n1) 
 738  g.name("Folded Cube Graph") 
 739  
 740  # Complementing the binary word 
 741  def complement(x): 
 742  x = x.replace('0','a') 
 743  x = x.replace('1','0') 
 744  x = x.replace('a','1') 
 745  return x 
 746  
 747  for x in g: 
 748  if x[0] == '0': 
 749  g.add_edge(x,complement(x)) 
 750  
 751  return g 
 752  
 753  
716  754  def FriendshipGraph(n): 
717  755  r""" 
718  756  Returns the friendship graph `F_n`. 
diff git a/sage/graphs/graph_generators.py b/sage/graphs/graph_generators.py
a

b


145  145  "CirculantGraph", 
146  146  "CubeGraph", 
147  147  "FibonacciTree", 
 148  "FoldedCubeGraph", 
148  149  "FriendshipGraph", 
149  150  "FuzzyBallGraph", 
150  151  "GeneralizedPetersenGraph", 
… 
… 

911  912  BubbleSortGraph = staticmethod(sage.graphs.generators.families.BubbleSortGraph) 
912  913  CirculantGraph = staticmethod(sage.graphs.generators.families.CirculantGraph) 
913  914  CubeGraph = staticmethod(sage.graphs.generators.families.CubeGraph) 
 915  FoldedCubeGraph = staticmethod(sage.graphs.generators.families.FoldedCubeGraph) 
914  916  DorogovtsevGoltsevMendesGraph = staticmethod(sage.graphs.generators.families.DorogovtsevGoltsevMendesGraph) 
915  917  FriendshipGraph = staticmethod(sage.graphs.generators.families.FriendshipGraph) 
916  918  FuzzyBallGraph = staticmethod(sage.graphs.generators.families.FuzzyBallGraph) 