Skip to main content

GraphHelpers.h File

Convenience helpers for building simple graphs. More...

Included Headers

#include "graph/GraphSession.h" #include "graph/nodes/PipelineNode.h" #include <memory> #include <string> #include <utility> #include <vector>

Namespaces Index

namespacesimaai
namespaceneat
namespacegraph
namespacehelpers

Description

Convenience helpers for building simple graphs.

File Listing

The file content with the documentation metadata removed is:

1
6#pragma once
7
10
11#include <memory>
12#include <string>
13#include <utility>
14#include <vector>
15
17
18inline NodeId add_pipeline(Graph& g, simaai::neat::NodeGroup group, std::string label = {}) {
19 auto node = std::make_shared<simaai::neat::graph::nodes::PipelineNode>(std::move(group),
20 std::move(label));
21 return g.add(std::move(node));
22}
23
24inline NodeId add_pipeline(Graph& g, std::shared_ptr<simaai::neat::Node> node,
25 std::string label = {}) {
26 auto wrapper =
27 std::make_shared<simaai::neat::graph::nodes::PipelineNode>(std::move(node), std::move(label));
28 return g.add(std::move(wrapper));
29}
30
31inline GraphRun build(Graph g, const GraphRunOptions& opt = {}) {
32 GraphSession session(std::move(g));
33 return session.build(opt);
34}
35
36inline void chain(Graph& g, const std::vector<NodeId>& nodes) {
37 if (nodes.size() < 2)
38 return;
39 for (std::size_t i = 1; i < nodes.size(); ++i) {
40 g.connect(nodes[i - 1], nodes[i]);
41 }
42}
43
44inline void chain(Graph& g, std::initializer_list<NodeId> nodes) {
45 chain(g, std::vector<NodeId>(nodes));
46}
47
48} // namespace simaai::neat::graph::helpers

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.1.