'Tests that a callable weight is interpreted as a weight
function instead of an edge attribute.'

def test_weight_function(self):

    G = nx.complete_graph(3)
    G.adj[0][2]['weight'] = 10
    G.adj[0][1]['weight'] = 1
    G.adj[1][2]['weight'] = 1
    weight = (lambda u, v, d: (1 / d['weight']))
    (distance, path) = nx.single_source_dijkstra(G, 0, 2)
    assert_equal(distance, 2)
    assert_equal(path, [0, 1, 2])
    (distance, path) = nx.single_source_dijkstra(G, 0, 2, weight=weight)
    assert_equal(distance, (1 / 10))
    assert_equal(path, [0, 2])
