New algorithams for the formulation of network matrices applied to the analysis of transient frequency deviations in multi-machine systems