2023-08-28 12:31:18 +02:00
|
|
|
/* A graph vertex.
|
2018-08-21 00:25:44 +02:00
|
|
|
*
|
2023-08-31 11:17:07 +02:00
|
|
|
* Author: Daniel Krebs <github@daniel-krebs.net>
|
|
|
|
* SPDX-FileCopyrightText: 2014-2023 Institute for Automation of Complex Power Systems, RWTH Aachen University
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2023-08-28 12:31:18 +02:00
|
|
|
*/
|
2018-08-21 00:25:44 +02:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
namespace villas {
|
|
|
|
namespace graph {
|
|
|
|
|
|
|
|
class Vertex {
|
2023-09-07 13:19:19 +02:00
|
|
|
template <typename VertexType, typename EdgeType> friend class DirectedGraph;
|
2018-08-21 00:25:44 +02:00
|
|
|
|
|
|
|
public:
|
2023-09-07 13:19:19 +02:00
|
|
|
using Identifier = std::size_t;
|
|
|
|
|
|
|
|
Vertex() : id(0) {}
|
|
|
|
|
|
|
|
const Identifier &getIdentifier() const { return id; }
|
|
|
|
|
|
|
|
friend std::ostream &operator<<(std::ostream &stream, const Vertex &vertex) {
|
|
|
|
return stream << vertex.id;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator==(const Vertex &other) { return this->id == other.id; }
|
|
|
|
|
|
|
|
std::string toString() {
|
|
|
|
std::stringstream ss;
|
|
|
|
ss << *this;
|
|
|
|
return ss.str();
|
|
|
|
}
|
2023-01-10 15:15:20 +01:00
|
|
|
|
2018-08-21 00:25:44 +02:00
|
|
|
private:
|
2023-09-07 13:19:19 +02:00
|
|
|
Identifier id;
|
|
|
|
// HACK: how to resolve this circular type dependency?
|
|
|
|
std::list<std::size_t> edges;
|
2018-08-21 00:25:44 +02:00
|
|
|
};
|
|
|
|
|
2022-12-02 17:16:44 +01:00
|
|
|
} // namespace graph
|
|
|
|
} // namespace villas
|