def loadGraph(name):
    """Load a graph in the DIMACS ascii format from
       the file "name" and return it as a list of sets"""

    V = 0
    E = 0
    G = []

    f = open(name, "r")
    lines = f.readlines()
    for l in lines:
        s = l.split()
        if len(s) < 1:
            continue
        if s[0] == "c":
            continue
        elif s[0] == "p":
            V = int(s[2]) + 1
            E = int(s[3])
            G = [set() for x in range(V)]
        elif s[0] == "e":
            (x, y) = (int(s[1]), int(s[2]))
            G[x].add(y)
            G[y].add(x)

    f.close()
    return G