Mercurial > public > think_complexity
diff ch4ex4.py @ 26:f6073c187926
Added a version of Dijkstra that uses a heap.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sat, 05 Jan 2013 13:30:58 -0600 |
parents | a46783561538 |
children | 15ff31ecec7a |
line wrap: on
line diff
--- a/ch4ex4.py Sat Jan 05 13:00:07 2013 -0600 +++ b/ch4ex4.py Sat Jan 05 13:30:58 2013 -0600 @@ -11,7 +11,7 @@ from SmallWorldGraph import SmallWorldGraph # Use Dijkstra or Floyd-Warshall to compute L -DIJKSTRA = False +DIJKSTRA = True # compute C(0) n = 1000 @@ -19,7 +19,7 @@ vs = [Vertex(str(i)) for i in range(n)] g = SmallWorldGraph(vs, k, 0.0) c0 = g.clustering_coefficient() -l0 = g.big_l() if DIJKSTRA else g.big_l2() +l0 = g.big_l3() if DIJKSTRA else g.big_l2() print 'c0 =', c0, 'l0 =', l0 # compute data @@ -34,7 +34,7 @@ for p in p_vals: g = SmallWorldGraph(vs, k, p) c_vals.append(g.clustering_coefficient() / c0) - l = g.big_l() if DIJKSTRA else g.big_l2() + l = g.big_l3() if DIJKSTRA else g.big_l2() l_vals.append(l / l0) p_vals.insert(0, 0.0)