  We present an algorithmic framework for the identification of candidate
invariant subspaces for switched linear systems. Namely, the framework allows
to compute an orthonormal basis in which the matrices of the system are close
to block-triangular matrices, based on a finite set of observed one-step
trajectories and with a priori confidence level. The link between the existence
of an invariant subspace and a common block-triangularization of the system
matrices is well known. Under some assumptions on the system, one can also
infer the existence of an invariant subspace when the matrices are close to be
block-triangular. Our approach relies on quadratic Lyapunov analysis and recent
tools in scenario optimization. We present two applications of our results for
problems of consensus and opinion dynamics; the first one allows to identify
the disconnected components in a switching hidden network, while the second one
identifies the stationary opinion vector of a switching gossip process with
antagonistic interactions.
