def get_back_prop_dependencies(net, wire):
    """Given a wire in a neural network, returns a set of inputs, neurons, and
    Wires whose outputs/values are required to update this wire's weight."""

    finalSet = set()
    agenda = [wire.endNode]
    while agenda:
        outgoing = net.get_outgoing_neighbors(agenda[0])
        neuron = agenda.pop(0)
        finalSet.add(neuron)
        if net.is_output_neuron(neuron):
            finalSet.add(wire)
            finalSet.add(wire.startNode)
        else:
            for n in outgoing:
                agenda.append(n)
                newWire = net.get_wires(neuron, n)[0]
                finalSet.add(newWire)
                finalSet.add(n)
    return finalSet