MCPcopy Create free account
hub / github.com/easy-graph/Easy-Graph / simulate

Method simulate

easygraph/functions/drawing/simulator.py:30–48  ·  view source on GitHub ↗
(self, init_position, H, max_iter=400, epsilon=0.001, dt=2.0)

Source from the content-addressed store, hash-verified

28 self.damping_factor = damping_factor
29
30 def simulate(self, init_position, H, max_iter=400, epsilon=0.001, dt=2.0) -> None:
31 import numpy as np
32
33 """
34 Simulate the force-directed layout algorithm.
35 """
36 position = init_position.copy()
37 velocity = np.zeros_like(position)
38 damping = 1.0
39 for it in range(max_iter):
40 position, velocity, stop = self._step(
41 position, velocity, H, epsilon, damping, dt
42 )
43 # np.save("./tmp/position_{}.npy".format(it), position)
44 # np.save("./tmp/velocity_{}.npy".format(it), velocity)
45 if stop:
46 break
47 damping *= self.damping_factor
48 return position
49
50 def _step(self, position, velocity, H, epsilon, damping, dt):
51 import numpy as np

Callers 1

force_layoutFunction · 0.95

Calls 2

_stepMethod · 0.95
copyMethod · 0.45

Tested by

no test coverage detected