summaryrefslogtreecommitdiff
path: root/src/data/path.cpp
diff options
context:
space:
mode:
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;
+}