summaryrefslogtreecommitdiff
path: root/src/data/path.cpp
diff options
context:
space:
mode:
authorGard Spreemann <gspr@nonempty.org>2020-08-20 09:03:17 +0200
committerGard Spreemann <gspr@nonempty.org>2020-08-20 09:03:17 +0200
commit4e1b4e9877732d1e1887674e48312902437f08c5 (patch)
tree7993cbc3ad71eed10da830aca85ef0b99d163bac /src/data/path.cpp
parent99f00a3ef9d1bd2d686b1521d25c9afedb880b34 (diff)
parent300267089b80785551c4721684280efe654ec834 (diff)
Merge tag 'v2.1.6' into debian/sid
Diffstat (limited to 'src/data/path.cpp')
-rw-r--r--src/data/path.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/data/path.cpp b/src/data/path.cpp
new file mode 100644
index 0000000..1438d64
--- /dev/null
+++ b/src/data/path.cpp
@@ -0,0 +1,35 @@
+#include "path.h"
+
+Path::Path(QObject *parent) : QObject(parent)
+{
+
+}
+
+int Path::length() const
+{
+ return _edges.length();
+}
+
+void Path::addEdge(Edge *e)
+{
+ e->setPath(this);
+ _edges << e;
+}
+
+void Path::removeEdges()
+{
+ foreach(Edge *e, _edges) {
+ e->setPath(nullptr);
+ }
+ _edges.clear();
+}
+
+bool Path::isCycle() const
+{
+ return !_edges.isEmpty() && _edges.first()->source() == _edges.last()->target();
+}
+
+QVector<Edge *> Path::edges() const
+{
+ return _edges;
+}