Skip to content
Snippets Groups Projects
Verified Commit c9690f8f authored by Enna Gerhard's avatar Enna Gerhard :levitate:
Browse files

Follow the path of enlightenment being checkstyle conform

parent de9004ca
No related branches found
No related tags found
1 merge request!30Maximum clique ennumeration
Pipeline #205824 passed
......@@ -42,7 +42,6 @@ public class NativeMaximumCliqueEnnumerationSolver {
public Collection<Set<Vertex>> solveMaximumCliqueEnumeration(final DirectedGraph<Vertex> graph) {
final DirectedGraph<Vertex> blueGraph = getUndirectedGraph.getBlueGraph(graph);
File solver = new File("mce_solver");
if (!solver.exists()) {
......@@ -63,7 +62,8 @@ public class NativeMaximumCliqueEnnumerationSolver {
}
}
final ProcessBuilder processBuilder = new ProcessBuilder(solver.getAbsolutePath(), "--input-file=ignored", "--algorithm=adjlist");
final String[] command = {solver.getAbsolutePath(), "--input-file=ignored", "--algorithm=adjlist"};
final ProcessBuilder processBuilder = new ProcessBuilder(command);
final GraphRenamingResult rename = new GraphRenaming().rename(blueGraph);
final DirectedGraph<Vertex> renamedGraph = rename.renamedGraph();
try {
......@@ -97,7 +97,7 @@ public class NativeMaximumCliqueEnnumerationSolver {
private List<Set<Vertex>> readResult(final DirectedGraph<Vertex> graph, final int offset, final Scanner scanner) {
List<Set<Vertex>> result = new ArrayList<>();
while (scanner.hasNext()){
while (scanner.hasNext()) {
final String line = scanner.nextLine();
if (line.startsWith("NOTE") || line.startsWith("Reading")) {
......@@ -130,9 +130,10 @@ public class NativeMaximumCliqueEnnumerationSolver {
* @param offset can be passed to eliminate values smaller than 1, needs to be kept in mind when parsin the result
*/
private void writeProblem(final Process process, final DirectedGraph<Vertex> graph, final int offset) {
final PrintWriter writer = new PrintWriter(new OutputStreamWriter(new BufferedOutputStream(process.getOutputStream())));
final PrintWriter writer = new PrintWriter(new OutputStreamWriter(new BufferedOutputStream(
process.getOutputStream())));
writer.println(graph.maxId()+1);
writer.println(graph.maxId() + 1);
writer.println(graph.edgeCount() / 2);
for (final DirectedEdge edge : graph.getEdges()) {
......
......@@ -5,14 +5,12 @@ import de.uni.bremen.grapa.library.graphs.api.DirectedGraph;
import de.uni.bremen.grapa.library.graphs.api.Vertex;
import java.util.ArrayList;
import java.util.LinkedList;
/**
* Easy access to the undirected graph.
*/
public class GetUndirectedGraph {
/**
* Strips away red edges.
*
......
......@@ -13,7 +13,6 @@ import java.util.Map;
*/
public class GraphRenaming {
/**
* Renames a graph.
*
......@@ -23,8 +22,8 @@ public class GraphRenaming {
public GraphRenamingResult rename(DirectedGraph<Vertex> graph) {
int[] backMapping = graph.getVertices().stream().mapToInt(Vertex::getId).toArray();
Map<Integer, Integer> forwardMapping = new HashMap<>();
DirectedGraph<Vertex> replacement = new BasicDirectedGraph();
for (int i = 0; i < backMapping.length; i++) {
forwardMapping.put(backMapping[i], i);
replacement.addVertex(new Vertex(i));
......@@ -37,5 +36,4 @@ public class GraphRenaming {
return new GraphRenamingResult(backMapping, replacement);
}
}
......@@ -14,11 +14,22 @@ import java.util.stream.Collectors;
* @param renamedGraph the directed graph
*/
public record GraphRenamingResult(int[] mapping, DirectedGraph<Vertex> renamedGraph) {
/**
* Interprets vertices in the translated representation and converts them back to the original.
*
* @param input in the renamed space
* @return in the original space
*/
public Collection<Set<Vertex>> decipher(final Collection<Set<Vertex>> input) {
return input.stream().map(this::decipher).toList();
}
/**
* Interprets vertices in the translated representation and converts them back to the original.
*
* @param input in the renamed space
* @return in the original space
*/
public Set<Vertex> decipher(final Set<Vertex> input) {
return input.stream()
.mapToInt(Vertex::getId)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment