void BuildLabelsUnion(FArray<FDownload>& DownArray, FLabels& AllLabels, FLabels& CommonLabels) { for (size_t k = 0; k < DownArray.GetCount(); k++) { CopyLabels(AllLabels, DownArray[k].m_Detail.m_Labels); } size_t j = 0; for (size_t k = 0; k < AllLabels.GetItemCount(); k++) { const FString& StrLabel = AllLabels.GetLabelAt(k); for ( j = 0; j < DownArray.GetCount(); j++) { if (!DownArray[j].m_Detail.m_Labels.HasLabel(StrLabel)) break; } if (j == DownArray.GetCount()) { CommonLabels.AddLabel(StrLabel); } } }
// Add a new graph to our PatternMap void PatternMap::Add( Graph*g ) { PatternList_iterator i; Graph_iterator j; // if the map is empty or does not contain this size, add it if ( Patterns.find(g->size()) == Patterns.end() ) { Label(g); // label all the nodes arbitrarily Patterns[g->size()].push_back( GraphList() ); EquivalentCopies[g->size()].push_back( GraphList() ); Patterns[g->size()].back().push_back(g); Graph * g_copy = new Graph; *(g_copy) = *g; Label(g_copy); // label all the nodes arbitrarily EquivalentCopies[g->size()].back().push_back(g_copy); // and also add all equivalent copies AddEquivalentCopies( g, g->GraphNodes.begin()->first, &( EquivalentCopies[g->size()].back() ) ); return; } // otherwise the size exists. Check for the graph in every GraphList of // every Pattern list for this size, and if it is found then the pattern // exists so increment its frequency. // Note this is where the EquivalentCopies GraphList is used: we need to // determine if the pattern of Graph g has been found before, but it could // be that it was found but in a different (equivalent) form // for each GraphList in the vector for ( PatternList_iterator i1 = Patterns[g->size()].begin(), i2 = EquivalentCopies[g->size()].begin(); i1 != Patterns[g->size()].end(); ++i1, ++i2 ) { // for each graph in the GraphList for (Graph_iterator j = i2->begin(); j != i2->end(); ++j) { if ( checkEquality(g, *j) ) { // We have a match, i.e. the 2 graphs are functionally the same, // but not necessarily topologically. To ensure CopyLabels (*j, g); i1->push_back(g); // The labels are consistent, i.e. label "1" always corresponds // to the same add // Copy the labels now then add the graph return; } } } // the pattern has not been found, so add it as above Label(g); // label all the nodes arbitrarily Patterns[g->size()].push_back( GraphList() ); EquivalentCopies[g->size()].push_back( GraphList() ); Patterns[g->size()].back().push_back(g); Graph * g_copy = new Graph; *(g_copy) = *g; Label(g_copy); // label all the nodes arbitrarily EquivalentCopies[g->size()].back().push_back(g_copy); // and also add all equivalent copies AddEquivalentCopies( g, g->GraphNodes.begin()->first, &( EquivalentCopies[g->size()].back() ) ); }