-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGraph.h
51 lines (40 loc) · 984 Bytes
/
Graph.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#pragma once
#include <QPoint>
#include <QList>
class Graph
{
public:
enum NodeState
{
stand = 0,
selected
};
struct AdjacencyListElement
{
int nodeNum;
float weight;
};
struct NodeInfo
{
NodeState state;
QPoint position;
QList<AdjacencyListElement> adjacencyList;
};
private:
QList<NodeInfo> _nodeList;
public:
Graph();
void addNode(QPoint pos, NodeState state = stand);
void removeNode(int nodeNum);
void addEdge(int nodeOut, int nodeIn, float weight);
void removeEdge(int nodeOut, int nodeIn);
QList<AdjacencyListElement> getEdges(int nodeNum);
bool hasEdge(int nodeOut, int nodeIn);
float getWeight(int nodeOut, int nodeIn);
void setPos(QPoint pos, int nodeNum);
QPoint getPos(int nodeNum);
void setState(NodeState state, int nodeNum);
NodeState getState(int nodeNum);
int nodeCount();
int edgeCount(int nodeNum);
};