<commit_before>#ifndef LOCALEDGEPRIORITY_H
#define LOCALEDGEPRIORITY_H

#include "EdgePriority.h"
#include "../Algorithms/RagAlgs.h"
#include <iostream>
#include <json/value.h>
#include <set>
#include <queue>
#include <cmath>


// ??!!allow undo when no real mode change 
// ??!!keep body the same?! 
// Don -- rav fix: export rag,  does config labels save?, clear undo queue on change, start session bugs


using std::cout; using std::endl;
namespace NeuroProof {

template <typename Region>
class LocalEdgePriority : public EdgePriority<Region> {
  public:
    typedef boost::tuple<Region, Region> NodePair;
    typedef boost::tuple<unsigned int, unsigned int, unsigned int> Location;

    LocalEdgePriority(Rag<Region>& rag_, double min_val_, double max_val_, double start_val_, Json::Value& json_vals); 
    void export_json(Json::Value& json_writer);

    void set_synapse_mode(double ignore_size_)
    {
        Rag<Region>& ragtemp = (EdgePriority<Region>::rag);
        reinitialize_scheduler();

        synapse_mode = true;
        ignore_size_orig = ignore_size_;        
        if (body_list) {
            delete body_list;
        } 
        body_list = new BodyRankList(ragtemp, already_analyzed_list);

        for (typename Rag<Region>::nodes_iterator iter = ragtemp.nodes_begin(); iter != ragtemp.nodes_end(); ++iter) {
            unsigned long long synapse_weight = 0;
            try {   
                synapse_weight = property_list_retrieve_template_property<Region, unsigned long long>(synapse_weight_list, (*iter));
            } catch(...) {
                continue;
            }
            volume_size += synapse_weight;
            BodyRank body_rank;
            body_rank.id = (*iter)->get_node_id();
            body_rank.size = synapse_weight;
            body_list->insert(body_rank);
        }

        ignore_size = voi_change(ignore_size_orig, ignore_size_orig, volume_size);
        updatePriority();
        estimateWork();
    }

    // depth currently not set
    void set_body_mode(double ignore_size_, int depth)
    {
        Rag<Region>& ragtemp = (EdgePriority<Region>::rag);
        reinitialize_scheduler();

        ignore_size_orig = ignore_size_;        
        if (body_list) {
            delete body_list;
        } 
        body_list = new BodyRankList(ragtemp, already_analyzed_list);
        
        volume_size = get_rag_size(&ragtemp);
        ignore_size = voi_change(approx_neurite_size, ignore_size_orig, volume_size);

        for (typename Rag<Region>::nodes_iterator iter = ragtemp.nodes_begin(); iter != ragtemp.nodes_end(); ++iter) {
            if ((*iter)->get_size() >= ignore_size_orig) {
                BodyRank body_rank;
                body_rank.id = (*iter)->get_node_id();
                body_rank.size = (*iter)->get_size();
                body_list->insert(body_rank);
            }        
        }

        updatePriority();
        estimateWork();
    }

    // synapse orphan currently not used
    void set_orphan_mode(double ignore_size_, double threshold, bool synapse_orphan)
    {
        Rag<Region>& ragtemp = (EdgePriority<Region>::rag);
        reinitialize_scheduler();
        orphan_mode = true;
        min_val = 1.0 - threshold;
        max_val = threshold;
        start_val = min_val;

        ignore_size = ignore_size_;
        ignore_size_orig = ignore_size_;        
        if (body_list) {
            delete body_list;
        } 
        body_list = new BodyRankList(ragtemp, already_analyzed_list);
        
        for (typename Rag<Region>::nodes_iterator iter = ragtemp.nodes_begin(); iter != ragtemp.nodes_end(); ++iter) {
            bool is_orphan = false;
            try { 
                is_orphan =  property_list_retrieve_template_property<Region, bool>(orphan_property_list, (*iter));
            } catch(...) {
                //
            }

            if (is_orphan) {
                BodyRank body_rank;
                body_rank.id = (*iter)->get_node_id();
                body_rank.size = (*iter)->get_size();
                body_list->insert(body_rank);
            }        
        }

        updatePriority();
        estimateWork();
    }

    // synapse orphan currently not used
    void set_edge_mode(double lower, double upper, double start)
    {
        reinitialize_scheduler();
        prob_mode = true;
        min_val = lower;
        max_val = upper;
        start_val = start;

        if (body_list) {
            delete body_list;
        }
        body_list = 0; 
        
        updatePriority();
        estimateWork();
    }

    void estimateWork()
    {
        Rag<Region>& ragtemp = (EdgePriority<Region>::rag);
        num_processed = 0;
        num_est_remaining = 0;
        
        //srand(1); 
        int num_edges = 0;<commit_msg>ignore size default set for edge<commit_after>#ifndef LOCALEDGEPRIORITY_H
#define LOCALEDGEPRIORITY_H

#include "EdgePriority.h"
#include "../Algorithms/RagAlgs.h"
#include <iostream>
#include <json/value.h>
#include <set>
#include <queue>
#include <cmath>


// ??!!allow undo when no real mode change 
// ??!!keep body the same?! 
// Don -- rav fix: export rag,  does config labels save?, clear undo queue on change, start session bugs


using std::cout; using std::endl;
namespace NeuroProof {

template <typename Region>
class LocalEdgePriority : public EdgePriority<Region> {
  public:
    typedef boost::tuple<Region, Region> NodePair;
    typedef boost::tuple<unsigned int, unsigned int, unsigned int> Location;

    LocalEdgePriority(Rag<Region>& rag_, double min_val_, double max_val_, double start_val_, Json::Value& json_vals); 
    void export_json(Json::Value& json_writer);

    void set_synapse_mode(double ignore_size_)
    {
        Rag<Region>& ragtemp = (EdgePriority<Region>::rag);
        reinitialize_scheduler();

        synapse_mode = true;
        ignore_size_orig = ignore_size_;        
        if (body_list) {
            delete body_list;
        } 
        body_list = new BodyRankList(ragtemp, already_analyzed_list);

        for (typename Rag<Region>::nodes_iterator iter = ragtemp.nodes_begin(); iter != ragtemp.nodes_end(); ++iter) {
            unsigned long long synapse_weight = 0;
            try {   
                synapse_weight = property_list_retrieve_template_property<Region, unsigned long long>(synapse_weight_list, (*iter));
            } catch(...) {
                continue;
            }
            volume_size += synapse_weight;
            BodyRank body_rank;
            body_rank.id = (*iter)->get_node_id();
            body_rank.size = synapse_weight;
            body_list->insert(body_rank);
        }

        ignore_size = voi_change(ignore_size_orig, ignore_size_orig, volume_size);
        updatePriority();
        estimateWork();
    }

    // depth currently not set
    void set_body_mode(double ignore_size_, int depth)
    {
        Rag<Region>& ragtemp = (EdgePriority<Region>::rag);
        reinitialize_scheduler();

        ignore_size_orig = ignore_size_;        
        if (body_list) {
            delete body_list;
        } 
        body_list = new BodyRankList(ragtemp, already_analyzed_list);
        
        volume_size = get_rag_size(&ragtemp);
        ignore_size = voi_change(approx_neurite_size, ignore_size_orig, volume_size);

        for (typename Rag<Region>::nodes_iterator iter = ragtemp.nodes_begin(); iter != ragtemp.nodes_end(); ++iter) {
            if ((*iter)->get_size() >= ignore_size_orig) {
                BodyRank body_rank;
                body_rank.id = (*iter)->get_node_id();
                body_rank.size = (*iter)->get_size();
                body_list->insert(body_rank);
            }        
        }

        updatePriority();
        estimateWork();
    }

    // synapse orphan currently not used
    void set_orphan_mode(double ignore_size_, double threshold, bool synapse_orphan)
    {
        Rag<Region>& ragtemp = (EdgePriority<Region>::rag);
        reinitialize_scheduler();
        orphan_mode = true;
        min_val = 1.0 - threshold;
        max_val = threshold;
        start_val = min_val;

        ignore_size = ignore_size_;
        ignore_size_orig = ignore_size_;        
        if (body_list) {
            delete body_list;
        } 
        body_list = new BodyRankList(ragtemp, already_analyzed_list);
        
        for (typename Rag<Region>::nodes_iterator iter = ragtemp.nodes_begin(); iter != ragtemp.nodes_end(); ++iter) {
            bool is_orphan = false;
            try { 
                is_orphan =  property_list_retrieve_template_property<Region, bool>(orphan_property_list, (*iter));
            } catch(...) {
                //
            }

            if (is_orphan) {
                BodyRank body_rank;
                body_rank.id = (*iter)->get_node_id();
                body_rank.size = (*iter)->get_size();
                body_list->insert(body_rank);
            }        
        }

        updatePriority();
        estimateWork();
    }

    // synapse orphan currently not used
    void set_edge_mode(double lower, double upper, double start)
    {
        reinitialize_scheduler();
        prob_mode = true;
        min_val = lower;
        max_val = upper;
        start_val = start;
        ignore_size = 27;
        ignore_size_orig = ignore_size;

        if (body_list) {
            delete body_list;
        }
        body_list = 0; 
        
        updatePriority();
        estimateWork();
    }

    void estimateWork()
    {
        Rag<Region>& ragtemp = (EdgePriority<Region>::rag);
        num_processed = 0;
        num_est_remaining = 0;
        
        //srand(1); 
        int num_edges = 0;
{'fraction_non_alphanumeric': 0.10493763529533037, 'fraction_numerical': 0.0018554788166168436, 'mean_word_length': 2.1685173089484, 'pattern_counts': {'":': 0, '<': 49, '<?xml version=': 0, '>': 69, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6172863', 'n_tokens_mistral': 2868, 'n_tokens_neox': 2768, 'n_words': 602}