forked from networkx/networkx
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'get-all-cliques' of git://github.com/waltherg/networkx …
…into get-all-cliques
- Loading branch information
Showing
2 changed files
with
180 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#!/usr/bin/env python | ||
|
||
"""Cliques | ||
======= | ||
""" | ||
|
||
from nose.tools import * | ||
from networkx import * | ||
from networkx.algorithms.clique import get_all_cliques | ||
|
||
class TestCliques(): | ||
def test_paper_figure_4(self): | ||
# Same graph as given in Fig. 4 of paper get_all_cliques is | ||
# based on. | ||
# http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=1559964&isnumber=33129 | ||
G = Graph() | ||
edges_fig_4 = [('a','b'),('a','c'),('a','d'),('a','e'), | ||
('b','c'),('b','d'),('b','e'), | ||
('c','d'),('c','e'), | ||
('d','e'), | ||
('f','b'),('f','c'),('f','g'), | ||
('g','f'),('g','c'),('g','d'),('g','e')] | ||
G.add_edges_from(edges_fig_4) | ||
|
||
cliques = list(get_all_cliques(G)) | ||
expected_cliques = [['a'], | ||
['b'], | ||
['c'], | ||
['d'], | ||
['e'], | ||
['f'], | ||
['g'], | ||
['a', 'b'], | ||
['a', 'b', 'd'], | ||
['a', 'b', 'd', 'e'], | ||
['a', 'b', 'e'], | ||
['a', 'c'], | ||
['a', 'c', 'd'], | ||
['a', 'c', 'd', 'e'], | ||
['a', 'c', 'e'], | ||
['a', 'd'], | ||
['a', 'd', 'e'], | ||
['a', 'e'], | ||
['b', 'c'], | ||
['b', 'c', 'd'], | ||
['b', 'c', 'd', 'e'], | ||
['b', 'c', 'e'], | ||
['b', 'c', 'f'], | ||
['b', 'd'], | ||
['b', 'd', 'e'], | ||
['b', 'e'], | ||
['b', 'f'], | ||
['c', 'd'], | ||
['c', 'd', 'e'], | ||
['c', 'd', 'e', 'g'], | ||
['c', 'd', 'g'], | ||
['c', 'e'], | ||
['c', 'e', 'g'], | ||
['c', 'f'], | ||
['c', 'f', 'g'], | ||
['c', 'g'], | ||
['d', 'e'], | ||
['d', 'e', 'g'], | ||
['d', 'g'], | ||
['e', 'g'], | ||
['f', 'g'], | ||
['a', 'b', 'c', 'd'], | ||
['a', 'b', 'c', 'd', 'e'], | ||
['a', 'b', 'c', 'e']] | ||
|
||
assert_equal(cliques, expected_cliques) |