Opinion dynamics using Altafini's model with a time-varying directed graph