Statistics
| Branch: | Revision:

iof-tools / networkxMiCe / networkx-master / networkx / algorithms / tests / test_triads.py @ 5cef0f13

History | View | Annotate | Download (905 Bytes)

1
# test_triads.py - unit tests for the triads module
2
#
3
# Copyright 2015 NetworkX developers.
4
# Copyright 2009 Diederik van Liere <diederik.vanliere@rotman.utoronto.ca>.
5
#
6
# This file is part of NetworkX.
7
#
8
# NetworkX is distributed under a BSD license; see LICENSE.txt for more
9
# information.
10
"""Unit tests for the :mod:`networkx.algorithms.triads` module."""
11
from nose.tools import assert_equal
12

    
13
import networkx as nx
14

    
15

    
16
def test_triadic_census():
17
    """Tests the triadic census function."""
18
    G = nx.DiGraph()
19
    G.add_edges_from(['01', '02', '03', '04', '05', '12', '16', '51', '56',
20
                      '65'])
21
    expected = {'030T': 2, '120C': 1, '210': 0, '120U': 0, '012': 9, '102': 3,
22
                '021U': 0, '111U': 0, '003': 8, '030C': 0, '021D': 9, '201': 0,
23
                '111D': 1, '300': 0, '120D': 0, '021C': 2}
24
    actual = nx.triadic_census(G)
25
    assert_equal(expected, actual)