A Methodology for Redesigning Networks by Using Markov Random Fields. Mathematics 2021, 9, 1389