diff --git a/PL2/PL2-core/src/main/java/nl/tudelft/pl2016gr2/core/algorithms/subgraph/OrderedGraph.java b/PL2/PL2-core/src/main/java/nl/tudelft/pl2016gr2/core/algorithms/subgraph/OrderedGraph.java index b17a0a89..0fa0fead 100644 --- a/PL2/PL2-core/src/main/java/nl/tudelft/pl2016gr2/core/algorithms/subgraph/OrderedGraph.java +++ b/PL2/PL2-core/src/main/java/nl/tudelft/pl2016gr2/core/algorithms/subgraph/OrderedGraph.java @@ -1,6 +1,5 @@ package nl.tudelft.pl2016gr2.core.algorithms.subgraph; -import nl.tudelft.pl2016gr2.model.graph.SequenceGraph; import nl.tudelft.pl2016gr2.model.graph.nodes.GraphNode; import java.util.ArrayList; @@ -12,25 +11,26 @@ */ public class OrderedGraph { - private final SequenceGraph subgraph; - private final ArrayList graphOrderEndX; + private final int amountOfGenomes; + private final ArrayList graphOrder; /** * Construct an ordered graph. * - * @param subgraph the subgraph. - * @param graphOrder the graph order. + * @param amountOfGenomes the amount of genomes in the graph. + * @param graphOrder the graph order. */ - public OrderedGraph(SequenceGraph subgraph, ArrayList graphOrder) { - this.subgraph = subgraph; - this.graphOrderEndX = graphOrder; + public OrderedGraph(int amountOfGenomes, ArrayList graphOrder) { + this.amountOfGenomes = amountOfGenomes; + this.graphOrder = graphOrder; + graphOrder.trimToSize(); } - public SequenceGraph getSubgraph() { - return subgraph; + public int getGenomeSize() { + return amountOfGenomes; } public ArrayList getGraphOrder() { - return graphOrderEndX; + return graphOrder; } } diff --git a/PL2/PL2-core/src/main/java/nl/tudelft/pl2016gr2/core/algorithms/subgraph/SubgraphAlgorithmManager.java b/PL2/PL2-core/src/main/java/nl/tudelft/pl2016gr2/core/algorithms/subgraph/SubgraphAlgorithmManager.java index 29c21f60..5f9137a7 100644 --- a/PL2/PL2-core/src/main/java/nl/tudelft/pl2016gr2/core/algorithms/subgraph/SubgraphAlgorithmManager.java +++ b/PL2/PL2-core/src/main/java/nl/tudelft/pl2016gr2/core/algorithms/subgraph/SubgraphAlgorithmManager.java @@ -44,7 +44,7 @@ private SubgraphAlgorithmManager() { * @return a pair containing as left value the ordered graph of the top subgraph and as right * value the ordered graph of the bottom subgraph. */ - @SuppressWarnings("checkstyle:MethodLength") + @SuppressWarnings({"checkstyle:MethodLength", "checkstyle:VariableDeclarationUsageDistance"}) public static Pair compareTwoGraphs(Collection topGenomes, Collection bottomGenomes, SequenceGraph mainGraph, GraphOrdererThread mainGraphOrder, IPhylogeneticTreeRoot treeRoot) { @@ -56,10 +56,14 @@ public static Pair compareTwoGraphs(Collection compareTwoGraphs(Collection(orderedTopGraph, orderedBottomGraph); } @@ -84,6 +87,7 @@ public static Pair compareTwoGraphs(Collection genomes, SequenceGraph mainGraph, GraphOrdererThread mainGraphOrder, IPhylogeneticTreeRoot treeRoot) { dummyRootNodeId = Integer.MAX_VALUE; @@ -93,11 +97,13 @@ public static OrderedGraph alignOneGraph(Collection genomes, SequenceGr SequenceGraph subgraph = topSubGraphThread.getSubGraph(); ArrayList orderedNodes = subgraph.getOrderedGraph(); + int amountOfGenomes = subgraph.getGenomes().size(); + subgraph = null; // allow garbage collection orderedNodes = performBubblingAlgorithms(orderedNodes, genomes, treeRoot); - + CompareSubgraphs.alignVertically(orderedNodes); addDummyNodes(orderedNodes); - return new OrderedGraph(subgraph, orderedNodes); + return new OrderedGraph(amountOfGenomes, orderedNodes); } /** @@ -190,14 +196,13 @@ public void run() { private static class FilterBubbleThread extends Thread { - private final SequenceGraph subgraph; private final Collection genomes; private final IPhylogeneticTreeRoot treeRoot; private ArrayList orderedNodes; - private FilterBubbleThread(SequenceGraph subgraph, Collection genomes, + private FilterBubbleThread(ArrayList orderedSubgraph, Collection genomes, IPhylogeneticTreeRoot treeRoot) { - this.subgraph = subgraph; + this.orderedNodes = orderedSubgraph; this.genomes = genomes; this.treeRoot = treeRoot; } @@ -213,7 +218,6 @@ public ArrayList getOrderedNodes() { @Override public void run() { - orderedNodes = subgraph.getOrderedGraph(); orderedNodes = performBubblingAlgorithms(orderedNodes, genomes, treeRoot); } } diff --git a/PL2/PL2-gui/src/main/java/nl/tudelft/pl2016gr2/gui/view/graph/GraphPaneController.java b/PL2/PL2-gui/src/main/java/nl/tudelft/pl2016gr2/gui/view/graph/GraphPaneController.java index 0f123a3c..dbdad173 100644 --- a/PL2/PL2-gui/src/main/java/nl/tudelft/pl2016gr2/gui/view/graph/GraphPaneController.java +++ b/PL2/PL2-gui/src/main/java/nl/tudelft/pl2016gr2/gui/view/graph/GraphPaneController.java @@ -783,12 +783,12 @@ private void updateGraph() { } clearCanvas(); if (topGraph != null) { - drawGraph(topPane, topEdgeCanvas, topGraph, topGraph.getSubgraph().getGenomes().size(), - startLevel, startLevel + levelsToDraw); + drawGraph(topPane, topEdgeCanvas, topGraph, topGraph.getGenomeSize(), startLevel, + startLevel + levelsToDraw); } if (bottomGraph != null) { - drawGraph(bottomPane, bottomEdgeCanvas, bottomGraph, - bottomGraph.getSubgraph().getGenomes().size(), startLevel, startLevel + levelsToDraw); + drawGraph(bottomPane, bottomEdgeCanvas, bottomGraph, bottomGraph.getGenomeSize(), startLevel, + startLevel + levelsToDraw); } }