Let
$f : X \to S$
be a family of smooth projective algebraic varieties over a smooth connected quasi-projective base
$S$
, and let
$\mathbb {V} = R^{2k} f_{*} \mathbb {Z}(k)$
be the integral variation of Hodge structure coming from degree
$2k$
cohomology it induces. Associated to
$\mathbb {V}$
one has the so-called Hodge locus
$\textrm {HL}(S) \subset S$
, which is a countable union of ‘special’ algebraic subvarieties of
$S$
parametrizing those fibres of
$\mathbb {V}$
possessing extra Hodge tensors (and so, conjecturally, those fibres of
$f$
possessing extra algebraic cycles). The special subvarieties belong to a larger class of so-called weakly special subvarieties, which are subvarieties of
$S$
maximal for their algebraic monodromy groups. For each positive integer
$d$
, we give an algorithm to compute the set of all weakly special subvarieties
$Z \subset S$
of degree at most
$d$
(with the degree taken relative to a choice of projective compactification
$S \subset \overline {S}$
and very ample line bundle
$\mathcal {L}$
on
$\overline {S}$
). As a corollary of our algorithm we prove conjectures of Daw–Ren and Daw–Javanpeykar–Kühne on the finiteness of sets of special and weakly special subvarieties of bounded degree.