I have a set $X$ that is acted on by $S_n$, and I've written some code that takes an input object $x\in X$ and finds the set $G\subseteq S_n$ of all permutations that fix $x$, essentially by brute force. The result is just a list of all the elements of $G$, and I would like to display the group in a more concise way, I guess as a minimum-size (or at least minimal) generating set for $G$. Is there an efficient way to obtain such a generating set?
The approach I can think of is: Pick elements of $G$ in some arbitrary order and maintain a set $H$ of all the permutations generated by the elements picked so far. Whenever we pick an element that is not already in $H$, add it to our generating set and grow $H$, and stop when $H=G$. But this feels slow (worse than linear-time in $|G|$, at least) and doesn't guarantee a minimal generating set (as we might pick $gh$ before $g$ and $h$, for example).