It changes when there is a new blood relationship. So from you to great-grandfather is blood-related, then a marriage, then another blood relationship (in yellow) until the next marriage breaks the cord (so to speak), and it's back to green.
So, on my "connection" to John Monash - it goes 5 generations green, including a sibling relationship on the same generation, then to the husband of my 2-greats-grandfather's sister, then his daughter, then her brother - in yellow, then his wife, her brother etc in green, until the next break back to yellow.