def get_edgeVal(G, n1, n2, weightParameter):
    """
    Helper function to obtain the weight of the edge between two nodes, with exception handling, returns 0 if no edge is found
    """
    if weightParameter:
        try:
            valDict = G.edges[n1, n2]
        except KeyError:
            return 0
        else:
            return valDict[weightParameter]
    else:
        return 1
