Returns the largest possible clique for the node with given id.
(graph, id)
| 1008 | return graph.density == 1.0 |
| 1009 | |
| 1010 | def clique(graph, id): |
| 1011 | """ Returns the largest possible clique for the node with given id. |
| 1012 | """ |
| 1013 | if isinstance(id, Node): |
| 1014 | id = id.id |
| 1015 | a = [id] |
| 1016 | for n in graph.nodes: |
| 1017 | try: |
| 1018 | # Raises StopIteration if all nodes in the clique are connected to n: |
| 1019 | (id for id in a if n.id==id or graph.edge(n.id, id) is None).next() |
| 1020 | except StopIteration: |
| 1021 | a.append(n.id) |
| 1022 | return a |
| 1023 | |
| 1024 | def cliques(graph, threshold=3): |
| 1025 | """ Returns all cliques in the graph with at least the given number of nodes. |