Commit cdd49cbd authored by Sebastian Vollbrecht's avatar Sebastian Vollbrecht

Some minor fixes.

parent 78672061
......@@ -218,7 +218,9 @@ public final class GraphGenerator {
edgeIncluder.setASAPTimesMap(asapTimes);
backedgeIncluder.setASAPTimesMap(asapTimes);
property.generateProperty(layers, Collections.unmodifiableSet(nodes), nodeTable, edgeCreator);
property.generateProperty(layers, Collections.unmodifiableSet(nodes), Collections.unmodifiableMap(nodeTable),
edgeCreator
);
if (verbose) {
out.println("\tLayer structure post property generation: " + layers.toString());
......@@ -328,7 +330,7 @@ public final class GraphGenerator {
* <p>
* Use <code>new PrintStream(new FileOutputStream(new File(filename))</code> to immediately write to a file.<br>
* <b>Warning</b>: The resulting file might be excessively large due to the
* amount of edges possible in large graphs (O(2* V^2)).
* amount of edges possible in large graphs (O(2*V<sup>2</sup>)).
*
* @param out the print stream
*/
......
......@@ -180,7 +180,6 @@ public class EdgeCreator extends Observable<Edge<ResourceNode>> implements EdgeC
outgoingBackedges.get(src).add(edge);
incomingBackedges.get(dst).add(edge);
// TODO: is this check necessary?
if (src != GraphGenerator.SOURCE && dst != GraphGenerator.SINK) {
notifyObservers(edge);
}
......
......@@ -21,7 +21,6 @@ import graphgen.generator.exceptions.IllegalSwapException;
import graphgen.generator.exceptions.NodeDoesNotExistException;
import graphgen.generator.exceptions.StrictModeException;
import graphgen.observer.Observer;
import graphgen.util.JavaUtils;
import modsched.Edge;
import modsched.Node;
......@@ -36,7 +35,6 @@ import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Set;
import java.util.TreeMap;
/**
* The layer structure is an essential component of the graph generator. It contains a list of layers, which are
......@@ -66,9 +64,22 @@ public final class LayerStructure implements Serializable, Iterable<Integer>, Ob
* Constructs a new layer structure based on the provided list of layers and the ID depths map.
*
* @param depthsByID the depths of the IDs contained in the given list of layers
* @throws IllegalArgumentException if any depth is negative
*/
public LayerStructure(Map<Integer, Integer> depthsByID) {
this.layers = new ArrayList<>(new TreeMap<>(JavaUtils.invertMap(depthsByID)).values());
this.layers = new ArrayList<>();
depthsByID.forEach((id, depth) -> {
if (depth < 0) {
throw new IllegalArgumentException("Depth of ID " + id + " cannot be negative.");
} else {
while (layers.size() <= depth) {
layers.add(new HashSet<>());
}
}
layers.get(depth).add(id);
});
this.height = layers.size();
this.depthsByID = new HashMap<>(depthsByID);
this.checker = new SwapChecker();
......@@ -106,11 +117,13 @@ public final class LayerStructure implements Serializable, Iterable<Integer>, Ob
throw new IllegalSwapException(firstID, secondID);
}
int firstLevel = depthsByID.get(firstID);
int secondLevel = depthsByID.get(secondID);
int firstDepth = depthsByID.get(firstID);
int secondDepth = depthsByID.get(secondID);
moveNode(secondID, firstLevel);
moveNode(firstID, secondLevel);
if (firstDepth != secondDepth) {
moveNode(secondID, firstDepth);
moveNode(firstID, secondDepth);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment