Layout the graph live on the canvas using a physics simulator.
graph_live_layout( g, spring_length = 30L, sping_coeff = 8e-04, gravity = -1.2, theta = 0.8, drag_coeff = 0.02, time_step = 20L, is_3d = TRUE ) graph_layout_live( g, spring_length = 30L, sping_coeff = 8e-04, gravity = -1.2, theta = 0.8, drag_coeff = 0.02, time_step = 20L, is_3d = TRUE )
|An object of class |
|Used to compute Hook's law, default of |
|Hook's law coefficient, where |
|Coulomb's law coefficient. It's used to repel nodes thus should be negative if positive nodes attract each other.|
|Theta coefficient from Barnes Hut simulation, between |
|Drag force coefficient. Used to slow down system, thus should be less than |
|Default time step $dt$ for forces integration.|
|Whether to plot in 3 dimensions or 2 dimensions.|
Calculates forces acting on each body and then deduces their position via Newton's law. There are three major forces in the system:
list("Spring force keeps connected nodes together via ", list(list("https://en.wikipedia.org/wiki/Hooke's_law"), list("Hooke's law")), ".")
list("Each body repels each other via ", list(list("https://en.wikipedia.org/wiki/Coulomb's_law"), list("Coulomb's law")), ".")
list("To guarantee we get to "stable" state the system has a drag force which slows entire simulation down.")
Body forces are calculated in $n*lg(n)$ time with help of Barnes-Hut algorithm. Euler method is then used to solve ordinary differential equation of Newton's law and get position of bodies.
data <- make_data(20) graph(data) %>% graph_layout_live(time_step = 5L)