简体   繁体   English

如果我在DFS方法中生成频繁模式,如何构建DFS树?

[英]How to build a DFS tree if i generate frequent pattern in a DFS method?

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. 在我的算法中,我将通过DFS方法创建频繁模式,例如,我依次生成AAAABAABC ,...(这三个模式是频繁子图模式, ABC是节点,并且-如果不存在任何由AA组成的频繁子图,则开始生成ABABB ,...。我想使用DFS树存储这些频繁模式。 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? 我遇到的问题是我应该使用* prev指针记录上一级的模式吗?

// 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. 您正在手动构建GPattern对象图。 You're probably better off using Boost::Graph for that, as it comes with a lot of useful algorithms. 使用Boost::Graph可能会更好,因为它附带了许多有用的算法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM