Graph.h File
Hybrid graph DAG with port interning (STL-only). More...
Included Headers
#include "graph/GraphTypes.h"
#include "graph/Node.h"
#include <cstddef>
#include <memory>
#include <queue>
#include <stdexcept>
#include <string>
#include <string_view>
#include <unordered_map>
#include <utility>
#include <vector>
Namespaces Index
| namespace | simaai |
| namespace | neat |
| namespace | graph |
Classes Index
| class | Graph |
|
Directed acyclic graph of hybrid nodes with named ports. More... | |
Description
Hybrid graph DAG with port interning (STL-only).
File Listing
The file content with the documentation metadata removed is:
8#include "graph/GraphTypes.h"
9#include "graph/Node.h"
21namespace simaai::neat::graph {
34 if (!node) {
37 const NodeId id = nodes_.size();
38 nodes_.push_back(std::move(node));
49 std::size_t node_count() const noexcept {
57 PortId intern_port(std::string_view name) {
78 std::size_t port_count() const noexcept {
82 const std::vector<std::string>& port_names() const noexcept {
94 const PortId f = intern_port(from_port);
95 const PortId t = intern_port(to_port);
127 std::size_t out_degree(NodeId id) const {
138 std::vector<NodeId> topo_order() const {
141 for (NodeId i = 0; i < n; ++i)
145 for (NodeId i = 0; i < n; ++i) {
154 NodeId u = q.front();
159 const Edge& e = edges_[eidx];
160 if (indeg[e.to] == 0) {
163 indeg[e.to]--;
164 if (indeg[e.to] == 0)
165 q.push(e.to);
177 (void)topo_order();
185 void validate_id_(NodeId id, const char* where) const {
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.1.