You can use "conncomp" in Matlab2016a and later versions.
BINS = conncomp(G) computes the connected components of graph G.BINS(i) gives the number of the component that contains node i. Two nodes belong to the same component if there is a path connecting them.
If node i is isolated then BINS(i) will be unique in the BINS, which can be used for islanding detection. You can also use tabulate(BINS) to see overall situation of islands in the graph.
Example:
%Create and plot a graph. Compute its connected components.
s = [1 2 2 3 3 3 4 5 5 8 8];
t = [2 3 4 1 4 5 5 6 7 9 10];
G = graph(s,t);
plot(G,'Layout','layered');
bins = conncomp(G);
max(bins) will return the number of islands. In this example, the number of islands is 2.
Try PSAT custom package for Matlab. There you have many components of electrical network that might help you in designing model of your choice. fastest and most efficient method might be monitoring reactive energy and deciding on its behavior is generator in islanding operation mode.