We model topologically complex solar magnetic fields in the form of magnetic braids and study the evolution of their topology quantified in terms of knot polynomials. As it is not possible to define a single knot polynomial for a complex and volume filling magnetic field, even in the shape of a simple braid, we compute the polynomials for an ensemble of magnetic streamlines, which gives us a distribution. As the magnetic field relaxes and simplifies over time, we observe a distinct change in the distribution from a high probability of complex polynomials to a larger probability of simpler ones.