Many real-world networks exhibit correlations between the node degrees. For instance, in social networks nodes tend to connect to nodes of similar degree and conversely, in biological and technological networks, high-degree nodes tend to be linked with low-degree nodes. Degree correlations also affect the dynamics of processes supported by a network structure, such as the spread of opinions or epidemics. The proper modelling of these systems, i.e., without uncontrolled biases, requires the sampling of networks with a specified set of constraints. We present a solution to the sampling problem when the constraints imposed are the degree correlations. In particular, we develop an exact method to construct and sample graphs with a specified joint-degree matrix, which is a matrix providing the number of edges between all the sets of nodes of a given degree, for all degrees, thus completely specifying all pairwise degree correlations, and additionally, the degree sequence itself. Our algorithm always produces independent samples without backtracking. The complexity of the graph construction algorithm is NMwhere N is the number of nodes and M is the number of edges.where d i − denotes the in-degree, and d i + the out-degree, of node i. The situation of most practical interest is when we demand the graph with a given degree sequence to be a simple graph, which has the additional constraints that there can be at most one link (in each direction, if directed) between any two nodes, and that no link starts and ends on the same node (no self-loops). However, not all positive integer sequences can serve as the sequence of the degrees of some simple graph. If such a graph does exist, then the sequence is said to be graphical. Any simple graph (just 'graph' from here on) with the prescribed node degrees is said to realize the degree sequence, and it is called a graphical realization of the sequence. The two main results used to test the graphicality of an undirected degree sequence are the Erdős-Gallai theorem [5] and the Havel-Hakimi theorem [6,7]. For directed networks, instead, the main theorem characterizing the graphicality of a BDS is due to Fulkerson [8]. More recently, exploiting a formulation based on recurrence relations, new methods were introduced to implement these tests with a worst case computational complexity that is only linear in the number of nodes [9][10][11]. The advantage of these methods over others with similar complexity [12] is that they also allow a straightforward algorithmic implementation.While the above results provide complete and practical answers to the question of the graphicality of sequences of integers, they do not suffice to solve the problem of constructing graphs with prescribed degrees. One of the main issues with constructing graphs for the purpose of ensemble modeling is that, except for networks of just a few nodes, the number of graphs realizing a degree sequence, or other possible constraints, is generally so large that their complete enumeration is impractical. Therefore, one has...