Beispiel #1
0
# set various constants 
dimension = 2
max_it = 500
temp = 1
# get number of nodes and an edgelist
nodes = len(g.vertices())
edgelist = np.array( [edge.tuple for edge in g.edges()], np.int32)

start = time.clock()
# place nodes initially uniformly at random in 
# [-sqrt(nodes)/2, +sqrt(nodes)/2]^2
pos = math.sqrt(nodes) * np.random.random_sample( (nodes, dimension) ) - math.sqrt(nodes)/2
pos = pos.astype( np.float32) )

# call fastlayout function
fl.layout_fr_omp_simd( edgelist, pos, max_it, temp )
fastlayout = time.clock()
fastlayout = fastlayout - start

# draw the graph in graph_tool
gt.graph_draw(g, pos=pos, output="output/price_network-fr-fastlayout.pdf")

# call and plot the reference implementation of graph-tool
start = time.clock()
reference = gt.fruchterman_reingold_layout(g, n_iter=1000)
reflayout = time.clock()
reflayout = reflayout - start
gt.graph_draw(g, pos=reference, output="output/price_network-fr-reference.pdf")

print "Time for fastlayout is: ", fastlayout
print "Time for reference implementaion in gt is: ", reflayout
Beispiel #2
0
print 'layout_fr_omp'
start = time.clock()
pos = fl.layout_fr_omp( nodes*dimension, edgelist, max_it, temp )
pos = np.reshape(pos, (nodes, dimension))
float2Layout = ig.Layout( tuple(map(tuple, pos)) )
elapsed = time.clock()
elapsed = elapsed - start
print "Time spent for fastlayout with OpenMP is: ", elapsed
ig.plot(g, "output/plot_fr_omp.png", layout=float2Layout)

print 'layout_fr_simd'
start = time.clock()
pos = fl.layout_fr_simd( nodes*dimension, edgelist, max_it, temp )
pos = np.reshape(pos, (nodes, dimension))
float3Layout = ig.Layout( tuple(map(tuple, pos)) )
elapsed = time.clock()
elapsed = elapsed - start
print "Time spent for fastlayout with vectorization is: ", elapsed
ig.plot(g, "output/plot_fr_simd.png", layout=float3Layout)

print 'layout_fr_omp_simd'
start = time.clock()
pos = fl.layout_fr_omp_simd( nodes*dimension, edgelist, max_it, temp )
pos = np.reshape( pos, (nodes, dimension) )
float6Layout = ig.Layout( tuple(map(tuple, pos)) )
elapsed = time.clock()
elapsed = elapsed - start
print "Time spent for fastlayout with OpenMP and vectorization is: ", elapsed
ig.plot(g, "output/plot_fr_omp_simd.png", layout=float6Layout)
Beispiel #3
0
floatLayout = ig.Layout( tuple(map(tuple, floatPos )) )
ig.plot(g, "output/plot_float_baseline.png", layout=floatLayout)

#print 'layout_fr_omp'
#fl.layout_fr_omp( edges, float2Pos, max_it, temp )
#float2Layout = ig.Layout( tuple(map(tuple, float2Pos)) )
#ig.plot(g, "output/plot_fr_omp.png", layout=float2Layout)

#print 'layout_fr_simd'
#fl.layout_fr_simd( edges, float3Pos, max_it, temp )
#float3Layout = ig.Layout( tuple(map(tuple, float3Pos)) )
#ig.plot(g, "output/plot_fr_simd.png", layout=float3Layout)

#print 'layout_fr_simd_1x4'
#fl.layout_fr_simd_1x4( edges, float4Pos, max_it, temp )
#float4Layout = ig.Layout( tuple(map(tuple, float4Pos)) )
#ig.plot(g, "output/plot_fr_simd_1x4.png", layout=float4Layout)

#print 'layout_fr_2x2'
#fl.layout_fr_2x2( edges, float5Pos, max_it, temp )
#float5Layout = ig.Layout( tuple(map(tuple, float5Pos)) )
#ig.plot(g, "output/plot_fr_2x2.png", layout=float5Layout)

print 'layout_fr_omp_simd'
fl.layout_fr_omp_simd( edges, float6Pos, max_it, temp )
float6Layout = ig.Layout( tuple(map(tuple, float6Pos)) )
ig.plot(g, "output/plot_fr_omp_simd.png", layout=float6Layout)

#print np.array_str( floatPos )
#print np.array_str( float2Pos )