r/KnowledgeGraph

▲ 16 r/KnowledgeGraph+4 crossposts

Hi everyone,

I’ve spent the last few months building a custom knowledge graph extraction engine (which I call blAST) designed to map the architectural physics of massive software repositories.

Usually, extracting code into a graph requires an Abstract Syntax Tree (AST). The problem is ASTs are incredibly heavy, strictly monolingual, and fail if a repository doesn't compile. I wanted to map planetary-scale, multi-lingual enterprise systems, so I built a deterministic parser instead. It treats code like text and scans for keyword markers across 50+ languages to build the graph.

Here is how the graph ontology and analytics work:

1. The Ontology

  • Nodes: Files, Classes, and Functions.
  • Node Properties: 50+ dimensional vectors representing regex keyword hits (e.g., raw memory manipulation, state flux,etc).
  • Edges: File (imports/dependencies) and functional execution paths (outbound calls/reachability).

2. Graph Analytics & Network Topology

Once the graph is built, the engine runs network math over the repository to find architectural bottlenecks. I calculate:

  • Modularity & Average Path Length to measure encapsulation.
  • Articulation Points to find the "God Nodes" (if these fail, the graph shatters).
  • Cyclic Loop Density to measure static friction in the architecture.

3. K-Means Clustering on 1.5M Nodes

As all langauges have keywords that roughly mean the same thing, I analyzed 1000 repos of different languages and I took the regex count vectors of 1.59 million file nodes across 50 languages and ran them through an unsupervised K-Means clustering algorithm. The graph converged into 10 distinct architectural "micro-species" (e.g., UI View Layers, Highly Concurrent State Managers, Unshielded Native Core). The clustering algorithm successfully grouped a complex Java service and a defensive Rust file into the same exact node category based purely on their physical edge/property behavior.

4. Graph Traversal Use Cases

I used this graph engine to tear down Google DeepMind's original AlphaFold repo. By traversing the graph, the engine instantly isolated the absolute heaviest bottleneck in the network: a single node (contacts_network.py) running an $O(N^6)$ complexity loop holding up the entire pipeline.

code - https://github.com/squid-protocol/gitgalaxy

example data of google Deepmind's Alphafold - https://squid-protocol.github.io/gitgalaxy/museum-of-code/alphafold_teardown.html

Population data from 100's of repos - https://squid-protocol.github.io/gitgalaxy/03-04-claim-4-comparing-languages/

u/Chunky_cold_mandala — 5 days ago