Your task is to construct an undirected graph that has exactly different spanning trees.
The graph should have the nodes , with the number of nodes at most . 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 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 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 . 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)]