# Ticket #6823: knesergraph.patch

File knesergraph.patch, 1.8 KB (added by ncohen, 11 years ago)
• ## sage/graphs/graph_generators.py

`diff -r 684eea91ff22 -r 4b6ebc7decf3 sage/graphs/graph_generators.py`
 a - FruchtGraph - HeawoodGraph - HoffmanSingletonGraph - KneserGraph - MoebiusKantorGraph - Pappus Graph - PetersenGraph - FruchtGraph - HeawoodGraph - HoffmanSingletonGraph - KneserGraph - MoebiusKantorGraph - PappusGraph - PetersenGraph pos_dict[map[D[i]]] = [x,y] H.set_pos(pos_dict) return H def KneserGraph(self,n,k): r""" Returns the Kneser Graph of parameters `n, k`. The Kneser Graph of parameters `n,k` is the graph whose vertices are the `k`-subsets of `[0,1,\dots,n-1]`, and such that two vertices are linked if their corresponding sets are disjoint. For example, the Petersen Graph can be defined as the Kneser Graph of parameters `5,2`. EXAMPLE:: sage: KG=graphs.KneserGraph(5,2) sage: P=graphs.PetersenGraph() sage: P.is_isomorphic(KG) True """ g=graph.Graph() from sage.combinat.subset import Subsets if k>n/2: g.add_vertices(Subsets(n,k).list()) S=Subsets(Subsets(n,k),2) l=lambda x:list(x) [g.add_edge(s,t) for [s,t] in map(l,S) if s.intersection(t).cardinality() ==0 ] return g def MoebiusKantorGraph(self): """