Skip to content

Commit

Permalink
[feat] optimizer trim function
Browse files Browse the repository at this point in the history
  • Loading branch information
ChunelFeng committed Sep 4, 2024
1 parent 91593fe commit a421caa
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 18 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<a href="https://github.com/ChunelFeng/CGraph"><img src="https://badgen.net/badge/os/MacOS,Linux,Windows/cyan?list=1" alt="os"></a>
<a href="https://github.com/ChunelFeng/CGraph/stargazers"><img src="https://badgen.net/github/stars/ChunelFeng/CGraph?color=cyan" alt="stars"></a>
<a href="https://github.com/ChunelFeng/CGraph/network/members"><img src="https://badgen.net/github/forks/ChunelFeng/CGraph?color=cyan" alt="forks"></a>
<a href="https://www.codefactor.io/repository/github/chunelfeng/cgraph/overview/main"><img src="https://www.codefactor.io/repository/github/chunelfeng/cgraph/badge/main" alt="CodeFactor" /></a>
</p>

[![awesome-cpp](https://badgen.net/badge/icon/awesome-cpp/purple?icon=awesome&label&color)](https://github.com/fffaraz/awesome-cpp)
Expand Down Expand Up @@ -39,9 +40,11 @@
* [【B站视频】CGraph 功能篇](https://www.bilibili.com/cheese/play/ss22264) <br>
* 全面介绍CGraph项目中,所有的名词术语和功能模块
* 结合实际coding过程,详细介绍了每个功能的具体的使用场景、用法、以及解决的问题
* 适合想要全面了解功能、或快速上手使用CGraph的童鞋
* 适合想要全面了解功能和快速上手使用CGraph的童鞋
* 适合对多线程编程感兴趣的童鞋
* [【B站视频】CGraph 应用篇](https://www.bilibili.com/video/BV1B84y1D7Hs) <br>
* [【B站视频】CGraph 分享篇](https://www.bilibili.com/video/BV1dh4y1i78u) <br>
* [【B站视频】CGraph 和 taskflow 性能对比实测](https://www.bilibili.com/video/BV1gwWAekEAy/?spm_id_from=333.337.search-card.all.click&vd_source=2c7baed805c6cb33d630d5d4546cf0be) <br>

## 二. 使用Demo

Expand Down
5 changes: 0 additions & 5 deletions src/GraphCtrl/GraphElement/GGroup/GGroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,4 @@ CBool GGroup::isSeparate(GElementCPtr a, GElementCPtr b) const {
return false;
}


CSize GGroup::trim() const {
return 0;
}

CGRAPH_NAMESPACE_END
7 changes: 0 additions & 7 deletions src/GraphCtrl/GraphElement/GGroup/GGroup.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,6 @@ class GGroup : public GElement {
*/
virtual CBool isSeparate(GElementCPtr a, GElementCPtr b) const;

/**
* 剪裁逻辑
* @return
*/
virtual CSize trim() const;

private:
GElementPtrArr group_elements_arr_; // 存放 element的数组

Expand All @@ -77,7 +71,6 @@ class GGroup : public GElement {
friend class GMutable;
template<GMultiConditionType> friend class GMultiCondition;
template<CInt> friend class GSome;
friend class GTrimOptimizer;
};

using GGroupPtr = GGroup *;
Expand Down
3 changes: 2 additions & 1 deletion src/GraphCtrl/GraphElement/GGroup/GRegion/GRegion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ CBool GRegion::isSeparate(GElementCPtr a, GElementCPtr b) const {
}


CSize GRegion::trim() const {
CSize GRegion::trim() {
CGRAPH_ASSERT_INIT_THROW_ERROR(false)
CSize result = 0;
if (manager_) {
result = GTrimOptimizer::trim(manager_->manager_elements_);
Expand Down
8 changes: 6 additions & 2 deletions src/GraphCtrl/GraphElement/GGroup/GRegion/GRegion.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ class GRegion : public GGroup {
*/
GRegion* setGEngineType(GEngineType type);

/**
* 修剪冗余的连边信息
* @return
*/
CSize trim();

protected:
explicit GRegion();
~GRegion() override;
Expand All @@ -44,8 +50,6 @@ class GRegion : public GGroup {

CBool isSeparate(GElementCPtr a, GElementCPtr b) const final;

CSize trim() const override;

private:
GElementManagerPtr manager_ = nullptr; // region 内部通过 manager来管理其中的 element 信息

Expand Down
4 changes: 2 additions & 2 deletions src/GraphCtrl/GraphElement/_GOptimizer/GTrimOptimizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ class GTrimOptimizer : public GOptimizer {
}
}

if (cur->isGGroup()) {
trimNum += ((GGroupPtr)cur)->trim();
if (GElementType::REGION == cur->element_type_) {
trimNum += ((GRegionPtr)cur)->trim();
}
}

Expand Down

0 comments on commit a421caa

Please sign in to comment.