~ubuntu-branches/ubuntu/saucy/rocs/saucy-proposed

« back to all changes in this revision

Viewing changes to RocsCore/DataStructures/Graph/GraphStructure.h

  • Committer: Package Import Robot
  • Author(s): Rohan Garg, Rohan Garg, Philip Muškovac
  • Date: 2013-06-21 02:04:20 UTC
  • mfrom: (1.1.27)
  • Revision ID: package-import@ubuntu.com-20130621020420-lzlui9y7qc6w3xog
Tags: 4:4.10.80-0ubuntu1
[ Rohan Garg ]
* New upstream release

[ Philip Muškovac ]
* Build-depend on libgrantlee-dev and libx11-dev
* Update rocs.install and not-installed 

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
class ROCS_GRAPHSTRUCTURE_EXPORT GraphStructure : public DataStructure
30
30
{
31
31
    Q_OBJECT
 
32
    Q_PROPERTY(QString name READ name WRITE setName)
 
33
 
32
34
public:
33
35
    typedef enum {
34
36
        Graph,
37
39
 
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;
42
44
 
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
57
59
     */
58
 
    PointerPtr addPointer(DataPtr from, DataPtr to, int pointerType = 0);
 
60
    PointerPtr createPointer(DataPtr from, DataPtr to, int pointerType);
59
61
 
60
62
    /**
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
66
68
     */
67
 
    DataPtr addData(const QString& name, int dataType = 0);
 
69
    DataPtr createData(const QString& name, int dataType);
68
70
 
69
71
    /**
70
72
     * Returns type of the graph given by enum \see GRAPH_TYPE.
100
102
     */
101
103
    QMap<DataPtr,PointerList> dijkstraShortestPaths(DataPtr from);
102
104
 
 
105
    /**
 
106
     * Returns a list of all nodes of the graph.
 
107
     * \return array containing the nodes
 
108
     */
 
109
    Q_INVOKABLE QScriptValue nodes();
 
110
 
 
111
    /**
 
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
 
115
     */
 
116
    Q_INVOKABLE QScriptValue nodes(int type);
 
117
 
 
118
    /**
 
119
     * Returns a list of all edges of the graph.
 
120
     * \return array containing the edges
 
121
     */
 
122
    Q_INVOKABLE QScriptValue edges();
 
123
 
 
124
    /**
 
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
 
128
     */
 
129
    Q_INVOKABLE QScriptValue edges(int type);
 
130
 
 
131
    /**
 
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
 
136
     */
 
137
    Q_INVOKABLE QScriptValue createNode(int type);
 
138
 
 
139
    /**
 
140
     * Creates a new data element and return it.
 
141
     * \return script value for the new node
 
142
     */
 
143
    Q_INVOKABLE QScriptValue createNode();
 
144
 
 
145
    /**
 
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
 
148
     * is created.
 
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
 
153
     */
 
154
    Q_INVOKABLE QScriptValue createEdge(Data* fromRaw, Data* toRaw, int type);
 
155
 
 
156
    /**
 
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
 
161
     */
 
162
    Q_INVOKABLE QScriptValue createEdge(Data* fromRaw, Data* toRaw);
 
163
 
 
164
 
103
165
public slots:
104
166
    /**
105
167
     * Setter for graph type. No conversations are performed.
111
173
    /**
112
174
     * Returns a list of all nodes of the graph.
113
175
     * \return array containing the nodes
 
176
     * \deprecated
114
177
     */
115
178
    QScriptValue list_nodes();
116
179
 
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
 
184
     * \deprecated
121
185
     */
122
186
    QScriptValue list_nodes(int type);
123
187
 
124
188
    /**
125
189
     * Returns a list of all edges of the graph.
126
190
     * \return array containing the edges
 
191
     * \deprecated
127
192
     */
128
193
    QScriptValue list_edges();
129
194
 
131
196
     * Returns a list of all edges of given \p type in the graph.
132
197
     * \param type is the overlay for the to created pointer
133
198
     * \return array containing the edges
 
199
     * \deprecated
134
200
     */
135
201
    QScriptValue list_edges(int type);
136
202
 
139
205
     * does not exist an empty array is returned.
140
206
     * \param overlay integer that identifies the overlay
141
207
     * \return QScriptValue array
 
208
     * \deprecated
142
209
     */
143
210
    QScriptValue overlay_edges(int overlay);
144
211
 
146
213
     * Creates a new node with specified \param name.
147
214
     * \param name of the new node
148
215
     * \return script value for the new node
 
216
     * \deprecated
149
217
     */
150
218
    QScriptValue add_node(const QString& name);
151
219
 
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
 
228
     * \deprecated
160
229
     */
161
230
    QScriptValue add_overlay_edge(Data* fromRaw, Data* toRaw, int overlay);
162
231
 
165
234
     * \param fromRaw is origin of pointer
166
235
     * \param toRaw is target of pointer
167
236
     * \return script value for the new pointer
 
237
     * \deprecated
168
238
     */
169
239
    QScriptValue add_edge(Data* fromRaw, Data* toRaw);
170
240
 
184
254
    /**
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).
190
262
     *
191
263
     * \param from the node from which the computation starts