# HG changeset patch
# User Nathann Cohen <nathann.cohen@gmail.com>
# Date 1325325171 -3600
# Node ID 7e017ea0b32012ed8b905f6b07da523964757185
# Parent  15bea0f2b6de3555b7c35d84812d13567e37d869
trac 12134 -- is_planar(set_pos=True) doesn't work with small graphs -- Reviewer's patch

diff -r 15bea0f2b6de -r 7e017ea0b320 sage/graphs/planarity.pyx
--- a/sage/graphs/planarity.pyx	Sat Dec 31 03:25:19 2011 +0000
+++ b/sage/graphs/planarity.pyx	Sat Dec 31 10:52:51 2011 +0100
@@ -62,10 +62,17 @@
         sage: a == b # long time
         True
 
-    There were some problems with set_pos stability in the past,
-    so let's check if this this runs without exception:
+    There were some problems with ``set_pos`` stability in the past,
+    so let's check if this this runs without exception::
 
-        sage: c = [i for i in [1..1252] if atlas_graphs[i].is_connected() and atlas_graphs[i].is_planar(set_embedding=True, set_pos=True)] # long time
+        sage: for i,g in enumerate(atlas_graphs):                         # long time
+        ...       if (not g.is_connected() or i==0):                      # long time
+        ...           continue                                            # long time
+        ...       try:                                                    # long time
+        ...           _ = g.is_planar(set_embedding=True, set_pos=True)   # long time
+        ...       except:                                                 # long time
+        ...           print "There is something wrong here !"             # long time
+        ...           break                                               # long time
     """
     if set_pos and not g.is_connected():
         raise ValueError("is_planar() cannot set vertex positions for a disconnected graph")
@@ -76,10 +83,11 @@
             g._embedding = dict((v, []) for v in g.vertices())
         return (True, None) if kuratowski else True
     if len(g) == 2 and g.is_connected(): # P_2 is too small to be triangulated
+        u,v = g.vertices()
         if set_embedding:
-            g._embedding = { g.vertices()[0]: [g.vertices()[1]], g.vertices()[1]: [g.vertices()[0]] }
+            g._embedding = { u: [v], v: [u] }
         if set_pos:
-            g._pos = { g.vertices()[0]: [0,0], g.vertices()[1]: [0,1] }
+            g._pos = { u: [0,0], v: [0,1] }
         return (True, None) if kuratowski else True
 
     # create to and from mappings to relabel vertices to the set {0,...,n-1}
diff -r 15bea0f2b6de -r 7e017ea0b320 sage/graphs/schnyder.py
--- a/sage/graphs/schnyder.py	Sat Dec 31 03:25:19 2011 +0000
+++ b/sage/graphs/schnyder.py	Sat Dec 31 10:52:51 2011 +0100
@@ -63,7 +63,7 @@
     """
     # first make sure that the graph has at least 3 vertices, and that it is connected
     if g.order() < 3:
-        raise ValueError("Graph with less than 3 vertices doesn't have any triangulation.")
+        raise ValueError("A Graph with less than 3 vertices doesn't have any triangulation.")
     if g.is_connected() == False:
         raise NotImplementedError("_triangulate() only knows how to handle connected graphs.")
 
