<commit_before>#include "../inc/SpanningTree.hpp"

SpanningTree::SpanningTree(){}

SpanningTree::SpanningTree(const Bridge& r):root(r){
}

SpanningTree::SpanningTree(const Bridge& r, std::vector<SpanningTree> c): root(r), children(c){
}

SpanningTree::SpanningTree(const SpanningTree& other):root(other.root), children(other.children){
}

SpanningTree::~SpanningTree(){
}

SpanningTree operator+(const SpanningTree& lhs, const SpanningTree& rhs){
    if(lhs == rhs){
        return SpanningTree(lhs);
    }

    assert(lhs.root == rhs.root);
    SpanningTree ret = SpanningTree(lhs.root);

    //add all similar children
    for(SpanningTree leftChild : lhs.children){
        for(SpanningTree rightChild : rhs.children){
            //if they have the same root, add the combination
            if(leftChild.root == rightChild.root){
                //should the case occur that we make a wrong assumption and add a node with the wrong message age (due to wrong path assumptions)
                //AND we have this node again (with correct message age, which will be higher)
                //this function SHOULD move down far enough to hit this case with the two nodes
                //after combining them we can update the message age to the higher age
                //TODO: look over this when i'm not tired and delirious
                SpanningTree newTree = leftChild + rightChild;
                newTree.root.setMessageAge(std::max(leftChild.root.getMessageAge(), rightChild.root.getMessageAge()));
                ret.addChild(newTree);
                break;
            }

            //if rightChild is contained in left (additions "downstream"), add it there
            if(leftChild.containsRoot(rightChild)){
                SpanningTree combined = SpanningTree(leftChild);
                leftChild.addSubTree(rightChild);
                ret.addChild(combined);
            }
            
            //vice versa
            if(rightChild.containsRoot(leftChild)){<commit_msg>rewrote some commentary<commit_after>#include "../inc/SpanningTree.hpp"

SpanningTree::SpanningTree(){}

SpanningTree::SpanningTree(const Bridge& r):root(r){
}

SpanningTree::SpanningTree(const Bridge& r, std::vector<SpanningTree> c): root(r), children(c){
}

SpanningTree::SpanningTree(const SpanningTree& other):root(other.root), children(other.children){
}

SpanningTree::~SpanningTree(){
}

SpanningTree operator+(const SpanningTree& lhs, const SpanningTree& rhs){
    if(lhs == rhs){
        return SpanningTree(lhs);
    }

    assert(lhs.root == rhs.root);
    SpanningTree ret = SpanningTree(lhs.root);

    //add all similar children
    for(SpanningTree leftChild : lhs.children){
        for(SpanningTree rightChild : rhs.children){
            //if they have the same root, add the combination
            if(leftChild.root == rightChild.root){
                //should we make an incorrect assumption, set the message age to the higher one.
                //this should not be needed, as this should be filtered in the server.
                SpanningTree newTree = leftChild + rightChild;
                newTree.root.setMessageAge(std::max(leftChild.root.getMessageAge(), rightChild.root.getMessageAge()));
                ret.addChild(newTree);
                break;
            }

            //if rightChild is contained in left (additions "downstream"), add it there
            if(leftChild.containsRoot(rightChild)){
                SpanningTree combined = SpanningTree(leftChild);
                leftChild.addSubTree(rightChild);
                ret.addChild(combined);
            }
            
            //vice versa
            if(rightChild.containsRoot(leftChild)){
{'fraction_non_alphanumeric': 0.10302866414277988, 'fraction_numerical': 0.0, 'mean_word_length': 2.5704633204633205, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '2089987', 'n_tokens_mistral': 1022, 'n_tokens_neox': 987, 'n_words': 270}