2025-09-29, 2240h

I wanna poke around at some stats about my files. Interestingly, as I'm writing this, it'll produce new stats each time I update my Website. But I'm writing this on September 29th, 2025, and I started this research archive, with GnoponEmacs, on August 7th.

First, I was curious: how many nodes do I have, what's the mean number of links in each one, what's the max links in one nodes, and how many are isolatd.

(defun gpe/org-roam-link-stats ()
"Return an alist of (node-id . link-count)."
(mapcar
(lambda (node)
(cons (org-roam-node-id node)
(length (org-roam-backlinks-get node))))
(org-roam-node-list)))
(let* ((stats (gpe/org-roam-link-stats))
(counts (mapcar #'cdr stats)))
(list
(cons 'total-nodes (length stats))
(cons 'mean-links (/ (apply #'+ counts) (float (length counts))))
(cons 'max-links (apply #'max counts))
(cons 'isolated-nodes (cl-count 0 counts))))

: ((total-nodes . 3905) (mean-links . 1.7144686299615877) (max-links . 106) (isolated-nodes . 325))

As of writing, 3783 nodes, 1.6 mean links per, max links in one node is 103, and 295 nodes are isolated.

Now I wanna look at the distribution of those links:

(let* ((stats (mapcar
(lambda (node)
(cons (org-roam-node-id node)
(length (org-roam-backlinks-get node))))
(org-roam-node-list)))
(counts (mapcar #'cdr stats))
(hist (make-hash-table :test 'equal)))
(dolist (c counts)
(puthash c (1+ (gethash c hist 0)) hist))
(let (alist)
(maphash (lambda (k v) (push (cons k v) alist)) hist)
(concat "| Degree | Count |\n|-\n"
(mapconcat
(lambda (pair)
(format "| %d | %d |" (car pair) (cdr pair)))
(sort alist (lambda (a b) (< (car a) (car b))))
"\n"))))

| Degree | Count |
|-
| 0 | 325 |
| 1 | 2693 |
| 2 | 473 |
| 3 | 157 |
| 4 | 69 |
| 5 | 60 |
| 6 | 25 |
| 7 | 23 |
| 8 | 14 |
| 9 | 8 |
| 10 | 11 |
| 11 | 3 |
| 12 | 3 |
| 13 | 4 |
| 14 | 2 |
| 15 | 1 |
| 16 | 2 |
| 17 | 7 |
| 18 | 2 |
| 20 | 3 |
| 21 | 1 |
| 23 | 2 |
| 24 | 3 |
| 25 | 1 |
| 29 | 1 |
| 30 | 1 |
| 33 | 1 |
| 35 | 1 |
| 48 | 1 |
| 51 | 1 |
| 59 | 2 |
| 91 | 3 |
| 106 | 2 |