givenのような異種間接続のプログラムを書いてください
def connect(node1, node2):
    # 1-level connections
    # Create edges between the given nodes
    node1.edges.append(node2)
    node2.edges.append(node1)
 
    # Recursively build up connections
    for e1 in node1.edges:
        for e2 in node2.edges:
            if e1 != e2:
                connect(e1, e2)