def create_edge_dict(edgelist):
    """
    Creates an edge dictionary with the edge `(p, q)` as the key, and weight `w` as the value.
    @param  edgelist -> A list with elements of form `(p, q, w)`
    @return edgedict -> A dictionary with key `(p, q)` and value `w`.
    """
    edgedict             = {}
    for (p, q, w) in edgelist:
        edgedict[(p, q)] = w
    return edgedict