def _connected_chordal_graph_cliques(G):
 if (G.number_of_nodes() == 1):
  x = frozenset(G.nodes())
  return set([x])
 else:
  cliques = set()
  unnumbered = set(G.nodes())
  v = random.choice(list(unnumbered))
  unnumbered.remove(v)
  numbered = set([v])
  clique_wanna_be = set([v])
  while unnumbered:
   v = _max_cardinality_node(G, unnumbered, numbered)
   unnumbered.remove(v)
   numbered.add(v)
   new_clique_wanna_be = (set(G.neighbors(v)) & numbered)
   sg = G.subgraph(clique_wanna_be)
   if _is_complete_graph(sg):
    new_clique_wanna_be.add(v)
    if (not (new_clique_wanna_be >= clique_wanna_be)):
     cliques.add(frozenset(clique_wanna_be))
    clique_wanna_be = new_clique_wanna_be
   else:
    raise nx.NetworkXError('Input graph is not chordal.')
  cliques.add(frozenset(clique_wanna_be))
  return cliques

def _connected_chordal_graph_cliques ( G ) : if ( G . number_of_nodes ( ) == 1 ) : x = frozenset ( G . nodes ( ) ) return set ( [ x ] ) else : cliques = set ( ) unnumbered = set ( G . nodes ( ) ) v = random . choice ( list ( unnumbered ) ) unnumbered . remove ( v ) numbered = set ( [ v ] ) clique_wanna_be = set ( [ v ] ) while unnumbered : v = _max_cardinality_node ( G , unnumbered , numbered ) unnumbered . remove ( v ) numbered . add ( v ) new_clique_wanna_be = ( set ( G . neighbors ( v ) ) & numbered ) sg = G . subgraph ( clique_wanna_be ) if _is_complete_graph ( sg ) : new_clique_wanna_be . add ( v ) if ( not ( new_clique_wanna_be >= clique_wanna_be ) ) : cliques . add ( frozenset ( clique_wanna_be ) ) clique_wanna_be = new_clique_wanna_be else : raise nx . NetworkXError ( 'Input graph is not chordal.' ) cliques . add ( frozenset ( clique_wanna_be ) ) return cliques
return the set of maximal cliques of a connected chordal graph .