38
40
//to avoid hide some methods
39
41
using DataStructure::remove;
40
using DataStructure::addPointer;
41
using DataStructure::addData;
42
using DataStructure::createPointer;
43
using DataStructure::createData;
43
45
static DataStructurePtr create(Document *parent);
44
46
static DataStructurePtr create(DataStructurePtr other, Document *parent);
55
57
* \param pointerType is the type of this edge, defaults to 0
56
58
* \return the created edge as PointerPtr
58
PointerPtr addPointer(DataPtr from, DataPtr to, int pointerType = 0);
60
PointerPtr createPointer(DataPtr from, DataPtr to, int pointerType);
61
63
* Internal method to create new graph node.
64
66
* \param dataType is the type of this node, defaults to 0
65
67
* \return the created node as DataPtr
67
DataPtr addData(const QString& name, int dataType = 0);
69
DataPtr createData(const QString& name, int dataType);
70
72
* Returns type of the graph given by enum \see GRAPH_TYPE.
101
103
QMap<DataPtr,PointerList> dijkstraShortestPaths(DataPtr from);
106
* Returns a list of all nodes of the graph.
107
* \return array containing the nodes
109
Q_INVOKABLE QScriptValue nodes();
112
* Returns a list of all nodes of given \p type in the graph.
113
* \param type is the overlay for the to created pointer
114
* \return array containing the nodes
116
Q_INVOKABLE QScriptValue nodes(int type);
119
* Returns a list of all edges of the graph.
120
* \return array containing the edges
122
Q_INVOKABLE QScriptValue edges();
125
* Returns a list of all edges of given \p type in the graph.
126
* \param type is the overlay for the to created pointer
127
* \return array containing the edges
129
Q_INVOKABLE QScriptValue edges(int type);
132
* Creates a new data element and return it. If the specified data type is not registered,
133
* no data element is created.
134
* \param type is the data type of the created node
135
* \return script value for the new node
137
Q_INVOKABLE QScriptValue createNode(int type);
140
* Creates a new data element and return it.
141
* \return script value for the new node
143
Q_INVOKABLE QScriptValue createNode();
146
* Creates a new edge edge from \param fromRaw to \param toRaw
147
* of pointer type \param type. If the specified pointer type does not exist, no pointer
149
* \param fromRaw is origin of pointer
150
* \param toRaw is target of pointer
151
* \param overlay is the overlay for the to created pointer
152
* \return script value for the new pointer
154
Q_INVOKABLE QScriptValue createEdge(Data* fromRaw, Data* toRaw, int type);
157
* Creates a new edge from \param fromRaw to \param toRaw.
158
* \param fromRaw is origin of pointer
159
* \param toRaw is target of pointer
160
* \return script value for the new pointer
162
Q_INVOKABLE QScriptValue createEdge(Data* fromRaw, Data* toRaw);
105
167
* Setter for graph type. No conversations are performed.
118
181
* Returns a list of all nodes of given \p type in the graph.
119
182
* \param type is the overlay for the to created pointer
120
183
* \return array containing the nodes
122
186
QScriptValue list_nodes(int type);
125
189
* Returns a list of all edges of the graph.
126
190
* \return array containing the edges
128
193
QScriptValue list_edges();
157
225
* \param toRaw is target of pointer
158
226
* \param overlay is the overlay for the to created pointer
159
227
* \return script value for the new pointer
161
230
QScriptValue add_overlay_edge(Data* fromRaw, Data* toRaw, int overlay);
185
255
* Computes the Dijkstra's shortest path algorithm to compute
186
256
* all shortest path distances from \p from. If edge has value 0, the edge value
187
* is set to 1. Note: this shortest path algorithm works only for graphs with all
188
* edges values non-negative. For undirected graphs reverse edges are add automatically.
257
* is set to 1. Infinity is returned when there is no path
258
* between \p from and another node in the graph. Note: this shortest path
259
* algorithm works only for graphs with all edges values non-negative. For
260
* undirected graphs reverse edges are added automatically.
189
261
* The algorithm has time complexity O(V log V + E).
191
263
* \param from the node from which the computation starts