I'm working on a project wherein I need to dynamically refresh my graph
layout, getting a image for each step of the layout refresh. The problem
is: I can't get the continuity of frames we see in this
http://graph-tool.skewed.de/static/doc/demos/animation.html#dynamic-layout.
My video seems more like a
stopmotion: http://www.mediafire.com/watch/4de67mc7nanu2ox/output4.avi
This problem seems to arise from 2 facts: 1) the way I'm refreshing the
graph - since I'm simply generating another graph (which is not a bigger
problem because the model I'm using is deterministic); 2) max_iter = 2,
instead of 1. But EVEN when I set it to 1, I get no continuity from one
frame to another.
I think it will be useful some parts of the algorithm I'm using, but I
don't know how comprehensible it is:
#main function: makes graphs and save them as images; also save some useful
> data
> def graph(a, b, BIN):
> global prop, init_foot, ibin, fbin
> b=0
> while BIN > fbin:
> print 'while'
> foot = (init_foot)*(10**a)
> BIN = ibin - foot*b
> g.clear_edges()
> for i in g.vertices():
> xj = abs(prop[i])+abs((BIN-1)*dP)
> match = gt.find_vertex_range(g,prop,(abs(prop[i]+0.0000000001),
> xj))
> val = np.array([g.vertex_index[i], len(match), prop[i], BIN])
> exv.append(val)
> for j in xrange(0,len(match)):
> e = g.add_edge(g.vertex_index[i], match[j])
> Rij = (dP - abs(prop[i] - prop[match[j]]))/dP
> R[e] = Rij
>
> posa = g.vp['pos']
> pos = gt.sfdp_layout(g, pos=posa, max_iter=2)
> gt.graph_draw(g, pos=pos,
> vertex_fill_color=Mag,vertex_size=prop_to_size(Mass, mi=3, ma=9.5,
> log=False, power=6), fit_view=True, output = '%03d.png' % b)
> #some data I`ll need for analysis
> comp, hist = gt.label_components(g, directed=False)
> compo = len(set(comp.a))
> components.append(compo)
> bins.append(BIN)
> numed.append(g.num_edges())
> print g.num_edges(), compo, BIN
> diam1, end = gt.pseudo_diameter(g)
> diam.append(diam1)
> gg = g.copy()
> graphs.append(gg)
> deg = g.degree_property_map('out', weight=None)
> degree.append(deg.a)
> lclstr = gt.local_clustering(g, undirected=True)
> gclstr = gt.global_clustering(g)
> lclust.append(lclstr.a)
> gclust.append(gclstr)
> #the cases the images start to get too big to compute efficiently
> if b > 1 and components[b] < 350:
> a += 0.1
> if b > 1 and components[b] < 150:
> a += 0.3
>
> #pace
> b+=1
> #pace variation
> a +=0.1
>
return components, bins, exv, graphs
_______________________________________________
graph-tool mailing list
[email protected]
http://lists.skewed.de/mailman/listinfo/graph-tool