CSES - Spanning trees

Your task is to construct an undirected graph that has exactly xx different spanning trees.

The graph should have the nodes 1,2,,n1,2,\dots,n, with the number of nodes nn at most 4040. The graph may not have two identical edges, and each edge should connect two different nodes.

In a file spanning.py, implement the function create_edges that constructs the desired graph. The function should return the graph as a list of edges. The number of nodes nn is the largest node number that occurs on the edge list.

For example, the list [(1, 2), (2, 3), (1, 3)] means a graph with n=3n=3 nodes and an edge for every pair of two nodes. This graph has three spanning trees, because any set of two edges is a spanning tree.

You may construct any graph with the specified properties. The function will be tested with the parameter values x=1,2,,42x=1,2,\dots,42. If a desired graph cannot be constructed, the function should return None.

def create_edges(x):
    # TODO

if __name__ == "__main__":
    print(create_edges(1)) # esim. [(1, 2), (2, 3)]
    print(create_edges(2)) # None
    print(create_edges(3)) # esim. [(1, 2), (1, 3), (2, 3)]