The late-time distribution of matter in the universe is that of a complex pattern commonly called the cosmic web in which massive nodes are linked together by elongated bridges of matter, the filaments, themselves found at the intersections of mildly-dense walls forming the borders of vast and underdense volumes called voids. In a first part of the talk, we build an algorithm aiming at identifying the most prominent feature of the web, its filamentary pattern, based on a discrete distribution of tracers like galaxies. This latter is modelled by a regularised Gaussian mixture model in which a spatial graph is used to represent the underlying one-dimensional structure characterising the filamentary pattern. By iteratively estimating parameters of the model, the algorithm provides a smooth estimate of a graph passing ‘in the middle’ of the galaxy distribution. In a second part of the presentation, we show that the cosmic web environments (filaments but also voids, walls and nodes) can be used to improve the constraints on parameters of the cosmological model over the traditional matter power spectrum. In particular, by breaking some key degeneracies, we report up to an order of magnitude tighter constraints on parameters like the summed neutrino mass and the matter density over the real-space power spectrum in large-scale dark matter simulations from the Quijote suite.