-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGraph.java
More file actions
275 lines (240 loc) · 8.03 KB
/
Copy pathGraph.java
File metadata and controls
275 lines (240 loc) · 8.03 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
import java.util.*;
public class Graph{
// Returns a list of nodes that are incoming to this node. The list is sorted
ArrayList<String> incomingNodes ;
ArrayList<String> outgoingNodes ;
ArrayList<String> outgoingEdgesNames;
ArrayList<Integer> incomingEdges;
ArrayList<Integer> outgoingEdges;
String name , id , type , kind;
int petriNetStyle;
int taskType , cardinality;
int currentTime;
boolean isTimer , isSpecialNode;
// This is called by the constructor to initialize the fields that are used to determine which nodes and edges are valid
Graph(){
incomingNodes = new ArrayList<>();
outgoingNodes = new ArrayList<>();
incomingEdges = new ArrayList<>();
outgoingEdges = new ArrayList<>();
/**
* this list stores the names of edges , this will be used in graphviz for naming the edges (outgoing edges)
*/
outgoingEdgesNames = new ArrayList<>();
name = "";
id = "";
type = "";
petriNetStyle = -1;
/*
* task type means weather its looping task, multiinstance sequenctial or multiinstance parallel or default task
* value assigned are as follows
* default = 0;
* loop =1
* multinstance parallel = 2 (here issequential in not present)
* multinstance sequential = 3 ( here issequential is set to true)
*/
taskType = 0;
cardinality = 0;
/**
* when dealing with timer events we need to make sure non determinism behaviour
*/
isTimer = false;
/**
* this is set to true if the node is constructed for timers , multinstance parallel or sequential or loops structures
*/
isSpecialNode = false;
/**
* this denotes what kind of node we have is it task, event , gateway this is important to avoid the parallel gateway merging condition
*/
kind = "";
/**
* current time helps us to identify if the node is already visited and a backward node for this we have visited variable
* but it can only tell us whether the node is visited or not but we need to maintain a instance (variable ) so that we can
* identify whether it is forward or backward edge
*/
currentTime = -1;
}
public void setTime(int val){
this.currentTime = val;
}
public int getTime(){
return currentTime;
}
public String getKind(){
return this.kind;
}
public void setKind(String val){
this.kind = val;
}
public ArrayList<String> getOutgoingEdgesName(){
return outgoingEdgesNames;
}
public void setOutgoingEdgesName(String str){
this.outgoingEdgesNames.add(str);
}
/**
* Returns the list of incoming nodes. This is used to determine if we are talking to a node, incoming nodes
*/
public ArrayList<String> getIncomingNodes(){
return incomingNodes;
}
/**
* Returns the outgoing nodes. This is a list of node IDs that are reachable from this node in the order they were added
*/
public ArrayList<String> getOutgoingNodes(){
return outgoingNodes;
}
/**
* Sets the incoming node. This is used to determine if a node is the same as another node or not
*
* @param incoming - The name of the node
*/
public void setIncomingNode(String incoming){
this.incomingNodes.add(incoming);
}
/**
* Sets the outgoing nodes. This is used to determine if a node is in the graph or not.
*
* @param outgoing - The outgoing node to add to the graph
*/
public void setOutgoingNodes(String outgoing){
this.outgoingNodes.add(outgoing);
}
// setting incoming edges type which can be direct 1 or message flow -1
/**
* Returns the incoming edges of this edge - weighted digraph. This is a copy of getIncomingEdges
*/
public ArrayList<Integer> getIncomingEdges(){
return incomingEdges;
}
/**
* Returns the outgoing edges of this edge - weighted digraph. This is a copy of the outgoingEdges array
*/
public ArrayList<Integer> getOutgoingEdges(){
return outgoingEdges;
}
/**
* Sets the number of incoming edges. This is used to determine whether or not a node is connected to another node by an edge in the graph.
*
* @param incoming - The number of incoming edges to be connected to the
*/
public void setIncomingEdges(int incoming){
this.incomingEdges.add(incoming);
}
/**
* Sets the number of outgoing edges. This is used to determine whether or not a node is connected to another node by an edge in the graph.
*
* @param outgoing - the number of outgoing edges to be connected to this
*/
public void setOutgoingEdges(int outgoing){
this.outgoingEdges.add(outgoing);
}
/**
* Set the name of the entity. This is used to distinguish entities from other entities that are in the same entity group
*
* @param n - The name of the
*/
public void setName(String n){
this.name = n;
}
/**
* Returns the name of this entity. This is the entity's name in the form of a java. lang. String object.
*
*
* @return the entity's name in the form of a java. lang. String object or null if there is no
*/
public String getName(){
return name;
}
/**
* Sets the type of this node. This is used to determine the type of the node when it is added to the XML document
*
* @param n - The name of the
*/
public void setType(String n){
this.name = n;
}
/**
* Returns the type of this property. This is the name of the property without the namespace. For example " Object " will be converted to " Object ".
*
*
* @return the type of this property as a java. lang. String ( not null ). Note that null is returned if this property has no type
*/
public String getType(){
return name;
}
/**
* Sets the ID of the entity. This is used to distinguish entities that have been created by the client from those that have been deleted by the server.
*
* @param Id - the ID of the entity to be created by the
*/
public void setId(String Id){
this.id = Id;
}
/**
* Returns the id of this message. This is used to distinguish messages from other messages that have the same id.
*
*
* @return the id of this node of graph, this way we can identify it
*/
public String getId(){
return id;
}
/**
* Returns the petri net style of this node.
@return interger values
*/
public int getPetriNetStyle(){
return petriNetStyle;
}
/**
* Set or get the petri net style. Default is 0. See class description for more details.
*
* @param val - The value to set it to ( 0 - 3)
*/
public void setPetriNetStyle(int val){
this.petriNetStyle = val;
}
/**
* Sets the message flow to - 2. This is used to indicate that there is no petri net or basically a message or annotations
*/
public void setMessageFlow(){
this.petriNetStyle = -2;
}
/**
* Sets the task type so that we can make changes accordingly
*/
public void setTaskType(int type){
this.taskType = type;
}
/**
* Return tasktype so that the correct petri net can be mapped
*/
public int getTaskType(){
return taskType;
}
/**
* set the cardinality of multiinstance activity
*/
public void setCardinality(int val){
this.cardinality = val;
}
/**
* Returns the cardinatlity of particular instance
*/
public int getCardinality(){
return cardinality;
}
public void setIsTimerEvent(boolean val){
this.isTimer = val;
}
public boolean getIsTimerEvent(){
return isTimer;
}
public void setIsSpecialNode(){
isSpecialNode = true;
}
public boolean getIsSpecialNode(){
return isSpecialNode;
}
}