I managed to determine the equation of my algorithm, which generates a graph and I tested it it works well, but I don't know how to determine the time and space complexity of it based on this formula: $$ \sum_{i=1}^{n}\frac{n!}{(n-i)!} $$ with $1\leq n\leq 8$
This formula calculates the number of edges of the graph according to the input $n$.