What does Community Topology Checkup conclude, in numbers, about “Persistent Homology: the Rips Filtration, Union-Find for Dimension Zero and Reduction Mod 2 for Dimension One”?

Answer: Chapter 2 computes the zero-dimensional barcode by union-find and the one-dimensional barcode by column reduction mod 2; across two hundred synthetic communities total likes have an AUC of only 0.427 while L3, the sum of the three longest one-dimensional bars, has 0.975, falling to 0.673 when the genuine core of the padded communities grows to 30, where short zero-dimensional bars must take over.

Scope of the numbers: Every community and member in the book is synthetic data with fixed seeds, and no data from any real community or person is used; all calculations are generated by its programs, and its parameters are illustrative. The book is not individual business advice, and its "detection of paid boosters" produces only a list of suspects for human review, never an automatic penalty for any member.

中文版

Data table

The numbers below are printed verbatim by the chapter's Python program and can be reproduced by running it. standard-library Python onlyprinted values that match the answer: 0.427, 0.673, 0.975, 30

metric AUC95 % interval
likes (activity)0.427 [0.348, 0.506]
co-engagement triangles0.003 [0.000, 0.011]
longest H1 bar0.970 [0.946, 0.994]
H1 lead-3 persistence L30.975 [0.953, 0.997]
short H0 bars per account0.000 [0.000, 0.000]
dose scan: real core of padded communities, 40 vs 40 each
core AUC likes AUC L3 AUC short-bars
100.570 0.998 0.000
150.187 0.963 0.000
200.000 0.918 0.000
250.000 0.786 0.000
300.000 0.673 0.000
Show the full program
# Chapter 2. p23: Which number separates genuine from padded communities?
# 100 genuine (24-36 members over the whole ring) against 100 padded
# (10-14 real members over the whole ring plus 14-22 lockstep
# accounts), fixed seed, synthetic only. AUC = P(genuine scores above
# padded); 0.5 is no information, values near 0 mean the metric ranks
# padded communities higher. 95 % intervals by Hanley and McNeil (1982).
# Then a dose scan: the real core of the padded communities grows.
import math
import random

T, P = 24, 5          # 24 topics on a ring, 5 posts each (illustrative)
N_POSTS = T * P


def member(rng, centre, width, q=0.8, stray=0.03):
    # a genuine member likes posts on an arc of topics around centre
    s = set()
    for t in range(T):
        dd = abs(t - centre) % T
        dd = min(dd, T - dd)
        hit = q if dd <= width / 2.0 else stray
        for k in range(P):
            if rng.random() < hit:
                s.add(t * P + k)
    return s


def sock(rng, target, q=0.95, stray=0.01):
    # a boosting account likes the operator's target posts in lockstep
    s = set()
    for p in range(N_POSTS):
        if rng.random() < (q if p in target else stray):
            s.add(p)
    return s


def community(rng, n_real, arc, n_sock):
    # n_real genuine members with interest centres on [0, arc) topics,
    # plus n_sock boosting accounts aimed at 30 target posts
    pts = []
    for _ in range(n_real):
        pts.append(member(rng, rng.uniform(0, arc), rng.randint(5, 8)))
    target = set(rng.sample(range(N_POSTS), 30))
    for _ in range(n_sock):
        pts.append(sock(rng, target))
    return pts


def jaccard(a, b):
    u = len(a | b)
    return 1.0 - len(a & b) / u if u else 0.0


def barcodes(pts, cap=1.0):
    return barcodes_d(len(pts), lambda i, j: jaccard(pts[i], pts[j]), cap)


def barcodes_d(n, dist, cap=1.0):
    # Vietoris-Rips filtration (up to triangles) of a distance dist(i, j).
    # H0 by union-find; H1 by mod-2 reduction of triangle columns,
    # each column stored as a Python integer used as a bitset of edges.
    edges = []
    for i in range(n):
        for j in range(i + 1, n):
            d = dist(i, j)
            if d <= cap:
                edges.append((d, i, j))
    edges.sort()
    eid = {(i, j): k for k, (d, i, j) in enumerate(edges)}
    par = list(range(n))

    def find(x):
        while par[x] != x:
            par[x] = par[par[x]]
            x = par[x]
        return x
    h0, neg = [], set()
    for k, (d, i, j) in enumerate(edges):
        a, b = find(i), find(j)
        if a != b:
            par[max(a, b)] = min(a, b)
            h0.append((d, i, j))
            neg.add(k)
    tris = []
    for (i, j), e in eid.items():
        for k in range(j + 1, n):
            f, g = eid.get((i, k)), eid.get((j, k))
            if f is not None and g is not None:
                tris.append(tuple(sorted((e, f, g), reverse=True)))
    tris.sort()
    piv, h1 = {}, []
    for t in tris:
        col = (1 << t[0]) | (1 << t[1]) | (1 << t[2])
        while col:
            low = col.bit_length() - 1
            if low not in piv:
                piv[low] = col
                break
            col ^= piv[low]
        if col and edges[t[0]][0] > edges[low][0]:
            h1.append((edges[low][0], edges[t[0]][0]))
    for k in range(len(edges)):
        if k not in neg and k not in piv:
            h1.append((edges[k][0], cap))     # still open at the cap
    return h0, h1


def lead3(h1):
    # length of the three longest one-dimensional bars, added exactly
    top = sorted((d - b for b, d in h1), reverse=True)[:3]
    return math.fsum(top)


def short_frac(h0, n, delta=0.2):
    # zero-dimensional bars dying below delta, per account
    return len([1 for d, i, j in h0 if d < delta]) / float(n)


def auc(pos, neg):
    # Mann-Whitney estimate of P(score of pos > score of neg)
    wins = 0
    for a in pos:
        for b in neg:
            wins += 2 if a > b else (1 if a == b else 0)
    return wins / (2.0 * len(pos) * len(neg))


def auc_se(a, n1, n2):
    # Hanley and McNeil (1982) standard error of an AUC
    q1, q2 = a / (2.0 - a), 2.0 * a * a / (1.0 + a)
    v = (a * (1 - a) + (n1 - 1) * (q1 - a * a)
         + (n2 - 1) * (q2 - a * a)) / (n1 * n2)
    return math.sqrt(max(v, 0.0))


def features(pts):
    n = len(pts)
    likes = 0
    for p in pts:
        likes += len(p)
    tri = 0
    near = [[jaccard(pts[i], pts[j]) <= 0.75 for j in range(n)]
            for i in range(n)]
    for i in range(n):
        for j in range(i + 1, n):
            if near[i][j]:
                for k in range(j + 1, n):
                    if near[i][k] and near[j][k]:
                        tri += 1
    h0, h1 = barcodes(pts)
    longest = max([d - b for b, d in h1] + [0.0])
    return [likes, tri, longest, lead3(h1), short_frac(h0, n)]


rng = random.Random(20261113)
G = [features(community(rng, rng.randint(24, 36), 24, 0))
     for _ in range(100)]
F = [features(community(rng, rng.randint(10, 14), 24,
                        rng.randint(14, 22))) for _ in range(100)]
names = ["likes (activity)", "co-engagement triangles",
         "longest H1 bar", "H1 lead-3 persistence L3",
         "short H0 bars per account"]
print("%-27s %6s  %15s" % ("metric", "AUC", "95 % interval"))
for m, name in enumerate(names):
    a = auc([g[m] for g in G], [f[m] for f in F])
    se = auc_se(max(a, 1 - a), 100, 100)
    print("%-27s %6.3f  [%.3f, %.3f]" % (name, a, max(0.0, a - 1.96 * se),
                                         min(1.0, a + 1.96 * se)))
print("dose scan: real core of padded communities, 40 vs 40 each")
print("core  AUC likes  AUC L3  AUC short-bars")
G40 = G[:40]
for core in (10, 15, 20, 25, 30):
    PAD = [features(community(rng, core, 24, 18)) for _ in range(40)]
    print("%4d  %9.3f  %6.3f  %14.3f" % (
        core, auc([g[0] for g in G40], [p[0] for p in PAD]),
        auc([g[3] for g in G40], [p[3] for p in PAD]),
        auc([g[4] for g in G40], [p[4] for p in PAD])))

Single source and citation

Fan, Y. (2026). Persistent Homology and Betti Numbers: Structural Voids in High-Net-Worth Private Communities and the Review of Fake Cliques (Version 1.0.0), Chapter 2: Persistent Homology: the Rips Filtration, Union-Find for Dimension Zero and Reduction Mod 2 for Dimension One. 5D Library. DOI pending

DOI pending · monograph page goes live after publication · 5DL-B-236 · v1.0.0 · CC-BY-NC-ND-4.0

BibTeX
@book{fan2026236,
  author    = {Fan, Yafu},
  title     = {Persistent Homology and Betti Numbers: Structural Voids in High-Net-Worth Private Communities and the Review of Fake Cliques},
  year      = {2026},
  publisher = {5D Library},
  edition   = {1.0.0},
  note      = {DOI pending}
}

Other chapter answers in this book