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
19inline NodeId add_pipeline(Graph& g, simaai::neat::NodeGroup group, std::string label = {}) {
20 auto node = std::make_shared<simaai::neat::graph::nodes::PipelineNode>(std::move(group),
21 std::move(label));
22 return g.add(std::move(node));
23}
24
26inline NodeId add_pipeline(Graph& g, std::shared_ptr<simaai::neat::Node> node,
27 std::string label = {}) {
28 auto wrapper =
29 std::make_shared<simaai::neat::graph::nodes::PipelineNode>(std::move(node), std::move(label));
30 return g.add(std::move(wrapper));
31}
32
34inline GraphRun build(Graph g, const GraphRunOptions& opt = {}) {
35 GraphSession session(std::move(g));
36 return session.build(opt);
37}
38
40inline void chain(Graph& g, const std::vector<NodeId>& nodes) {
41 if (nodes.size() < 2)
42 return;
43 for (std::size_t i = 1; i < nodes.size(); ++i) {
44 g.connect(nodes[i - 1], nodes[i]);
45 }
46}
47
49inline void chain(Graph& g, std::initializer_list<NodeId> nodes) {
50 chain(g, std::vector<NodeId>(nodes));
51}
52
53} // namespace simaai::neat::graph::helpers

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.8.