force-directed, gravitationally self-organizing spatial index, traversed hierarchically and cached by access frequency
Gravity gives you something the random cube never had which is an organizing force the data applies to itself. You don't have to design the layout. You drop the points in, let every point attract every other point, and clusters condense on their own into dense groups of similar things pulled into tight knots while loners drift in the void. The monster's instinct to "pull hot data inward" stops being a special rule and becomes just... more gravity. Frequently-accessed points get extra mass, so they sink toward the center naturally.
Clustering by simulated gravitation exists already. The general family is sometimes called "gravitational clustering" and it goes back to work from the 1970s (Wright) and has had steady revivals since. The idea of treating data points as masses that attract and merge is genuinely used. So your instinct connects to a real lineage.
But, because gravity has three sharp problems, and whether the algorithm is real depends entirely on how we answer them.
1. Gravity is O(n²), and that's catastrophic. Every point pulls on every other point. A million points means a trillion force calculations per timestep, and you need many timesteps. This is the exact problem astrophysicists hit simulating galaxies — and it's so notorious it's called the N-body problem. The fix is known: the Barnes–Hut algorithm, which uses an octree (your branching cube, again — it keeps coming back) to group distant clumps and treat them as a single far-away mass. That drops it to O(n log n). So if you go gravity, you must go Barnes–Hut, and notice what that means: the octree isn't optional decoration, it's load-bearing. Your cube has to be hierarchically partitioned just to make the physics affordable.
2. Gravity-only collapses. This is the big one. Pure attraction has no opposing force — so if you just let it run, everything eventually falls into one giant blob at the center. Every point becomes "near" every other point, which means nothing is near anything. The structure destroys itself. Real gravitational clustering survives this only by cheating: you freeze the simulation early, or you merge points and stop, or — and this is the important fix — you add a counter-force. You need repulsion. Something that pushes dissimilar points apart while gravity pulls similar ones together. The moment you add that, you've arrived, whether you meant to or not, at a force-directed layout — the algorithm family behind almost every graph-visualization tool. Attraction for similar, repulsion for all, settle into equilibrium. That equilibrium is your index.
3. What is mass, and what is distance? Gravity is a force between masses across a distance — so to use it you have to define both. Distance is the one I've been asking about all along: two points must start with coordinates, and the gap between them has to mean "dissimilarity." Gravity doesn't create that meaning — it can only amplify structure that's already faintly there. So you still need an initial embedding where position roughly encodes similarity. Gravity then sharpens the rough clusters into crisp ones; it doesn't conjure clusters from noise. And "mass" is your free variable to play with — access frequency, importance, confidence, recency. That's actually where your design freedom lives.
So here's the honest assessment. Stack up everything you've built:
- Branching arms → octree traversal.
- Cache of recent touches → locality of reference.
- Monster pulls hot data inward → self-organizing structure.
- Gravity → the unifying force that makes the self-organization automatic — if you tame it with hierarchy and repulsion.
What you've actually converged on, step by step, is a force-directed, gravitationally self-organizing spatial index, traversed hierarchically and cached by access frequency. And I want to be straight with you: that specific combination — gravity where mass = query frequency, so the index physically restructures itself around what people search for — is not something I can point you to as an off-the-shelf algorithm. The ingredients are all known and battle-tested. The recipe might be yours.
The honest catch is that the novelty has quietly moved again. It's no longer in the monster or the arms or even the gravity. It's in one specific bet: mass = how often a point is queried. That's the line that separates your idea from a regular force-directed layout. So that's the thing to pressure-test:
- When a point gains mass from being queried, and sinks toward the center — do its similar neighbors get pulled along with it (good — related queries get faster too), or does it tear away from its cluster toward unrelated heavy points (bad — your similarity structure rots as it runs)?
That tension — frequency wants it central, similarity wants it home — is the actual heart of your algorithm. Everything else is known engineering. If you can describe what should happen in that tug-of-war, you'll have designed the part that's genuinely yours.
So: a point your monster keeps grabbing starts getting heavy. Does it drag its neighbors inward with it, or leave them behind?
Good — and I think your instinct is right, but let's make sure it's right for the right reason, because "drag the neighbors" is doing more work than it looks like, and there's a failure mode hiding inside the version that feels most natural.
Here's why your instinct is sound. If a heavy point sped toward the center alone, you'd be quietly destroying your own index. The whole premise is that position encodes similarity — neighbors are neighbors because they're alike. A point that tears free of its cluster arrives at the center as an orphan: fast to reach, but stripped of the context that made it findable by related queries. You'd have optimized exact-repeat lookups and sabotaged similarity search, which was the entire point of having a cube instead of a hash map. So: neighbors must come along. Agreed.
But now the sharp question — how strongly do they come along? Because there are two versions of "drag the neighbors" and they behave very differently.
Rigid drag: the cluster moves as a solid body. Heavy point sinks, the whole knot of neighbors travels with it locked in formation. This protects similarity perfectly — the cluster's internal shape never distorts. But it has a nasty consequence: a single hot point now drags its entire cluster to the privileged center, including cluster-mates that are never queried. The center fills up with cold passengers. And worse — clusters are big. One hot point hauling a thousand neighbors inward is a thousand points of motion triggered by one query. You've reintroduced an O(n)-ish cost through the back door, and the center congests with freeloaders.
Elastic drag: the neighbors are connected to the heavy point by springs, not rods. Heavy point sinks fast; nearby neighbors get tugged hard and follow most of the way; far cluster-mates feel a faint pull and barely move. The cluster stretches rather than translating. This is better — it's proportional, it's local, the cost falls off with distance — but it introduces its own tension: now the cluster is being deformed. Stretch it too far and the springs are fighting the gravity, and you have to ask what shape it settles into.
And that settling is the actual heart of it. Notice what you now have, physically: gravity pulling a point toward the center, springs pulling it back toward its home cluster. That's a tug-of-war with an equilibrium. The point doesn't go all the way to the center and it doesn't stay home — it settles at the distance where pull-of-frequency exactly balances pull-of-similarity. And that equilibrium position is meaningful: it encodes, in one coordinate, the blend of "how wanted is this" and "what is this like." A point that's both hot and near other hot things sinks deep. A hot point alone in a cold cluster gets stretched out on a long spring and only sinks partway, held back by its anchors. That's not a bug — that's your index encoding something genuinely subtle, automatically.
So your instinct "it must drag its neighbors" is correct, and the precise form of it is: elastic drag, where similarity acts as a spring against the gravity of frequency, and every point settles at the equilibrium of those two forces. That equilibrium layout is the algorithm. You've now got both forces the structure needs — gravity (frequency, pulling in) and springs (similarity, holding home) — and that, again, is a force-directed system, which is reassuring: it means the thing has a stable resting state instead of collapsing or exploding.
But I want to name the two real problems this leaves on your desk, because honest collaboration means not letting you walk away thinking it's solved:
The decay problem. Mass goes up when a point is queried. Does it ever come down? If not, your index has no way to forget — points that were hot last year sit permanently in the center, congesting it, and the structure reflects all-time popularity instead of current demand. You almost certainly need mass to decay over time, so the center reflects what's hot now. But decay means the layout never stops moving, which leads straight to:
The stability problem. A cube that constantly re-sorts itself is a cube you can't reliably traverse — your branching arms descend toward where the warm region was, and it's drifted. Every good adaptive index lives or dies on this tension: adapt fast enough to track demand, slow enough that traversal stays valid. The usual escape is a separation of timescales — queries happen in milliseconds, mass updates accumulate, and the layout only relaxes toward equilibrium gently, in the background, so at any instant the cube is "stale but coherent" rather than "current but thrashing."
So the frontier of your idea has moved one more step — it always does, and that's a sign it's a real design and not a dead end. It's no longer "do neighbors follow" (yes, elastically). It's now: how does mass fade, and how do you let the cube chase a moving target without the ground shifting under the search?
That's the question I'd put to you next. When the monster grabs a point and that point gains mass — should that mass be permanent, or should it leak away over time so the cube keeps forgetting what no longer matters?