@Override
    public void send() {
        
        //first an empty message is sent to each port. If the node sends another
        //message, the empty message will be overwritten
        sendAll(" ");
        
        if(stopped){
            return;
        }
        
        if(round % 2 == 0){
            
            if("white".equals(super.input)){
                if(matched){
                    sendAll("matched");
                    stopped = true;
                }
                else if(round/2 >= degree()){
                    stopped = true;
                    setOutput(-1);
                            
                }
                else{
                    sendMessage("proposal", round/2);
                }
            }
        }
        else{
            if("black".equals(super.input)){
                if(allNeighboursMatched()){
                    stopped = true;
                    setOutput(-1);
                }
                for (int i = 0; i < degree(); i++) {
                    if(proposals[i]){
                        sendMessage("accept", i);
                        stopped = true;
                        setOutput(i);
                        break;
                    }
                }
            }
        }
        
    }