MCPcopy Create free account
hub / github.com/ChunelFeng/CGraph / tutorial_trim

Function tutorial_trim

tutorial/T27-Trim.cpp:14–35  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12using namespace CGraph;
13
14void tutorial_trim() {
15 GPipelinePtr pipeline = GPipelineFactory::create();
16 GElementPtr a, b, c, d = nullptr;
17
18 pipeline->registerGElement<MyNode1>(&a, {}, "nodeA");
19 pipeline->registerGElement<MyNode2>(&b, {a}, "nodeB");
20 pipeline->registerGElement<MyNode1>(&c, {a}, "nodeC");
21
22 /**
23 * 可以看出,d节点 对a 的依赖,是可有可无的
24 * 建议通过 trim() 接口删除冗余依赖
25 * 参考文档:http://www.chunel.cn/archives/cgraph-remove-redundancy-link
26 */
27 pipeline->registerGElement<MyNode2>(&d, {a, b, c}, "nodeD");
28
29 auto trimSize = pipeline->trim();
30 CGRAPH_ECHO("trim size is: %d", (int)trimSize);
31
32 // 查看 trim后的效果
33 pipeline->dump();
34 GPipelineFactory::remove(pipeline);
35}
36
37
38int main() {

Callers 1

mainFunction · 0.70

Calls 5

createFunction · 0.85
CGRAPH_ECHOFunction · 0.85
removeFunction · 0.85
trimMethod · 0.45
dumpMethod · 0.45

Tested by

no test coverage detected