VC: Visualization with Trees and Graphs

Jeheonpark
The Startup
Published in
6 min readSep 12, 2020

--

Do you like graphs? I really like it because it looks like a real-world for me. Didn’t you? I hope you feel the same thing. Graphs can be anything, it can be protein, human, animal, molecule, machine, and anything you can imagine. In this post, we will learn some techniques based on graphs to visualize the data.

Force-directed Graph Layouts

The goal of this technique is to place groups of strongly connected nodes close to each other, preserve the minimum distance between nodes. How can we achieve this, we will take the idea from nature. The idea is to model the graph as a spring system. Edges are modeled as springs and we need to avoid the overlaps between nodes, we model nodes to electrically repel each other. The final positions are selected by simulating the resulting forces, finding equilibrium between spring force and electrical force.

Let’s define both forces:

The Spring force is calculated for the connected nodes. pj-pi is the vector from ni to nj. We normalize this vector and s is the natural spring length, the normal length when there are no external forces. k is the tension of the spring.

Electrical repulsion is calculated for every node. It is defined by the above equation. r is repulsion strength.

General Algorithm

The idea is to find out the equilibrium point where the distances of the nodes make the forces zero.

  1. Initialize randomly…

--

--

Jeheonpark
The Startup

Jeheon Park, Software Engineer at Kakao in South Korea