MCPcopy Index your code
hub / github.com/clips/pattern / clique

Function clique

pattern/graph/__init__.py:1010–1022  ·  view source on GitHub ↗

Returns the largest possible clique for the node with given id.

(graph, id)

Source from the content-addressed store, hash-verified

1008 return graph.density == 1.0
1009
1010def 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
1024def cliques(graph, threshold=3):
1025 """ Returns all cliques in the graph with at least the given number of nodes.

Callers 1

cliquesFunction · 0.85

Calls 3

nextMethod · 0.45
edgeMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…