Statistics
| Branch: | Revision:

iof-tools / networkxMiCe / networkx-master / networkx / generators / tests / test_random_clustered.py @ 5cef0f13

History | View | Annotate | Download (973 Bytes)

1
#!/usr/bin/env python
2
from nose.tools import *
3
import networkx
4

    
5

    
6
class TestRandomClusteredGraph:
7

    
8
    def test_valid(self):
9
        node = [1, 1, 1, 2, 1, 2, 0, 0]
10
        tri = [0, 0, 0, 0, 0, 1, 1, 1]
11
        joint_degree_sequence = zip(node, tri)
12
        G = networkx.random_clustered_graph(joint_degree_sequence)
13
        assert_equal(G.number_of_nodes(), 8)
14
        assert_equal(G.number_of_edges(), 7)
15

    
16
    def test_valid2(self):
17
        G = networkx.random_clustered_graph(
18
            [(1, 2), (2, 1), (1, 1), (1, 1), (1, 1), (2, 0)])
19
        assert_equal(G.number_of_nodes(), 6)
20
        assert_equal(G.number_of_edges(), 10)
21

    
22
    def test_invalid1(self):
23
        assert_raises((TypeError, networkx.NetworkXError),
24
                      networkx.random_clustered_graph, [[1, 1], [2, 1], [0, 1]])
25

    
26
    def test_invalid2(self):
27
        assert_raises((TypeError, networkx.NetworkXError),
28
                      networkx.random_clustered_graph, [[1, 1], [1, 2], [0, 1]])