def updateJunctions(junctions, lineMap):
    """
    Look through all {@link Junction}s. If either of the lines has been merged, the Junction is updated to reference the merged line. Returns the set of all such modified Junctions
    :param junctions:
    :param lineMap: it is a dict. key,value are Line
    :return:
    """
    updated = set()
    for junction in junctions:
        toUpdate = False
        mergedLine = lineMap.get(junction.lineCont1)
        if mergedLine is not None:
            toUpdate = True
            junction.lineCont1 = mergedLine
            junction.cont1 = mergedLine.getID()
        mergedLine = lineMap.get(junction.lineCont2)
        if mergedLine is not None:
            junction.lineCont2 = mergedLine
            junction.cont2 = mergedLine.getID()
            toUpdate = True
        if toUpdate is True:
            updated.add(junction)
    return updated
