Many real-world networks of interest are embedded in physical space. We present a new random graph model aiming to reflect the interplay between the geometries of the graph and of the underlying space. The model favors configurations with small average graph distance between vertices, but adding an edge comes at a cost measured according to the geometry of the ambient physical space. In most cases, we identify the order of magnitude of the average graph distance as a function of the parameters of the model. As the proofs reveal, hierarchical structures naturally emerge from our simple modeling assumptions. Moreover, a critical regime exhibits an infinite number of discontinuous phase transitions.</p