# HG changeset patch
# User Diego de Estrada <destrada@dc.uba.ar>
# Date 1315670488 -7200
# Node ID 24cf1fbceb61c3d63334c14008f1e6b7aa502a96
# Parent  6d083e3d29a3ee52e0e72ebe4964a3cf87a84b99
trac #11738 - Various issues in is_interval and is_chordal

diff -r 6d083e3d29a3 -r 24cf1fbceb61 sage/graphs/generic_graph.py
--- a/sage/graphs/generic_graph.py	Wed Aug 17 16:07:36 2011 +0000
+++ b/sage/graphs/generic_graph.py	Sat Sep 10 18:01:28 2011 +0200
@@ -9467,7 +9467,7 @@
 
                     b, certif = gg.is_chordal(certificate = True)
                     if not b:
-                        return certif
+                        return False, certif
                     else:
                         peo.extend(certif)
                     
@@ -9482,34 +9482,32 @@
         g = self.copy()
         peo.reverse()
     
-        # Remembering the (closed) neighborhoods of each vertex
-        from sage.combinat.subset import Subsets
-        neighbors_subsets = dict([(v,Subsets(self.neighbors(v)+[v])) for v in self.vertex_iterator()])
-    
         # Iteratively removing vertices and checking everything is fine.
         for v in peo:
 
-            if t_peo.out_degree(v)>0 and g.neighbors(v) not in neighbors_subsets[t_peo.neighbor_out_iterator(v).next()]:
-
-                if certificate:
-
-                    # In this case, let us take two nonadjacent neighbors of v
-
-                    x = t_peo.neighbor_out_iterator(v).next()
-                    S = neighbors_subsets[x]
-
-                    for y in g.neighbors(v):
-                        if [y] not in S:
-                            break
-
-                    g.delete_vertex(v)
-
-                    # Our hole is v + (a shortest path between x and y
-                    # not containing v)
-
-                    return (False, self.subgraph([v] + g.shortest_path(x,y)))
-                else:
-                    return False
+            if t_peo.out_degree(v)>0:
+
+                x = t_peo.neighbor_out_iterator(v).next()
+                S = self.neighbors(x)+[x]
+
+                if not frozenset(g.neighbors(v)).issubset(S): 
+
+                    if certificate:
+
+                        # In this case, let us take two nonadjacent neighbors of v
+
+                        for y in g.neighbors(v):
+                            if y not in S:
+                                break
+
+                        g.delete_vertex(v)
+
+                        # Our hole is v + (a shortest path between x and y
+                        # not containing v)
+
+                        return (False, self.subgraph([v] + g.shortest_path(x,y)))
+                    else:
+                        return False
 
             g.delete_vertex(v)
 
@@ -9590,14 +9588,10 @@
         if not self.is_chordal():
             return False
 
-        from sage.sets.set import Set
-        from sage.combinat.subset import Subsets
-
         # First, we need to gather the list of maximal cliques, which
         # is easy as the graph is chordal
 
         cliques = []
-        clique_subsets = []
 
         # As we will be deleting vertices ...
         g = self.copy()
@@ -9616,13 +9610,11 @@
 
             while peo:
                 v = peo.pop()
-                clique = Set( [v] + cc.neighbors(v))
+                clique = frozenset( [v] + cc.neighbors(v))
                 cc.delete_vertex(v)
 
-                if not any([clique in cs for cs in clique_subsets]):
+                if not any([clique.issubset(c) for c in cliques]):
                     cliques.append(clique)
-                    clique_subsets.append(Subsets(clique))
-
 
         from sage.graphs.pq_trees import reorder_sets
 
