~ubuntu-branches/ubuntu/utopic/python-networkx/utopic

« back to all changes in this revision

Viewing changes to networkx/algorithms/tests/test_block.py

  • Committer: Package Import Robot
  • Author(s): Sandro Tosi
  • Date: 2012-08-11 12:41:30 UTC
  • mfrom: (1.4.1) (5.1.13 sid)
  • Revision ID: package-import@ubuntu.com-20120811124130-whr6uso7fncyg8bi
Tags: 1.7-1
* New upstream release
* debian/patches/changeset_*
  - removed, included upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
            assert_equal(M.node[n]['nnodes'],2)
16
16
            assert_equal(M.node[n]['density'],1.0)
17
17
 
 
18
    def test_multigraph_path(self):
 
19
        G=networkx.MultiGraph(networkx.path_graph(6))
 
20
        partition=[[0,1],[2,3],[4,5]]
 
21
        M=networkx.blockmodel(G,partition,multigraph=True)
 
22
        assert_equal(sorted(M.nodes()),[0,1,2])
 
23
        assert_equal(sorted(M.edges()),[(0,1),(1,2)])
 
24
        for n in M.nodes():
 
25
            assert_equal(M.node[n]['nedges'],1)
 
26
            assert_equal(M.node[n]['nnodes'],2)
 
27
            assert_equal(M.node[n]['density'],1.0)
 
28
 
 
29
    def test_directed_path(self):
 
30
        G = networkx.DiGraph()
 
31
        G.add_path(list(range(6)))
 
32
        partition=[[0,1],[2,3],[4,5]]
 
33
        M=networkx.blockmodel(G,partition)
 
34
        assert_equal(sorted(M.nodes()),[0,1,2])
 
35
        assert_equal(sorted(M.edges()),[(0,1),(1,2)])
 
36
        for n in M.nodes():
 
37
            assert_equal(M.node[n]['nedges'],1)
 
38
            assert_equal(M.node[n]['nnodes'],2)
 
39
            assert_equal(M.node[n]['density'],0.5)
 
40
 
 
41
    def test_directed_multigraph_path(self):
 
42
        G = networkx.MultiDiGraph()
 
43
        G.add_path(list(range(6)))
 
44
        partition=[[0,1],[2,3],[4,5]]
 
45
        M=networkx.blockmodel(G,partition,multigraph=True)
 
46
        assert_equal(sorted(M.nodes()),[0,1,2])
 
47
        assert_equal(sorted(M.edges()),[(0,1),(1,2)])
 
48
        for n in M.nodes():
 
49
            assert_equal(M.node[n]['nedges'],1)
 
50
            assert_equal(M.node[n]['nnodes'],2)
 
51
            assert_equal(M.node[n]['density'],0.5)
 
52
 
 
53
    @raises(networkx.NetworkXException)
 
54
    def test_overlapping(self):
 
55
        G=networkx.path_graph(6)
 
56
        partition=[[0,1,2],[2,3],[4,5]]
 
57
        M=networkx.blockmodel(G,partition)
 
58
 
18
59
    def test_weighted_path(self):
19
60
        G=networkx.path_graph(6)
20
61
        G[0][1]['weight']=1