In my algorithm, i will create frequent pattern by DFS method, for example, i generate AA
, AAB
, AABC
, ... in order.(These three patterns are frequent subgraph patterns, A
, B
, C
are nodes, and -
means there exist an edge between two nodes.) If there does not exist any frequent subgraph consist of AA
, we start to generate AB
, ABB
, .... I want to use a DFS tree to store these frequent patterns. But i don't know what is the best method.
The problem i encounter is should i use a *prev pointer to record the pattern in previous level?
// When i generate one frequent pattern, i will call `report`
void report (Projected &projected, unsigned int sup)
{
// i want to store this pattern in a DFS tree which implement with GPattern
}
struct GPattern {
CODE code;
Project project;
vector<GPattern> children; // record all children of this pattern
// should i use a `prev` pointer to record ancestor?
};
I think you should use a prefix tree. take a look here
You're building a graph of GPattern
objects, manually. You're probably better off using Boost::Graph
for that, as it comes with a lot of useful algorithms.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.