// first clone the whole graph
Vector<ScheduleNode> newscheduleGraph =
cloneScheduleGraph(scheduleGraph, lgid);
+
+ if(newscheduleGraph.size() == 0) {
+ System.err.println("empty schedule graph!");
+ return optimizeschedulegraphs;
+ }
// these nodes are root nodes
Vector<ScheduleNode> roots = new Vector<ScheduleNode>();
}
}
cGen.clear();
+ for(int i = 0; i < rootNodes.size(); i++) {
+ if(rootNodes.elementAt(i) != null) {
+ rootNodes.elementAt(i).clear();
+ }
+ }
rootNodes = null;
+ for(int i = 0; i < nodes2combine.size(); i++) {
+ if(nodes2combine.elementAt(i) != null) {
+ nodes2combine.elementAt(i).clear();
+ }
+ }
nodes2combine = null;
for(int j = 0; j < newscheduleGraph.size(); j++) {
ScheduleNode snode = newscheduleGraph.elementAt(j);
for(index = 0; index < sNodeVecs.size(); index++) {
if(sNodeVecs.elementAt(index).elementAt(0).getCid() > tmpcid) {
// find the place to insert
- sNodeVecs.add(sNodeVecs.lastElement());
+ sNodeVecs.insertElementAt(new Vector<ScheduleNode>(), index);
+ /*sNodeVecs.add(sNodeVecs.lastElement());
for(int j = sNodeVecs.size() - 2; j > index; j--) {
sNodeVecs.setElementAt(sNodeVecs.elementAt(j - 1), j);
}
- sNodeVecs.setElementAt(new Vector<ScheduleNode>(), index);
+ sNodeVecs.setElementAt(new Vector<ScheduleNode>(), index);*/
+ break;
} else if(sNodeVecs.elementAt(index).elementAt(0).getCid() == tmpcid) {
break;
}
if(sNodeVecs.elementAt(index) == null) {
sNodeVecs.setElementAt(new Vector<ScheduleNode>(), index);
}*/
- sNodeVecs.elementAt(index).add(tmpn);
+ if(!sNodeVecs.elementAt(index).contains(tmpn)) {
+ sNodeVecs.elementAt(index).addElement(tmpn);
+ }
}
return sNodeVecs;
} catch(Error e) {
- System.err.println("Error in rangeScheduleNodes");
+ System.err.println("Error in rangeScheduleNodes: " + scheduleNodes.size());
e.printStackTrace();
+ //System.exit(-1);
return null;
}
}