}
}
+ force_empty_first_frame = 0;
+ force_empty_last_frame = 0;
+
_edge_lengths = 0;
_graph = 0;
}
void MTPTracker::write(ostream *os) {
- (*os) << nb_locations << " " << nb_time_steps <<endl;
+ (*os) << nb_locations << " " << nb_time_steps << endl;
(*os) << endl;
(*os) << endl;
+ (*os) << force_empty_first_frame << " " << force_empty_last_frame << endl;
+
+ (*os) << endl;
+
for(int l = 0; l < nb_locations; l++) {
(*os) << entrances[l];
if(l < nb_locations - 1) (*os) << " "; else (*os) << endl;
}
}
+ (*is) >> force_empty_first_frame >> force_empty_last_frame;
+
for(int l = 0; l < nb_locations; l++) {
(*is) >> entrances[l];
}
int nb_vertices = 2 + 2 * nb_time_steps * nb_locations;
int nb_edges =
- // The edges from the source to the first frame, and from the last
- // frame to the sink
- nb_locations * 2 +
// The edges from the source to the entrances and from the exits
// to the sink (in every time frames but the first for the
// entrances, and last for the exits)
// The edges inside the duplicated nodes
nb_locations * nb_time_steps;
+ // Edges from the source to the first frame
+ if(force_empty_first_frame) {
+ nb_edges += nb_entrances;
+ } else {
+ nb_edges += nb_locations;
+ }
+
+ // Edges from the last frame to the sink
+ if(force_empty_last_frame) {
+ nb_edges += nb_exits;
+ } else {
+ nb_edges += nb_locations;
+ }
+
int *node_from = new int[nb_edges];
int *node_to = new int[nb_edges];
// The edges from the source to the first time frame
for(int l = 0; l < nb_locations; l++) {
- node_from[e] = source;
- node_to[e] = 1 + l + 0 * nb_locations;
- _edge_lengths[e] = 0.0;
- e++;
+ if(!force_empty_first_frame || entrances[l]) {
+ node_from[e] = source;
+ node_to[e] = 1 + l + 0 * nb_locations;
+ _edge_lengths[e] = 0.0;
+ e++;
+ }
}
// The edges from the last frame to the sink
for(int l = 0; l < nb_locations; l++) {
- node_from[e] = late_pair_node(nb_time_steps - 1, l);
- node_to[e] = sink;
- _edge_lengths[e] = 0.0;
- e++;
+ if(!force_empty_last_frame || exits[l]) {
+ node_from[e] = late_pair_node(nb_time_steps - 1, l);
+ node_to[e] = sink;
+ _edge_lengths[e] = 0.0;
+ e++;
+ }
}
// The edges between frames, corresponding to allowed motions