Using Simulation for Graph Visualization

AI Thread Summary
The discussion focuses on visualizing a large graph with approximately 500,000 vertices and 5,000,000 edges, which cannot be effectively managed by standard graph visualization tools. The proposed solution involves simulating a physical system where vertices are treated as "balls" that repel each other, while edges act like elastic "strings" that attract connected nodes. The goal is to determine x-coordinates for the vertices to minimize edge lengths and prevent crowding within rows. The simulation will iteratively adjust positions based on gravitational and elastic forces until a stable configuration is achieved. Suggestions for improving the algorithm or addressing potential issues with convergence or stability are welcomed.
Sane
Messages
220
Reaction score
0
Firstly, let me excuse myself for not knowing the most appropriate location to post this question. This is a question pertaining to Graph Theory, but the heart of the application is intended to be driven by the math and/or simulation of classical physics.

At work I am currently attempting to visualize a very large graph. The graph is initially too squished together and is altogether incomprehensible when drawn on screen. My plan is to simulate a physical scenario involving the graph, in which the end result of the system should yield a more "eye-pleasing" arrangement of vertices (nodes or points) and edges (a link between two nodes). The details are as follows:

I have a very specific graph that, due to its size, requires visualization of overall structure. I cannot use any out-of-the-box graph visualization tools because the graph is simply too big, the goal is to get an idea of how the general layout looks, and I want to have fine-grain control over aspects such as the colour and the y-coordinates. This is going to fit into one image (maybe 5,000x5,000) so there won't even be enough room to have nodes larger than a few pixels. Point being: I doubt any free applications out there can satisfy my needs.

The graph is special because I've arranged it in the following way:

There are approximately 500,000 vertices. Every vertex already has a desired y-coordinate that should not change. There are around 500 "rows" (one for each y-coordinate), and each row contains anywhere between 1 and 100,000 nodes. Edges can only exist between vertices on different rows (edges will never join vertices on the same row). Finally, the graph is sparse with only around 5,000,000 edges.

Every vertex also has a desired colour/shape. The x-coordinates are currently unknown.

I need a way to determine the x-coordinate of each and every node, such that vertices on the same row do not crowd each other, and the geometrical/physical length of each edge is minimized. Clearly, some more precise objective function will be necessary, but this description should suffice for the planning stages. In the end, plotting the (x,y,colour) of each node (and potentially joining some of the more major nodes with a transparent edge) should give a visual representation of how the graph is structured.

My plan is to motivate the algorithm by the physics required to simulate an interaction between "balls" joined by elastic "strings". Balls will gravitationally repel all other balls on the same row, and strings will have tension and elastic energy that try to bring the two ends closer together (and could potentially break if need be).

The physics would be simulated in an iterative fashion, where the system begins with some amount of potential energy, and each step of the simulation assigns new x-coordinates to each ball, based on the x-components of all surrounding forces, to put the system into a more "stable" condition. The iterations would continue until the changes become minimal, converge, or after a fixed amount of time.

Any suggestions or pointers as to the kind of equations or algorithms that could be used here? Thank you very much!
 
Last edited:
Physics news on Phys.org
I have been thinking about this for quite a while, and thought of the following simulation:

Code:
for node in graph:
    node.x = <arbitrary value near 0> must be distinct per row
    node.velocity = 0

for number of STEPS:
    for node in graph:
        node.accel = 0
        for node's row: 
            node.accel += G/r^2
        for node.neighbours: 
            node.accel += K*x/sqrt(x^2 + y^2)
        node.velocity += node.accel * TIME

    for node in graph:
        node.x += node.velocity * TIME

The first equation is Attraction[/url] (where r is the distance in x co-ordinates between the two nodes -- note: needs a direction added), the second equation is Law[/url] using the x-distance between the nodes as the stretch factor normalized by their euclidean distance, and G/K/TIME/STEPS are constants to play with. Mass is implicitly 1 throughout to simplify equations and set force equal to acceleration.

This method seems appealing. However, there is always the chance that the system might stand still, oscillate, diverge, or generally do something stupid. I can try it out tomorrow, but anyone want to add their thoughts or point out some potential short-comings or improvements?
 
Last edited by a moderator:
Thread ''splain this hydrostatic paradox in tiny words'
This is (ostensibly) not a trick shot or video*. The scale was balanced before any blue water was added. 550mL of blue water was added to the left side. only 60mL of water needed to be added to the right side to re-balance the scale. Apparently, the scale will balance when the height of the two columns is equal. The left side of the scale only feels the weight of the column above the lower "tail" of the funnel (i.e. 60mL). So where does the weight of the remaining (550-60=) 490mL go...
Consider an extremely long and perfectly calibrated scale. A car with a mass of 1000 kg is placed on it, and the scale registers this weight accurately. Now, suppose the car begins to move, reaching very high speeds. Neglecting air resistance and rolling friction, if the car attains, for example, a velocity of 500 km/h, will the scale still indicate a weight corresponding to 1000 kg, or will the measured value decrease as a result of the motion? In a second scenario, imagine a person with a...
Scalar and vector potentials in Coulomb gauge Assume Coulomb gauge so that $$\nabla \cdot \mathbf{A}=0.\tag{1}$$ The scalar potential ##\phi## is described by Poisson's equation $$\nabla^2 \phi = -\frac{\rho}{\varepsilon_0}\tag{2}$$ which has the instantaneous general solution given by $$\phi(\mathbf{r},t)=\frac{1}{4\pi\varepsilon_0}\int \frac{\rho(\mathbf{r}',t)}{|\mathbf{r}-\mathbf{r}'|}d^3r'.\tag{3}$$ In Coulomb gauge the vector potential ##\mathbf{A}## is given by...
Back
Top