OpenTwin 0.1
OpenTwin
 
Loading...
Searching...
No Matches
Graph.h
Go to the documentation of this file.
1#pragma once
2#include "GraphNode.h"
3
4#include <list>
5#include <vector>
6#include <memory>
7
8class Graph
9{
10public:
11
12 std::shared_ptr<GraphNode> addNode();
13 std::shared_ptr<GraphNode> getNode(int nodeID);
14 const std::list<std::shared_ptr<GraphNode>> getContainedNodes() const { return _nodes; };
15 const bool hasCycles(const std::shared_ptr<GraphNode> startNode) const; //Depth first search
16
17protected:
18 int _counter = 0;
19 std::list<std::shared_ptr<GraphNode>> _nodes;
20
21 bool TraverseNodesUntilCycle(const std::shared_ptr<GraphNode> node, std::vector<bool>& visited, std::vector<bool>& recursiveStack) const;
22};
Definition Graph.h:9
std::list< std::shared_ptr< GraphNode > > _nodes
Definition Graph.h:19
std::shared_ptr< GraphNode > addNode()
Definition Graph.cpp:5
const bool hasCycles(const std::shared_ptr< GraphNode > startNode) const
Definition Graph.cpp:24
std::shared_ptr< GraphNode > getNode(int nodeID)
Definition Graph.cpp:12
int _counter
Definition Graph.h:18
bool TraverseNodesUntilCycle(const std::shared_ptr< GraphNode > node, std::vector< bool > &visited, std::vector< bool > &recursiveStack) const
Definition Graph.cpp:34
const std::list< std::shared_ptr< GraphNode > > getContainedNodes() const
Definition Graph.h:14