Dear Graph-Tool Community,
I am trying to use a customised version of the animation script provided in the graph-tool cookbook where you can save iterated steps as frames to then convert to a short movie, as per the Dynamic Layout here: https://graph-tool.skewed.de/static/doc/demos/animation/animation.html
The script [below] seems to works with finite numbers of nodes, e.g. 1000. However, with larger numbers of nodes, all output frames look the same (?not iterating through properly).To scale up, I want to apply this to a graph with 20,000 nodes.
from graph_tool.all import *
from numpy.random import *
from numpy.linalg import norm
import sys, os, os.path
from gi.repository import GLib
import graph_tool.all as gt; import matplotlib; import math; import numpy;
from gi.repository import Gtk, Gdk, GdkPixbuf, GObject
g = random_graph(500, lambda: 1 + poisson(5), directed=False)
#step = 0.05 # move step
K = 0.5 # preferred edge length
pos = sfdp_layout(g, K=K, max_iter=1) # initial layout positions
offscreen = sys.argv == "offscreen" if len(sys.argv) > 1 else False
max_count = 50
if offscreen and not os.path.exists("./frames"):
if not offscreen:
win = GraphWindow(g, pos, geometry=(400, 400),bg_color=[0,0,0,1])
win = Gtk.OffscreenWindow()
win.graph = GraphWidget(g, pos)
count = 0
sfdp_layout(g, pos=pos, K=K, init_step=step, max_iter=1)
count += 1
# if doing an offscreen animation, dump frame to disk
pixbuf = win.get_pixbuf()
pixbuf.savev(r'./frames/dancing%06d.png' % count, 'png', , )
if count > max_count:
# Bind the function above as an 'idle' callback.
cid = GLib.idle_add(update_state)
# We will give the user the ability to stop the program by closing the window.
# Actually show the window, and start the main loop.
I have tried modifying step, in addition to the number of iterations and k, but have had no success.
Does anyone have advice how to get it working for large numbers of nodes - i.e. 20,000…?
attachment.html (4.9 KB)