r/PKMS • • 9d ago

Discussion I used an algorithm to automatically detect clusters in my collective knowledge graph

Post image

Instead of relying purely on manual organization, I wanted to see what would happen if I let an algorithm automatically detect clusters (i call them "Hubs") in my knowledge graph purely from how notes and concepts are linked together.

I'm currently working on an update for a collaborative knowledge app I'm building, and I've been testing the Louvain community detection algorithm on the global graph (the shared knowledge graph)

I was genuinely surprised by the quality of the results and what pure graph structure reveals without any AI or text analysis.

For instance, it surfaced parallel clusters across languages, like "Productivity" and "Productivité" showing up as two separate hubs. That raises an interesting design question: writing bridge notes to link both concepts could eventually pull them together, though keeping distinct clusters for each language community might actually be preferable (we'll see what happens!).

On the flip side, it kept closely related topics separate, like "Prise de notes" (note-taking) and "Système de prise de note" (note-taking systems), simply because their notes connect to different neighboring concepts. It was also fascinating to spot tiny clusters forming around very specific niche topics that individual users just started exploring.

For the technical part for those interested : I looked into Leiden algo too, though my current stack only had a solid library for Louvain. Each detected cluster gets assigned a color and is automatically named after its highest-weighted concept. Since the script runs every night at midnight, I added a small stabilization step that compares each new output against the previous day's run, keeping the same IDs and colors whenever a cluster's core nodes haven't shifted too much.

Watching how these clusters grow, split, or merge over time should be really interesting, but for now I don't store historical snapshots of each daily run.

Have any of you experimented with automated graph clustering (via plugins, custom scripts, or specific PKM tools) ?

I'm curious to hear how you approach discovering structure in a growing graph, or any thoughts and questions you have on this setup!

0 Upvotes

13 comments sorted by

2

u/YouWillConcur 8d ago

share the code?

1

u/Longjumping_Reach419 8d ago

It's part of a proprietary web app I'm building rather than an open-source script, so I can't share the repo. And honestly, there isn't much magic to share anyway: I didn't code the Louvain algorithm myself (it's just a standard library), and the stabilization step is super basic: it just compares yesterday's clusters with today's output and keeps the same ID and color whenever the core nodes haven't changed much.

What I find really interesting here isn't so much the code itself, but how applying a simple community-detection algorithm changes the way you navigate and organize a large knowledge graph.

1

u/YouWillConcur 8d ago

i just wanted to know what approach and algos did you use, im vibecoding tools for myself and want to do smth similar for me locally

you can also check infranodus i think you might be interested

2

u/Longjumping_Reach419 8d ago

Oh got it, my bad! For vibecoding something similar locally, the stack is pretty straightforward: you need a standard graph data structure (nodes for concepts, weighted edges for co-occurrences in notes) and a community-detection library like graphology (with graphology-communities-louvain in JS/TS) or networkx in Python may do the job too.

Thanks for mentioning InfraNodus too! From what I learn, it leans heavily into automated NLP and AI text extraction, whereas my platform's philosophy is strictly centered around intentional human curation rather than AI. That said, revealing a hidden meta-structure purely from how ideas connect is the exact same intention behind my Louvain implementation, so it's definitely cool to see that overlap in approach.

0

u/TomLucidor 6d ago

FOSS for bust

2

u/Lagarenne_Avena 8d ago

doubt theyll open source the whole thing if its part of an app they are building, maybe just the stabilization logic

1

u/Sad_Plane_4677 5d ago

open source it for what ? yet another implementation of yet another clustering algo ? if there was some value, there is probably a data science package implemented it. weka already has dbscan and kmeans and that's from 2012 when was last time i looked at the documentation.

2

u/Sad_Plane_4677 5d ago

kmeans, dbscan and graph cliques. if you use tags, go for cliques. dbscan has a natural advantage on disjoint graphs. kmeans seems to work better on small world structured graphs than in the wild.

1

u/Longjumping_Reach419 5d ago

Thanks for the insight, you clearly know your way around clustering algorithms! (probably better than me..)

Honestly, I hadn't looked into dbscan or cliques at all. I went straight for Louvain because it works directly on weighted graph topology. Since the nodes don't live in a vector space, kmeans or dbscan don't really fit, and we can't predefine a fixed number of clusters because the graph evolves every day.

Strict graph cliques also feel a bit too rigid for human-curated notes, since users rarely connect every concept in a topic to every other one. In the current UI, clicking a concept actually highlights its immediate neighborhood (a 1-hop ego network), fading out the rest, which gets close to that idea locally without requiring a full clique. Louvain just felt like the most organic way to let broader Hubs emerge naturally from daily activity.

1

u/Sad_Plane_4677 5d ago edited 5d ago

Graphs are represented as adjacent lists and generalized as matrices. Weighted represent the connection as distances vs 0/1 for graphs withous distances, so make sure how your metrics fit and how the algorithms outputs make sense. As I said, cliques I used on graphs of tags. Found it to be a good application making sense. Louvain i hadn't met until recently and your post reminded me of it, so I'm not sure how well it behaves on graphs of kms systems. But if you're happy with the results more power to you. Personally I would recommend dbscan et al as I can see posts forming disjoint graphs.Seems to fit good for the domain and dataset.in fact, I might go for it myself one of these days. Seems like a fun project.

1

u/Longjumping_Reach419 5d ago

Fair point, mathematically you're right the graph could easily be represented as a matrix or vectorized to run those algorithms

When you said "make sure how your metrics fit and how the algorithms outputs make sense," that is actually what I focused on most. I didn't really dive into the underlying math or implementation details and pretty much just plugged in the standard Louvain library, focusing instead on whether the resulting hubs made sense for users

For now, I'm going to stick with this implementation and see how users interact with it, though offering different algorithms down the road to surface different meta-structures of the graph is definitely a cool idea

Thanks a lot for taking an interest in the project, and I can confirm it has been a really fun one to build!

2

u/Sad_Plane_4677 5d ago

Start with unweighted as a baseline. Its already there and results can be explained simpler before moving to more complex distance measure or why the measure works. I can see pagerank working, it's natural environment was the web and interconnected pages after all. But as I said, test simple, survey the land. Complex will come later. Have fun along the way.