To solve the consensus problem associated with multi-agent systems under Markovian switching topologies in which the union of switching topologies is an arbitrary network structure, we propose a construction method for any network structure. We also design a consensus protocol for the constructed network to solve the problem of leader-follower consensus for time-varying nonlinear multi-agent systems. First, by introducing a virtual leader node that connects with the minimum number of leaders in the union of switching topologies, we construct an arbitrary network structure so that the constructed network topology includes a directed spanning tree. Next, we design a consensus protocol with dynamic gain, and introduce consensus errors and state transitions to transform the system consensus problem into a design based on time-varying parameters. Based on Lyapunov's stability theory, we analyze the stability of time-varying nonlinear multi-agent systems under Markovian switching topologies. The results of simulation examples demonstrate the validity of the theoretical results.