# Ticket #904: clique_ind_set.patch

File clique_ind_set.patch, 1.9 KB (added by jason, 12 years ago)
• ## sage/graphs/graph.py

`diff -r 615b8e8fde7f sage/graphs/graph.py`
 a class Graph(GenericGraph): return networkx.generators.bipartite.is_bipartite(self._nxg) ### Substructures def is_clique(self, vertices=None): """ Returns True if the set \code{vertices} is a clique, False if not.  A clique is a set of vertices such that there is an edge between any two vertices. INPUT: vertices -- Vertices can be a single vertex or an iterable container of vertices, e.g. a list, set, graph, file or numeric array.  If not passed, defaults to the entire graph. EXAMPLE: sage: graphs.CompleteGraph(4).is_clique([1,2,3]) True sage: graphs.CycleGraph(4).is_clique([1,2]) True sage: graphs.CycleGraph(4).is_clique([1,2,3]) False """ subgraph=self.subgraph(vertices).to_simple() n=subgraph.order() return subgraph.size()==n*(n-1)/2 def is_independent_set(self, vertices=None): """ Returns True if the set \code{vertices} is an independent set, False if not.  An independent set is a set of vertices such that there is no edge between any two vertices. INPUT: vertices -- Vertices can be a single vertex or an iterable container of vertices, e.g. a list, set, graph, file or numeric array.  If not passed, defaults to the entire graph. EXAMPLE: sage: graphs.CycleGraph(4).is_independent_set([1,3]) True sage: graphs.CycleGraph(4).is_independent_set([1,2,3]) False """ return self.subgraph(vertices).to_simple().size()==0 ### Automorphism and isomorphism