ó žÃÒYc@sSdZddlZddlZddlmZdgZedƒdd„ƒZdS(s= Algorithm to find a maximal (not maximum) independent set. iÿÿÿÿN(tnot_implemented_fortmaximal_independent_settdirectedcCs3|s'ttjt|ƒƒgƒ}n t|ƒ}|j|ƒsXtjd|ƒ‚ntjg|D]}t|j|ƒ^qeŒ}tj ||ƒr¯tjd|ƒ‚nt|ƒ}t|j ƒƒj |j|ƒƒ}xM|r.tjt|ƒƒ}|j |ƒ|j t|j|ƒ|gƒqâW|S(sReturn a random maximal independent set guaranteed to contain a given set of nodes. An independent set is a set of nodes such that the subgraph of G induced by these nodes contains no edges. A maximal independent set is an independent set such that it is not possible to add a new node and still get an independent set. Parameters ---------- G : NetworkX graph nodes : list or iterable Nodes that must be part of the independent set. This set of nodes must be independent. Returns ------- indep_nodes : list List of nodes that are part of a maximal independent set. Raises ------ NetworkXUnfeasible If the nodes in the provided list are not part of the graph or do not form an independent set, an exception is raised. NetworkXNotImplemented If `G` is directed. Examples -------- >>> G = nx.path_graph(5) >>> nx.maximal_independent_set(G) # doctest: +SKIP [4, 0, 2] >>> nx.maximal_independent_set(G, [1]) # doctest: +SKIP [1, 3] Notes ----- This algorithm does not solve the maximum independent set problem. s$%s is not a subset of the nodes of Gs!%s is not an independent set of G(tsettrandomtchoicetlisttissubsettnxtNetworkXUnfeasibletuniontadjt intersectiontnodest differencetappendtdifference_update(tGR tvt neighborst indep_nodestavailable_nodestnode((sm/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/networkx/networkx/algorithms/mis.pyRs"-! / $  %( t__doc__RtnetworkxRtnetworkx.utilsRt__all__tNoneR(((sm/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/networkx/networkx/algorithms/mis.pyts