| 3 | |
| 4 | |
| 5 | def test_devrank(): |
| 6 | G = nx.DiGraph() |
| 7 | G.add_node(1, weight=10) |
| 8 | G.add_node(2, weight=10) |
| 9 | G.add_edge(1, 2) |
| 10 | G.add_edge(2, 1) |
| 11 | assert(devrank(G, 'weight') == {1: 0.5, 2: 0.5}) |
| 12 | |
| 13 | G2 = nx.DiGraph() |
| 14 | G2.add_edges_from([(1, 2), (2, 3), (3, 4), (4, 1)]) |
| 15 | for u in G2: |
| 16 | G2.node[u]['weight'] = 10 |
| 17 | assert(devrank(G2, 'weight') == {1: 0.25, 2: 0.25, 3: 0.25, 4: 0.25}) |
| 18 | |
| 19 | G3 = nx.DiGraph() |
| 20 | G3.add_edge(1, 2) |
| 21 | for u in G3: |
| 22 | G3.node[u]['weight'] = 10 |
| 23 | dr = devrank(G3, 'weight', alpha=1.0) |
| 24 | assert(abs(dr[1] - 0.3333) < 0.0001) |
| 25 | assert(abs(dr[2] - 0.6666) < 0.0001) |