integeruser / FP-growth

A C++ implementation of the FP-growth algorithm
MIT License
42 stars 22 forks source link

How to visualize the patterns? #6

Closed luisfredgs closed 4 years ago

luisfredgs commented 4 years ago

For example: const std::set patterns = fptree_growth( fptree );

std::cout << patterns

luisfredgs commented 4 years ago

I have found the solution (i'm new in C++):

for ( const Pattern& pattern : patterns) {            

        std::set<Item> item = pattern.first;
        uint64_t frequency = pattern.second;

        std::cout << frequency;

        for (auto it=item.begin(); it != item.end(); ++it)     
        {
            std::cout << " " << *it;
        }        

        std::cout << "\n";
    }

The output is:

8 A 5 A B 3 A B C 2 A B D 4 A C 2 A C D 4 A D 2 A D E 2 A E 7 B 5 B C 2 B C D 3 B D 6 C 3 C D 2 C E 5 D 2 D E 3 E