NeoGraph 0.10.0
A C++17 Graph Agent Engine Library — LangGraph for C++
Loading...
Searching...
No Matches
scheduler.h
Go to the documentation of this file.
1
21#pragma once
22
23#include <neograph/api.h>
25#include <map>
26#include <optional>
27#include <set>
28#include <vector>
29
30namespace neograph::graph {
31
32class GraphState;
33
43 std::string node_name;
44 std::optional<std::string> command_goto;
45};
46
57 std::vector<std::string> ready;
58 bool hit_end = false;
59 std::optional<std::string> winning_command_goto;
60};
61
70using BarrierState = std::map<std::string, std::set<std::string>>;
71
75using BarrierSpecs = std::map<std::string, std::set<std::string>>;
76
87class NEOGRAPH_API Scheduler {
88public:
100 Scheduler(const std::vector<Edge>& edges,
101 const std::vector<ConditionalEdge>& conditional_edges,
102 BarrierSpecs barrier_specs = {});
103
122 std::vector<std::string> resolve_next_nodes(
123 const std::string& current, const GraphState& state) const;
124
130 std::vector<std::string> plan_start_step() const;
131
157 NextStepPlan plan_next_step(const std::vector<StepRouting>& routings,
158 const GraphState& state) const;
159
179 NextStepPlan plan_next_step(const std::vector<std::string>& just_ran,
180 const std::vector<NodeResult>& results,
181 const GraphState& state) const;
182
210 NextStepPlan plan_next_step(const std::vector<StepRouting>& routings,
211 const GraphState& state,
212 BarrierState& barrier_state) const;
213
215 NextStepPlan plan_next_step(const std::vector<std::string>& just_ran,
216 const std::vector<NodeResult>& results,
217 const GraphState& state,
218 BarrierState& barrier_state) const;
219
221 const BarrierSpecs& barrier_specs() const { return barrier_specs_; }
222
223private:
224 const std::vector<Edge>& edges_;
225 const std::vector<ConditionalEdge>& conditional_edges_;
226 BarrierSpecs barrier_specs_;
227};
228
229} // namespace neograph::graph
NEOGRAPH_API export/import macro for shared-library builds.
Thread-safe container for all graph state channels.
Definition state.h:26
Immutable routing oracle for a compiled graph.
Definition scheduler.h:87
NextStepPlan plan_next_step(const std::vector< StepRouting > &routings, const GraphState &state) const
Decide the next ready set from this super-step's routing.
std::vector< std::string > plan_start_step() const
Nodes directly routed from __start__ at step 0.
Scheduler(const std::vector< Edge > &edges, const std::vector< ConditionalEdge > &conditional_edges, BarrierSpecs barrier_specs={})
Bind the scheduler to the graph's edge topology.
std::vector< std::string > resolve_next_nodes(const std::string &current, const GraphState &state) const
Resolve the direct successors of a node.
const BarrierSpecs & barrier_specs() const
Read-only view of declared barriers (mainly for tests).
Definition scheduler.h:221
NextStepPlan plan_next_step(const std::vector< std::string > &just_ran, const std::vector< NodeResult > &results, const GraphState &state) const
Convenience overload: pair up ready[i] with results[i].
NextStepPlan plan_next_step(const std::vector< std::string > &just_ran, const std::vector< NodeResult > &results, const GraphState &state, BarrierState &barrier_state) const
NodeResult-taking barrier-aware overload.
NextStepPlan plan_next_step(const std::vector< StepRouting > &routings, const GraphState &state, BarrierState &barrier_state) const
Barrier-aware planning.
Graph engine type definitions: channels, edges, nodes, events, and control flow.
std::map< std::string, std::set< std::string > > BarrierSpecs
Static barrier declarations extracted at graph-compile time.
Definition scheduler.h:75
std::map< std::string, std::set< std::string > > BarrierState
Per-barrier signal bookkeeping.
Definition scheduler.h:70
Plan for the next super-step.
Definition scheduler.h:56
Per-node routing signal emitted by this super-step.
Definition scheduler.h:42