MCPcopy Index your code
hub / github.com/Persper/code-analytics / test_devrank

Function test_devrank

test/test_analytics/test_devrank.py:5–25  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3
4
5def 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)

Callers

nothing calls this directly

Calls 3

devrankFunction · 0.90
add_nodeMethod · 0.80
add_edgeMethod · 0.80

Tested by

no test coverage detected