Python networkx.graph_number_of_cliques() Examples

The following are 3 code examples of networkx.graph_number_of_cliques(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module networkx , or try the search function .
Example #1
Source File: test_clique.py    From qgisSpaceSyntaxToolkit with GNU General Public License v3.0 6 votes vote down vote up
def test_number_of_cliques(self):
        G = self.G
        assert_equal(nx.graph_number_of_cliques(G), 5)
        assert_equal(nx.graph_number_of_cliques(G, cliques=self.cl), 5)
        assert_equal(nx.number_of_cliques(G, 1), 1)
        assert_equal(list(nx.number_of_cliques(G, [1]).values()), [1])
        assert_equal(list(nx.number_of_cliques(G, [1, 2]).values()), [1, 2])
        assert_equal(nx.number_of_cliques(G, [1, 2]), {1: 1, 2: 2})
        assert_equal(nx.number_of_cliques(G, 2), 2)
        assert_equal(nx.number_of_cliques(G),
                     {1: 1, 2: 2, 3: 1, 4: 2, 5: 1,
                      6: 2, 7: 1, 8: 1, 9: 1, 10: 1, 11: 1})
        assert_equal(nx.number_of_cliques(G, nodes=G.nodes()),
                     {1: 1, 2: 2, 3: 1, 4: 2, 5: 1,
                      6: 2, 7: 1, 8: 1, 9: 1, 10: 1, 11: 1})
        assert_equal(nx.number_of_cliques(G, nodes=[2, 3, 4]),
                     {2: 2, 3: 1, 4: 2})
        assert_equal(nx.number_of_cliques(G, cliques=self.cl),
                     {1: 1, 2: 2, 3: 1, 4: 2, 5: 1,
                      6: 2, 7: 1, 8: 1, 9: 1, 10: 1, 11: 1})
        assert_equal(nx.number_of_cliques(G, G.nodes(), cliques=self.cl),
                     {1: 1, 2: 2, 3: 1, 4: 2, 5: 1,
                      6: 2, 7: 1, 8: 1, 9: 1, 10: 1, 11: 1}) 
Example #2
Source File: test_clique.py    From Carnets with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def test_number_of_cliques(self):
        G = self.G
        assert_equal(nx.graph_number_of_cliques(G), 5)
        assert_equal(nx.graph_number_of_cliques(G, cliques=self.cl), 5)
        assert_equal(nx.number_of_cliques(G, 1), 1)
        assert_equal(list(nx.number_of_cliques(G, [1]).values()), [1])
        assert_equal(list(nx.number_of_cliques(G, [1, 2]).values()), [1, 2])
        assert_equal(nx.number_of_cliques(G, [1, 2]), {1: 1, 2: 2})
        assert_equal(nx.number_of_cliques(G, 2), 2)
        assert_equal(nx.number_of_cliques(G),
                     {1: 1, 2: 2, 3: 1, 4: 2, 5: 1,
                      6: 2, 7: 1, 8: 1, 9: 1, 10: 1, 11: 1})
        assert_equal(nx.number_of_cliques(G, nodes=list(G)),
                     {1: 1, 2: 2, 3: 1, 4: 2, 5: 1,
                      6: 2, 7: 1, 8: 1, 9: 1, 10: 1, 11: 1})
        assert_equal(nx.number_of_cliques(G, nodes=[2, 3, 4]),
                     {2: 2, 3: 1, 4: 2})
        assert_equal(nx.number_of_cliques(G, cliques=self.cl),
                     {1: 1, 2: 2, 3: 1, 4: 2, 5: 1,
                      6: 2, 7: 1, 8: 1, 9: 1, 10: 1, 11: 1})
        assert_equal(nx.number_of_cliques(G, list(G), cliques=self.cl),
                     {1: 1, 2: 2, 3: 1, 4: 2, 5: 1,
                      6: 2, 7: 1, 8: 1, 9: 1, 10: 1, 11: 1}) 
Example #3
Source File: test_clique.py    From aws-kube-codesuite with Apache License 2.0 6 votes vote down vote up
def test_number_of_cliques(self):
        G = self.G
        assert_equal(nx.graph_number_of_cliques(G), 5)
        assert_equal(nx.graph_number_of_cliques(G, cliques=self.cl), 5)
        assert_equal(nx.number_of_cliques(G, 1), 1)
        assert_equal(list(nx.number_of_cliques(G, [1]).values()), [1])
        assert_equal(list(nx.number_of_cliques(G, [1, 2]).values()), [1, 2])
        assert_equal(nx.number_of_cliques(G, [1, 2]), {1: 1, 2: 2})
        assert_equal(nx.number_of_cliques(G, 2), 2)
        assert_equal(nx.number_of_cliques(G),
                     {1: 1, 2: 2, 3: 1, 4: 2, 5: 1,
                      6: 2, 7: 1, 8: 1, 9: 1, 10: 1, 11: 1})
        assert_equal(nx.number_of_cliques(G, nodes=list(G)),
                     {1: 1, 2: 2, 3: 1, 4: 2, 5: 1,
                      6: 2, 7: 1, 8: 1, 9: 1, 10: 1, 11: 1})
        assert_equal(nx.number_of_cliques(G, nodes=[2, 3, 4]),
                     {2: 2, 3: 1, 4: 2})
        assert_equal(nx.number_of_cliques(G, cliques=self.cl),
                     {1: 1, 2: 2, 3: 1, 4: 2, 5: 1,
                      6: 2, 7: 1, 8: 1, 9: 1, 10: 1, 11: 1})
        assert_equal(nx.number_of_cliques(G, list(G), cliques=self.cl),
                     {1: 1, 2: 2, 3: 1, 4: 2, 5: 1,
                      6: 2, 7: 1, 8: 1, 9: 1, 10: 1, 11: 1})