Let H n be a graph on n vertices and let H n denote the complement of H n . Suppose that ∆ = ∆(n) is the maximum degree of H n . We analyse three algorithms for sampling d-regular subgraphs (d-factors) of H n . This is equivalent to uniformly sampling dregular graphs which avoid a set E(H n ) of forbidden edges. Here d = d(n) is a positive integer which may depend on n.Two of these algorithms produce a uniformly random d-factor of H n in expected runtime which is linear in n and low-degree polynomial in d and ∆. The first algorithm applies when (d + ∆)d∆ = o(n). This improves on an earlier algorithm by the first author, which required constant d and at most a linear number of edges in H n . The second algorithm applies when H n is regular and d 2 + ∆ 2 = o(n), adapting an approach developed by the first author together with Wormald. The third algorithm is a simplification of the second, and produces an approximately uniform d-factor of H n in time O(dn). Here the output distribution differs from uniform by o(1) in total variation distance, provided that d 2 + ∆ 2 = o(n). d = o(n 1/3 ), and by McKay and Wormald [16] to d = o( √ n), for the d-regular graph case.On the other hand, asymptotic enumeration for dense d-regular graphs was performed in 1990 by McKay and Wormald [17] for d, n − d ≥ n/ log n, leaving a gap in which no result was known: namely, when min{d, n − d} lies between n 1/2 and n/ log n. This gap was filled recently by Liebenau and Wormald [13]. Uniform generation of graphs with given degrees has an equally long history, and is closely related to asymptotic enumeration. Tinhofer [19] is among the first who investigated algorithmic heuristics, and realised that efficient uniform generation, or approximately uniform generation, is difficult. Graph enumeration arguments can sometimes be adapted to provide algorithms for uniform generation of graphs with given degrees. The proofs in [2,3] immediately yield a simple rejection algorithm, which uniformly generates graphs of degrees at most O( √ log n) in expected polynomial time (polynomial as a function of n). The switching arguments in [14,16] were adapted to give a polynomial-time (in expectation) algorithm [15] for uniformly generating random d-regular graphs when d = O(n 1/3 ). However, overcoming the n 1/3 barrier was extremely challenging, with no progress for more than two decades. A major breakthrough was obtained by Wormald and the first author [8,9], by modifying the McKay-Wormald algorithm [15] to a more flexible form, which allows the use and classification of different types and classes of switchings. This new technique greatly extended the range of degree sequences for which uniform generation is possible. The first application [8,9] of the new technique gave an algorithm for uniform generation of d-regular graphs with expected runtime O(nd 3 ) when d = o( √ n). The second application [10] gave an algorithm for uniform generation of graphs with power-law degree sequences with exponent slightly below 3, with expected runtime O(n 2.107 ) with...