r/PKMS • u/Longjumping_Reach419 • 16d ago
Discussion I used an algorithm to automatically detect clusters in my collective knowledge graph
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!
2
u/Sad_Plane_4677 13d 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 13d 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 13d ago edited 13d 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 13d 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 13d 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.
2
u/YouWillConcur 16d ago
share the code?