From 604969362dc856fcc582be0b6b7f46cb8d8b41fb Mon Sep 17 00:00:00 2001 From: Ali Rostami Date: Tue, 20 May 2025 13:47:42 +0200 Subject: [PATCH 1/7] refactoring --- src/graphtea/extensions/AlgorithmUtils.java | 37 +- .../extensions/actions/ExtractSubGraph.java | 2 +- src/graphtea/extensions/algorithms/DAG.java | 2 +- .../algorithms/IndSetProductColoring.java | 2 +- .../extensions/algorithms/LloydKMeans.java | 10 +- .../algorithms/TopologicalSort.java | 2 +- .../algorithms/spanningtree/Prim.java | 12 +- .../generators/KneserGraphGenerator.java | 2 +- .../extensions/reports/Partitioner.java | 4 +- .../reports/basicreports/GirthSize.java | 10 +- .../NumOfConnectedComponents.java | 6 +- .../SpectrumOfAdjacencyMatrix.java | 2 +- .../SpectrumOfDistanceAdjMatrix.java | 2 +- .../SpectrumOfDistanceLaplacianMatrix.java | 2 +- .../SpectrumOfDistanceSignlessLaplacian.java | 2 +- .../SpectrumOfMaxDegreeAdjMatrix.java | 2 +- .../SpectrumOfNormalizedLaplacian.java | 2 +- .../reports/boundcheck/forall/IterGraphs.java | 2 +- .../reports/connectivity/KConnected.java | 4 +- src/graphtea/graph/graph/Edge.java | 6 +- src/graphtea/graph/graph/GraphColoring.java | 8 +- src/graphtea/graph/graph/GraphModel.java | 4 +- src/graphtea/graph/graph/SubGraph.java | 4 +- src/graphtea/graph/graph/Vertex.java | 4 +- src/graphtea/library/ListGraph.java | 2 +- src/graphtea/library/MatrixGraph.java | 4 +- .../traversal/BreadthFirstSearch.java | 2 +- .../algorithms/util/BipartiteChecker.java | 6 +- .../TimeLimitedNotifiableAttrSet.java | 2 +- .../platform/core/AbstractAction.java | 10 +- .../extension/ExtensionClassLoader.java | 2 +- .../platform/extension/ExtensionLoader.java | 4 +- .../core/AlgorithmAnimator.java | 5 +- .../core/atoms/GraphSelect.java | 4 - .../core/atoms/PrePostWork.java | 3 +- .../AtomAnimatorExtensionAction.java | 2 - .../plugins/commandline/ShellConsole.java | 8 +- .../commandline/commands/NativeCommands.java | 5 +- .../commands/ShellServerCommands.java | 2 +- .../extensionloader/BSHExtensionLoader.java | 2 +- .../commandline/parsers/DefaultParser.java | 2 +- .../plugins/commonplugin/undo/UndoAction.java | 6 +- src/graphtea/plugins/main/Init.java | 3 +- .../main/core/actions/edge/AddEdge.java | 3 +- .../main/core/actions/edge/DragEdge.java | 6 +- .../main/core/actions/vertex/AddVertex.java | 2 +- .../extension/GraphIOExtensionHandler.java | 3 +- .../main/saveload/matrix/SaveMatrix.java | 2 +- .../xmlparser/GraphmlHandlerImpl.java | 2 - .../plugins/main/select/ClearSelection.java | 6 +- .../plugins/main/select/MoveSelected.java | 3 +- .../main/select/SelectPluginMethods.java | 2 +- .../main/ui/GraphColoringRenderer.java | 4 +- .../plugins/main/ui/SubGraphRenderer.java | 4 +- .../CircularDispatchVisualization.java | 4 +- .../hierarchical/BendedTrees.java | 2 +- .../treevisualizations/BackwardTrees.java | 4 +- .../CircularTreeVisualization.java | 2 +- .../HierarchicalTreeVisualization.java | 4 +- .../SparseTreeVisualization.java | 2 +- .../myplugin/actions/ReadWriteTextFile.java | 4 +- .../ui/components/ExtensionConfigFrame.java | 14 +- src/graphtea/ui/components/GStatusBar.java | 2 - src/graphtea/ui/components/GToolbar.java | 2 - .../gpropertyeditor/utils/JFontChooser.java | 5 +- .../ui/components/gsidebar/GSideBarPanel.java | 8 +- .../ui/components/prefeditor/GPrefPane.java | 9 +- .../prefeditor/GTabbedAttributeFrame.java | 3 +- .../prefeditor/GTabbedAttributePane.java | 3 +- .../ui/components/utils/GAttrFrame.java | 3 +- {test => src/test}/BasicReportsTest.java | 42 +- {test => src/test}/GeneratorsTest.java | 357 ++++++++------- {test => src/test}/ProductsTest.java | 17 +- {test => src/test}/RenderTableTest.java | 4 +- {test => src/test}/ReportsTest.java | 430 +++++++++--------- {test => src/test}/TestActions.java | 8 +- .../test}/TestChemicalGraphIndices.java | 8 +- {test => src/test}/TestHomomorphism.java | 19 +- {test => src/test}/TestListGraph.java | 6 +- {test => src/test}/TestMatrixGraph.java | 3 +- {test => src/test}/TestNewEdge.java | 2 +- {test => src/test}/TestPropertyEditor.java | 4 +- 82 files changed, 579 insertions(+), 636 deletions(-) rename {test => src/test}/BasicReportsTest.java (60%) rename {test => src/test}/GeneratorsTest.java (69%) rename {test => src/test}/ProductsTest.java (81%) rename {test => src/test}/RenderTableTest.java (90%) rename {test => src/test}/ReportsTest.java (53%) rename {test => src/test}/TestActions.java (92%) rename {test => src/test}/TestChemicalGraphIndices.java (51%) rename {test => src/test}/TestHomomorphism.java (86%) rename {test => src/test}/TestListGraph.java (98%) rename {test => src/test}/TestMatrixGraph.java (98%) rename {test => src/test}/TestNewEdge.java (91%) rename {test => src/test}/TestPropertyEditor.java (91%) diff --git a/src/graphtea/extensions/AlgorithmUtils.java b/src/graphtea/extensions/AlgorithmUtils.java index 496c2132..cba573e3 100755 --- a/src/graphtea/extensions/AlgorithmUtils.java +++ b/src/graphtea/extensions/AlgorithmUtils.java @@ -132,7 +132,7 @@ void clearVertexMarks(GraphModel g) { } /** - * returns the subtree rooted by subTreeRoot in the rooted tree tree with the root treeRoot + * returns the subtree rooted by subTreeRoot in the rooted tree with the root treeRoot * the vertices are ordered by their distances to subTreeRoot * the exact distance is placed in v.getProp().obj as an Integer, starting distance is 0 which is subTreeRoot */ @@ -144,6 +144,7 @@ ArrayList getSubTree(GraphModel tree, Vertex treeRoot, Vertex subTreeRoo clearVertexMarks(tree); //close the path to tree root + assert pathToRoot != null; for (Vertex vertex : pathToRoot) { vertex.setMark(true); } @@ -351,7 +352,7 @@ public static double getAngle(GPoint p1, GPoint p2) { } /** - * locations v in a r-teta coordination + * locations v in an r-teta coordination */ public static void setLocation(Vertex v, GPoint center, double radius, double ang) { v.setLocation(new GPoint(center.x + radius * Math.cos(ang), center.y + radius * Math.sin(ang))); @@ -426,17 +427,17 @@ public static String getEigenValues(GraphModel g) { EigenvalueDecomposition ed = A.eig(); double[] rv = ed.getRealEigenvalues(); double[] iv = ed.getImagEigenvalues(); - String res = ""; + StringBuilder res = new StringBuilder(); for (int i = 0; i < rv.length; i++) { if (iv[i] != 0) - res +="" + AlgorithmUtils.round(rv[i],10) + " + " + AlgorithmUtils.round(iv[i],10) + "i"; + res.append(AlgorithmUtils.round(rv[i], 10)).append(" + ").append(AlgorithmUtils.round(iv[i], 10)).append("i"); else - res += "" + AlgorithmUtils.round(rv[i],10); + res.append(AlgorithmUtils.round(rv[i], 10)); if(i!=rv.length-1) { - res += ","; + res.append(","); } } - return res; + return res.toString(); } /** @@ -493,25 +494,25 @@ public static String getEigenValues(Matrix A) { EigenvalueDecomposition ed = A.eig(); double[] rv = ed.getRealEigenvalues(); double[] iv = ed.getImagEigenvalues(); - String res = ""; + StringBuilder res = new StringBuilder(); Vector EigenValues = new Vector<>(); for (int i = 0; i < rv.length; i++) { if (iv[i] != 0) - res +="" + AlgorithmUtils.round(rv[i],10) + " + " + AlgorithmUtils.round(iv[i],10) + "i"; + res.append(AlgorithmUtils.round(rv[i], 10)).append(" + ").append(AlgorithmUtils.round(iv[i], 10)).append("i"); else EigenValues.add(AlgorithmUtils.round(rv[i],10)); } - if(EigenValues.size() > 0) { - res = ""; + if(!EigenValues.isEmpty()) { + res = new StringBuilder(); EigenValues.sort((aDouble, t1) -> -aDouble.compareTo(t1)); for (int i = 0; i < EigenValues.size(); i++) { - res += EigenValues.get(i); + res.append(EigenValues.get(i)); if(i != EigenValues.size() - 1) { - res+=","; + res.append(","); } } } - return res; + return res.toString(); } // get kth minimum degree @@ -541,7 +542,7 @@ public static double getDegreeSumOfVertex(GraphModel g, double alpha, Vertex v) public static double getDegreeSum(GraphModel g, double alpha) { int sum = 0; for(Vertex v: g) { - sum+=getDegreeSumOfVertex(g,alpha,v); + sum+= (int) getDegreeSumOfVertex(g,alpha,v); } return sum; } @@ -677,7 +678,7 @@ public static Matrix getMaxDegreeAdjacencyMatrix (GraphModel g) { /** * Distance adjacency matrix * Distance Energy based on - * Gopalapillai Indulal,a Ivan Gutmanb and Vijayakumarc + * Gopalapillai Indulal,an Ivan Gutmanb and Vijayakumarc * ON DISTANCE ENERGY OF GRAPHS * MATCH Commun. Math. Comput. Chem. 60 (2008) 461-472. * @@ -714,7 +715,7 @@ public static Matrix getLaplacian(Matrix A) { for (int i = 0; i < n; i++) { sum = 0; for (int j = 0; j < n; j++) { - sum += ATemp[j][i]; + sum += (int) ATemp[j][i]; } DTemp[i][i] = sum; } @@ -781,7 +782,7 @@ public static Matrix getSignlessLaplacian(Matrix A) { for (int i = 0; i < n; i++) { sum = 0; for (int j = 0; j < n; j++) { - sum += ATemp[j][i]; + sum += (int) ATemp[j][i]; } DTemp[i][i] = sum; } diff --git a/src/graphtea/extensions/actions/ExtractSubGraph.java b/src/graphtea/extensions/actions/ExtractSubGraph.java index a64a6c83..be358024 100755 --- a/src/graphtea/extensions/actions/ExtractSubGraph.java +++ b/src/graphtea/extensions/actions/ExtractSubGraph.java @@ -31,7 +31,7 @@ public void action(GraphData graphData) { SubGraph sg = SubGraphRenderer.sgbck; HashMap idid= new HashMap<>(); - if(sg.vertices.size()!=0) { + if(!sg.vertices.isEmpty()) { for(Vertex v : sg.vertices) { Vertex tmp = new Vertex(); tmp.setLabel(v.getLabel()); diff --git a/src/graphtea/extensions/algorithms/DAG.java b/src/graphtea/extensions/algorithms/DAG.java index 5dc726b2..54d2eb5c 100755 --- a/src/graphtea/extensions/algorithms/DAG.java +++ b/src/graphtea/extensions/algorithms/DAG.java @@ -36,7 +36,7 @@ public static AbstractList doSort(GraphModel graph) { v.setMark(true); } - while (alv.size() != 0) { + while (!alv.isEmpty()) { Vertex v = alv.remove(0); out.add(v); diff --git a/src/graphtea/extensions/algorithms/IndSetProductColoring.java b/src/graphtea/extensions/algorithms/IndSetProductColoring.java index fd2ae9fa..e37f2a96 100755 --- a/src/graphtea/extensions/algorithms/IndSetProductColoring.java +++ b/src/graphtea/extensions/algorithms/IndSetProductColoring.java @@ -131,7 +131,7 @@ public Vector> setproduct(Vector> set1,Vector... + *

* Lloyd's Algorithm - A greedy approximation to the kmeans clustering problem (NP-HARD), this is similar to * finding the centers of the voronoi cells of a tessellation that has the input points * distributed as evenly as possible throughout the cells. - * + *

* Steps: * 1) It guesses an initial location for the center of each cluster * 2) It assigns each input point to one cluster (the one with the closest center) * 3) For each cluster, move its center to the centroid of all its assigned points. * 4) Repeat steps 2-3 until no change occurs. - * + *

* Returns: An array of Clusters. If you need exactly k clusters you may have to run it several times since * some clusters may die out during the algorithm, this shouldn't be a problem because this function * usually runs very fast. @@ -89,7 +89,7 @@ public static Cluster[] cluster(GPoint[] p, int k) { // remove all empty clusters (due to bad initial placement) for (int i = 0; i < ret.size(); i++) - if (ret.get(i).getMembers().size() == 0) + if (ret.get(i).getMembers().isEmpty()) ret.remove(i--); return ret.toArray(new Cluster[0]); // the result may not have exactly k diff --git a/src/graphtea/extensions/algorithms/TopologicalSort.java b/src/graphtea/extensions/algorithms/TopologicalSort.java index 617a138c..eaa7e5df 100755 --- a/src/graphtea/extensions/algorithms/TopologicalSort.java +++ b/src/graphtea/extensions/algorithms/TopologicalSort.java @@ -31,7 +31,7 @@ public class TopologicalSort extends Algorithm implements AutomatedAlgorithm { if (graph.getInDegree(v) == 0) alv.add(v); - while (alv.size() != 0) { + while (!alv.isEmpty()) { Vertex v = alv.remove(0); out.add(v); diff --git a/src/graphtea/extensions/algorithms/spanningtree/Prim.java b/src/graphtea/extensions/algorithms/spanningtree/Prim.java index 8b0e02e7..2673efb9 100755 --- a/src/graphtea/extensions/algorithms/spanningtree/Prim.java +++ b/src/graphtea/extensions/algorithms/spanningtree/Prim.java @@ -31,12 +31,6 @@ public class Prim extends Algorithm implements AutomatedAlgorithm { * Temporary reference to the graph the algorithm is going to run on it. */ final GraphModel graph; - /** - * Reference to a GraphConverter object which is responsible for duplication - * of the graph elements, because graph edges and vertices are going to be - * copied to the newly created spanning tree. - */ - private final EdgeVertexCopier gc; /** * Priority queue implemented as a binary heap to store edges, sorted according * to their weights. @@ -73,7 +67,11 @@ public Prim(GraphModel graph, // throw new NullPointerException(); this.graph = graph; - this.gc = gc; + /** + * Reference to a GraphConverter object which is responsible for duplication + * of the graph elements, because graph edges and vertices are going to be + * copied to the newly created spanning tree. + */ this.ec = new DefaultEdgeComparator(); } diff --git a/src/graphtea/extensions/generators/KneserGraphGenerator.java b/src/graphtea/extensions/generators/KneserGraphGenerator.java index 462acee2..9809f17e 100755 --- a/src/graphtea/extensions/generators/KneserGraphGenerator.java +++ b/src/graphtea/extensions/generators/KneserGraphGenerator.java @@ -89,7 +89,7 @@ public Edge[] getEdges() { HashSet s2 = computedVertices.get(j); Set intersection = new HashSet<>(s1); intersection.retainAll(s2); - if(intersection.size() == 0) ret.add(new Edge(v[i], v[j])); + if(intersection.isEmpty()) ret.add(new Edge(v[i], v[j])); } } Edge[] ret1 = new Edge[ret.size()]; diff --git a/src/graphtea/extensions/reports/Partitioner.java b/src/graphtea/extensions/reports/Partitioner.java index 877c7bed..354e1328 100755 --- a/src/graphtea/extensions/reports/Partitioner.java +++ b/src/graphtea/extensions/reports/Partitioner.java @@ -156,7 +156,7 @@ public boolean findAllPartitionings(final int t, final ColoringListener listener } public boolean findAllPartitioningsRecursively(final int tt, final ColoringListener listener, final ArrayDeque v) { - if (tt == 0 || v.size() == 0) { + if (tt == 0 || v.isEmpty()) { return listener.coloringFound(tt); } Vertex fv = v.removeFirst(); @@ -170,7 +170,7 @@ public boolean findAllPartitioningsRecursively(final int tt, final ColoringListe } private boolean findAllSubsetsRecursively(final int t, SubSetListener listener, ArrayDeque v, ArrayDeque set, ArrayDeque complement) { - if (t == 0 || v.size() == 0) { + if (t == 0 || v.isEmpty()) { //all colorings of valid and checked before except the remaining vertices which all have color 0 for (Vertex Vertex : v) { for (int i : edgeArray[Vertex.getId()]) diff --git a/src/graphtea/extensions/reports/basicreports/GirthSize.java b/src/graphtea/extensions/reports/basicreports/GirthSize.java index 9f475043..c5fd89f5 100755 --- a/src/graphtea/extensions/reports/basicreports/GirthSize.java +++ b/src/graphtea/extensions/reports/basicreports/GirthSize.java @@ -16,7 +16,7 @@ /** * @author Mohammad Ali Rostami * - * In graph theory, the girth of an undirected graph is the length of a shortest cycle contained in the graph. + * In graph theory, the girth of an undirected graph is the length of the shortest cycle contained in the graph. */ @CommandAttitude(name = "girth_size", abbreviation = "_gs") @@ -34,7 +34,7 @@ private static int bfs(int start, double[][] mat, int cc, int girth) { baba[start] = -1; List ll = new ArrayList<>(); ll.add(start); - while (ll.size() > 0) { + while (!ll.isEmpty()) { int currentNode = ll.remove(0); for (int j = 0; j < cc; j++) if (mat[currentNode][j] == 1) @@ -63,9 +63,9 @@ private static int getGirthSize(GraphModel graph) { double[][] mat = graph.getAdjacencyMatrix().getArray(); int girth = AlgorithmUtils.Max_Int; for (int i = 0; i < size; i++) { - int sizeofsmallestcycle = bfs(i, mat, size, girth); - if (sizeofsmallestcycle != AlgorithmUtils.Max_Int && girth > sizeofsmallestcycle) - girth = sizeofsmallestcycle; + int sizeOfSmallestCycle = bfs(i, mat, size, girth); + if (sizeOfSmallestCycle != AlgorithmUtils.Max_Int && girth > sizeOfSmallestCycle) + girth = sizeOfSmallestCycle; } if (girth == AlgorithmUtils.Max_Int) return 0; return girth; diff --git a/src/graphtea/extensions/reports/basicreports/NumOfConnectedComponents.java b/src/graphtea/extensions/reports/basicreports/NumOfConnectedComponents.java index 203eefae..6b5a7580 100755 --- a/src/graphtea/extensions/reports/basicreports/NumOfConnectedComponents.java +++ b/src/graphtea/extensions/reports/basicreports/NumOfConnectedComponents.java @@ -11,6 +11,7 @@ import graphtea.plugins.reports.extension.GraphReportExtension; import java.util.ArrayList; +import java.util.Arrays; /** * @author Mohammad Ali Rostami @@ -35,11 +36,10 @@ public static ArrayList> getConnectedComponents(GraphModel gr ArrayList> comps = new ArrayList<>(); int[] parent = new int[size]; - for (int i = 0; i < size; i++) - parent[i] = -1; + Arrays.fill(parent, -1); ArrayList visit; - for (; untraversed.size() > 0; untraversed.removeAll(visit)) { + for (; !untraversed.isEmpty(); untraversed.removeAll(visit)) { visit = new ArrayList<>(); int currentNode = untraversed.get(0); parent[currentNode] = currentNode; diff --git a/src/graphtea/extensions/reports/basicreports/SpectrumOfAdjacencyMatrix.java b/src/graphtea/extensions/reports/basicreports/SpectrumOfAdjacencyMatrix.java index 9f1dd0aa..383dd1d4 100755 --- a/src/graphtea/extensions/reports/basicreports/SpectrumOfAdjacencyMatrix.java +++ b/src/graphtea/extensions/reports/basicreports/SpectrumOfAdjacencyMatrix.java @@ -34,7 +34,7 @@ public ArrayList calculate(GraphModel g) { double[] iv = ed.getImagEigenvalues(); for (int i = 0; i < rv.length; i++) if (iv[i] != 0) - res.add("" + AlgorithmUtils.round(rv[i], 5) + " + " + AlgorithmUtils.round(iv[i], 5) + "i"); + res.add(AlgorithmUtils.round(rv[i], 5) + " + " + AlgorithmUtils.round(iv[i], 5) + "i"); else res.add("" + AlgorithmUtils.round(rv[i], 5)); res.add("Eigen Vectors:\n"); diff --git a/src/graphtea/extensions/reports/basicreports/SpectrumOfDistanceAdjMatrix.java b/src/graphtea/extensions/reports/basicreports/SpectrumOfDistanceAdjMatrix.java index c05919c9..c5b360a0 100755 --- a/src/graphtea/extensions/reports/basicreports/SpectrumOfDistanceAdjMatrix.java +++ b/src/graphtea/extensions/reports/basicreports/SpectrumOfDistanceAdjMatrix.java @@ -33,7 +33,7 @@ public ArrayList calculate(GraphModel g) { double[] iv = ed.getImagEigenvalues(); for (int i = 0; i < rv.length; i++) if (iv[i] != 0) - res.add("" + AlgorithmUtils.round(rv[i], 5) + " + " + AlgorithmUtils.round(iv[i], 5) + "i"); + res.add(AlgorithmUtils.round(rv[i], 5) + " + " + AlgorithmUtils.round(iv[i], 5) + "i"); else res.add("" + AlgorithmUtils.round(rv[i], 5)); res.add("Eigen Vectors:\n"); diff --git a/src/graphtea/extensions/reports/basicreports/SpectrumOfDistanceLaplacianMatrix.java b/src/graphtea/extensions/reports/basicreports/SpectrumOfDistanceLaplacianMatrix.java index 2dab94c6..1ca57228 100755 --- a/src/graphtea/extensions/reports/basicreports/SpectrumOfDistanceLaplacianMatrix.java +++ b/src/graphtea/extensions/reports/basicreports/SpectrumOfDistanceLaplacianMatrix.java @@ -33,7 +33,7 @@ public ArrayList calculate(GraphModel g) { double[] iv = ed.getImagEigenvalues(); for (int i = 0; i < rv.length; i++) if (iv[i] != 0) - res.add("" + AlgorithmUtils.round(rv[i], 5) + " + " + AlgorithmUtils.round(iv[i], 5) + "i"); + res.add(AlgorithmUtils.round(rv[i], 5) + " + " + AlgorithmUtils.round(iv[i], 5) + "i"); else res.add("" + AlgorithmUtils.round(rv[i], 5)); res.add("Eigen Vectors:\n"); diff --git a/src/graphtea/extensions/reports/basicreports/SpectrumOfDistanceSignlessLaplacian.java b/src/graphtea/extensions/reports/basicreports/SpectrumOfDistanceSignlessLaplacian.java index cf4f44f2..cddaf7ce 100755 --- a/src/graphtea/extensions/reports/basicreports/SpectrumOfDistanceSignlessLaplacian.java +++ b/src/graphtea/extensions/reports/basicreports/SpectrumOfDistanceSignlessLaplacian.java @@ -34,7 +34,7 @@ public ArrayList calculate(GraphModel g) { double[] iv = ed.getImagEigenvalues(); for (int i = 0; i < rv.length; i++) if (iv[i] != 0) - res.add("" + AlgorithmUtils.round(rv[i], 5) + " + " + AlgorithmUtils.round(iv[i], 5) + "i"); + res.add(AlgorithmUtils.round(rv[i], 5) + " + " + AlgorithmUtils.round(iv[i], 5) + "i"); else res.add("" + AlgorithmUtils.round(rv[i], 5)); res.add("Eigen Vectors:\n"); diff --git a/src/graphtea/extensions/reports/basicreports/SpectrumOfMaxDegreeAdjMatrix.java b/src/graphtea/extensions/reports/basicreports/SpectrumOfMaxDegreeAdjMatrix.java index 6cb4ed4d..3eedc228 100755 --- a/src/graphtea/extensions/reports/basicreports/SpectrumOfMaxDegreeAdjMatrix.java +++ b/src/graphtea/extensions/reports/basicreports/SpectrumOfMaxDegreeAdjMatrix.java @@ -33,7 +33,7 @@ public ArrayList calculate(GraphModel g) { double[] iv = ed.getImagEigenvalues(); for (int i = 0; i < rv.length; i++) if (iv[i] != 0) - res.add("" + AlgorithmUtils.round(rv[i], 5) + " + " + AlgorithmUtils.round(iv[i], 5) + "i"); + res.add(AlgorithmUtils.round(rv[i], 5) + " + " + AlgorithmUtils.round(iv[i], 5) + "i"); else res.add("" + AlgorithmUtils.round(rv[i], 5)); res.add("Eigen Vectors:\n"); diff --git a/src/graphtea/extensions/reports/basicreports/SpectrumOfNormalizedLaplacian.java b/src/graphtea/extensions/reports/basicreports/SpectrumOfNormalizedLaplacian.java index ca6a07ba..e8908cd5 100755 --- a/src/graphtea/extensions/reports/basicreports/SpectrumOfNormalizedLaplacian.java +++ b/src/graphtea/extensions/reports/basicreports/SpectrumOfNormalizedLaplacian.java @@ -34,7 +34,7 @@ public ArrayList calculate(GraphModel g) { double[] iv = ed.getImagEigenvalues(); for (int i = 0; i < rv.length; i++) if (iv[i] != 0) - res.add("" + AlgorithmUtils.round(rv[i], 5) + " + " + AlgorithmUtils.round(iv[i], 5) + "i"); + res.add(AlgorithmUtils.round(rv[i], 5) + " + " + AlgorithmUtils.round(iv[i], 5) + "i"); else res.add("" + AlgorithmUtils.round(rv[i], 5)); res.add("Eigen Vectors:\n"); diff --git a/src/graphtea/extensions/reports/boundcheck/forall/IterGraphs.java b/src/graphtea/extensions/reports/boundcheck/forall/IterGraphs.java index 60edec2b..4a1b5ce8 100755 --- a/src/graphtea/extensions/reports/boundcheck/forall/IterGraphs.java +++ b/src/graphtea/extensions/reports/boundcheck/forall/IterGraphs.java @@ -141,7 +141,7 @@ public void showWrapper(BlackBoard blackboard) { private void getResIterLimited(ToCall f, GraphModel g, int count, RenderTable mpq, String g6) { RenderTable ret = f.f(g); if (ret == null) return; - if (mpq.getTitles().size() == 0) { + if (mpq.getTitles().isEmpty()) { Vector tts = new Vector<>(); tts.add("Index"); tts.addAll(ret.getTitles()); diff --git a/src/graphtea/extensions/reports/connectivity/KConnected.java b/src/graphtea/extensions/reports/connectivity/KConnected.java index 5d570b5e..1ab31787 100755 --- a/src/graphtea/extensions/reports/connectivity/KConnected.java +++ b/src/graphtea/extensions/reports/connectivity/KConnected.java @@ -68,11 +68,11 @@ public static Vertex[] kdisconn(GraphModel g, int k) { for (int j = 0; j < k; j++) popped.add(karray.get(j)); - for (int j = 0; remain.size() == 0; j++) + for (int j = 0; remain.isEmpty(); j++) if (!popped.contains(j)) remain.add(j); - while (remain.size() > 0) { + while (!remain.isEmpty()) { Vertex n = g.getVertex(remain.poll()); Integer index; diff --git a/src/graphtea/graph/graph/Edge.java b/src/graphtea/graph/graph/Edge.java index 0e910b6f..245a9f0f 100755 --- a/src/graphtea/graph/graph/Edge.java +++ b/src/graphtea/graph/graph/Edge.java @@ -99,7 +99,7 @@ public t getUserDefinedAttribute(String name) { */ public void removeUserDefinedAttribute(String name) { userDefinedAttributes.remove(name); - if (userDefinedAttributes.size() == 0) + if (userDefinedAttributes.isEmpty()) userDefinedAttributes = null; } @@ -129,7 +129,7 @@ public static void addGlobalUserDefinedAttribute(String name, Object defaultvalu */ public static void removeGlobalUserDefinedAttribute(String name) { globalUserDefinedAttributes.remove(name); - if (globalUserDefinedAttributes.size() == 0) + if (globalUserDefinedAttributes.isEmpty()) globalUserDefinedAttributes = null; } @@ -347,8 +347,6 @@ private void updateText() { String _label; if (!isShowWeight()) _label = label; - else if (isShowWeight()) - _label = String.valueOf(super.getWeight()); else _label = label + "," + super.getWeight(); this.text = _label; diff --git a/src/graphtea/graph/graph/GraphColoring.java b/src/graphtea/graph/graph/GraphColoring.java index cd79500f..2c61b292 100755 --- a/src/graphtea/graph/graph/GraphColoring.java +++ b/src/graphtea/graph/graph/GraphColoring.java @@ -35,13 +35,13 @@ public String toString() { if (label != null && !label.equals("")) { txt = txt + label + ": \n"; } - if (vertexColors != null && vertexColors.size() > 0) { + if (vertexColors != null && !vertexColors.isEmpty()) { txt = txt + "Vertex colors: "; for (Map.Entry p : vertexColors.entrySet()) { txt = txt + p.getKey().getLabel() + ":" + p.getValue() + " , "; } } - if (edgeColors != null && edgeColors.size() > 0) { + if (edgeColors != null && !edgeColors.isEmpty()) { txt = txt + "\nEdge colors: "; for (Map.Entry p : edgeColors.entrySet()) { txt = txt + p.getKey().getLabel() + ":" + p.getValue() + " , "; @@ -51,12 +51,12 @@ public String toString() { } public void applyColoring() { - if (vertexColors != null && vertexColors.size() > 0) { + if (vertexColors != null && !vertexColors.isEmpty()) { for (Map.Entry p : vertexColors.entrySet()) { p.getKey().setColor(p.getValue()); } } - if (edgeColors != null && edgeColors.size() > 0) { + if (edgeColors != null && !edgeColors.isEmpty()) { for (Map.Entry p : edgeColors.entrySet()) { p.getKey().setColor(p.getValue()); } diff --git a/src/graphtea/graph/graph/GraphModel.java b/src/graphtea/graph/graph/GraphModel.java index af7a21d5..9cec7710 100755 --- a/src/graphtea/graph/graph/GraphModel.java +++ b/src/graphtea/graph/graph/GraphModel.java @@ -134,7 +134,7 @@ public t getUserDefinedAttribute(String name) { */ public void removeUserDefinedAttribute(String name) { userDefinedAttributes.remove(name); - if (userDefinedAttributes.size() == 0) + if (userDefinedAttributes.isEmpty()) userDefinedAttributes = null; } @@ -164,7 +164,7 @@ public static void addGlobalUserDefinedAttribute(String name, Object defaultvalu */ public static void removeGlobalUserDefinedAttribute(String name) { globalUserDefinedAttributes.remove(name); - if (globalUserDefinedAttributes.size() == 0) + if (globalUserDefinedAttributes.isEmpty()) globalUserDefinedAttributes = null; } diff --git a/src/graphtea/graph/graph/SubGraph.java b/src/graphtea/graph/graph/SubGraph.java index cb79f548..b8c0706c 100755 --- a/src/graphtea/graph/graph/SubGraph.java +++ b/src/graphtea/graph/graph/SubGraph.java @@ -69,14 +69,14 @@ public String toString() { if (label != null && !label.equals("")) { txt += label + ": \n"; } - if (vertices != null && vertices.size() > 0) { + if (vertices != null && !vertices.isEmpty()) { txt = txt + "V: {"; for (Vertex v : vertices) { txt = txt + v.getLabel() + ", "; } txt = txt.substring(0, txt.length() - 2) + "}"; } - if (edges != null && edges.size() > 0) { + if (edges != null && !edges.isEmpty()) { txt += "\nE: {"; for (Edge e : edges) { txt = txt + e + ", "; diff --git a/src/graphtea/graph/graph/Vertex.java b/src/graphtea/graph/graph/Vertex.java index ccf5f263..b5bc1bb8 100755 --- a/src/graphtea/graph/graph/Vertex.java +++ b/src/graphtea/graph/graph/Vertex.java @@ -93,7 +93,7 @@ public t getUserDefinedAttribute(String name) { */ public void removeUserDefinedAttribute(String name) { userDefinedAttributes.remove(name); - if (userDefinedAttributes.size() == 0) + if (userDefinedAttributes.isEmpty()) userDefinedAttributes = null; } @@ -123,7 +123,7 @@ public static void addGlobalUserDefinedAttribute(String name, Object defaultvalu */ public static void removeGlobalUserDefinedAttribute(String name) { globalUserDefinedAttributes.remove(name); - if (globalUserDefinedAttributes.size() == 0) + if (globalUserDefinedAttributes.isEmpty()) globalUserDefinedAttributes = null; } diff --git a/src/graphtea/library/ListGraph.java b/src/graphtea/library/ListGraph.java index df0dc3d8..8273a5da 100755 --- a/src/graphtea/library/ListGraph.java +++ b/src/graphtea/library/ListGraph.java @@ -913,7 +913,7 @@ public void checkVertex(VertexType v) public boolean isEdge(VertexType source, VertexType target) throws InvalidVertexException { AbstractList edges = getEdges(source, target); - return (edges != null) && (edges.size() != 0); + return (edges != null) && (!edges.isEmpty()); } /* (non-Javadoc) diff --git a/src/graphtea/library/MatrixGraph.java b/src/graphtea/library/MatrixGraph.java index e52cdd2b..e39e7aca 100755 --- a/src/graphtea/library/MatrixGraph.java +++ b/src/graphtea/library/MatrixGraph.java @@ -841,7 +841,7 @@ public > GraphType createEmpty @Override public boolean isEdge(VertexType source, VertexType target) throws InvalidVertexException { - return (getEdges(source, target) != null) && (getEdges(source, target).size() != 0); + return (getEdges(source, target) != null) && (!getEdges(source, target).isEmpty()); } // @Override @@ -885,7 +885,7 @@ public int[][] getEdgeArray() { ArrayList temp = new ArrayList<>(); for (ArrayList alet : ll) { - if (alet != null && alet.size() != 0) + if (alet != null && !alet.isEmpty()) temp.add(j++); } diff --git a/src/graphtea/library/algorithms/traversal/BreadthFirstSearch.java b/src/graphtea/library/algorithms/traversal/BreadthFirstSearch.java index 7c04e96c..632f28be 100755 --- a/src/graphtea/library/algorithms/traversal/BreadthFirstSearch.java +++ b/src/graphtea/library/algorithms/traversal/BreadthFirstSearch.java @@ -55,7 +55,7 @@ public boolean doSearch(VertexType vertex, PreWorkHandler handler) queue.offer(vertex); roots.offer(vertex); try { - while (queue.size() != 0) { + while (!queue.isEmpty()) { VertexType index = queue.poll(); VertexType root = roots.poll(); diff --git a/src/graphtea/library/algorithms/util/BipartiteChecker.java b/src/graphtea/library/algorithms/util/BipartiteChecker.java index 5b838852..faf152ab 100755 --- a/src/graphtea/library/algorithms/util/BipartiteChecker.java +++ b/src/graphtea/library/algorithms/util/BipartiteChecker.java @@ -13,8 +13,8 @@ /** * The details of the algorithm used here can be found at: - * http://www.cs.auckland.ac.nz/~ute/220ft/graphalg/node15.html#SECTION00033000000000000000 - * + * ... + * * @author Hooman Mohajeri Moghaddam * */ @@ -42,7 +42,7 @@ boolean isBipartite(BaseGraph graph) { v.color = 1; queue.offer(v); - while (queue.size() != 0) { + while (!queue.isEmpty()) { cv = queue.poll(); for (ColorableVertex next : CVArray) { if (graph.isEdge(cv.vm, next.vm)) diff --git a/src/graphtea/platform/attribute/TimeLimitedNotifiableAttrSet.java b/src/graphtea/platform/attribute/TimeLimitedNotifiableAttrSet.java index e3c3e31c..a1f1004e 100755 --- a/src/graphtea/platform/attribute/TimeLimitedNotifiableAttrSet.java +++ b/src/graphtea/platform/attribute/TimeLimitedNotifiableAttrSet.java @@ -23,7 +23,6 @@ */ public class TimeLimitedNotifiableAttrSet implements Runnable, NotifiableAttributeSet { private boolean started = false; - private final long millis = 100; Thread thread; private final T inp; NotifiableAttributeSetImpl as = new NotifiableAttributeSetImpl(); @@ -59,6 +58,7 @@ public void run() { fireChange(old, _new); try { old = inp.getAttrs(); + long millis = 100; Thread.sleep(millis); } catch (InterruptedException e1) { e1.printStackTrace(); diff --git a/src/graphtea/platform/core/AbstractAction.java b/src/graphtea/platform/core/AbstractAction.java index 3173c868..e8ad25dd 100755 --- a/src/graphtea/platform/core/AbstractAction.java +++ b/src/graphtea/platform/core/AbstractAction.java @@ -6,17 +6,17 @@ /** * AbstractAction itself is a wrapper for the interface Action. - * As you see in the source, it contains only two methods to implement. The first one is the action that must be done by this action, performAction() gets the event(key) that has caused this action to be run. This helps if an action is result of multiple events or when event handling must be coped with in the implementation itself. + * As you see in the source, it contains only two methods to implement. The first one is the action that must be done by this action; performAction() gets the event(key) that has caused this action to be run. This helps if an action is a result of multiple events or when event handling must be coped with in the implementation itself. *

- * The abstract class, AbstractAction is the minimal implementation of an Action in a class. It integrates the Action with the GraphTea structure. As a result any recognized AbstractAction in the GraphTea ui is Runnable. The introducing procedure is done via Xml files. + * The abstract class, AbstractAction is the minimal implementation of an Action in a class. It integrates the Action with the GraphTea structure. As a result, any recognized AbstractAction in the GraphTea ui is Runnable. The introducing procedure is done via XML files. *

- * There is no default constructor, so every descendant of AbstractAction needs to call the super constructor in its constructor first. It is because the constructor of the AbstractAction assures that the action is registered in a BlackBoard and it is enabled. Method enable() and disable() are designated to control enablity of Action groups. + * There is no default constructor, so every descendant of AbstractAction needs to call the super constructor in its constructor first. It is because the constructor of the AbstractAction assures that the action is registered in a BlackBoard, and it is enabled. Method enable() and disable() are designated to control the enablity of Action groups. *

- * As you can see AbstractAction has implemented The interface Listener. It is easy to see why! Every action is a reaction to event(key change) that is called from a user or program itself. so every AbstractAction is listening to it's relevant event to be fired. Methods listen4Event() and unListenEvent() are designed to handle the relevant events. + * As you can see AbstractAction has implemented The interface Listener. It is easy to see why! Every action is a reaction to an event (key change) that is called from a user or program itself. so every AbstractAction is listening to it's relevant event to be fired. Methods listen4Event() and unListenEvent() are designed to handle the relevant events. *

* Basically if you want to do anything in GraphTea, you need to extend AbstractAction. Looking at it's code might help. *

- * note: As you may see working with AbstractAction to handle UI events is not so simple, Also there are many classes in !GraphTea that use AbstractAction. But this is not advised to you, It is easier to use Extensions whenever you want to interact with user interface. (basically UIActionExtension, but almost every extensions are welcome!) + * note: As you may see working with AbstractAction to handle UI events is not so simple, Also there are many classes in !GraphTea that use AbstractAction. But this is not advised to you, It is easier to use Extensions whenever you want to interact with the user interface. (basically UIActionExtension, but almost every extension is welcome!) * * @author rouzbeh ebrahimi * @author Azin Azadi diff --git a/src/graphtea/platform/extension/ExtensionClassLoader.java b/src/graphtea/platform/extension/ExtensionClassLoader.java index ef4c632e..211d397f 100755 --- a/src/graphtea/platform/extension/ExtensionClassLoader.java +++ b/src/graphtea/platform/extension/ExtensionClassLoader.java @@ -58,7 +58,7 @@ private void loadClassFiles(String dir, String pack) { else if (file1.getName().endsWith(".class")) try { String name; - if (pack.length() > 0) + if (!pack.isEmpty()) name = pack.substring(1) + "."; else name = ""; diff --git a/src/graphtea/platform/extension/ExtensionLoader.java b/src/graphtea/platform/extension/ExtensionLoader.java index 29edecb1..251b8b4e 100755 --- a/src/graphtea/platform/extension/ExtensionLoader.java +++ b/src/graphtea/platform/extension/ExtensionLoader.java @@ -102,8 +102,8 @@ public static Extension loadExtension(Class extensionClass) { break; } } - if (ret == null && extensionClass.getConstructor() != null) { - ret = extensionClass.newInstance(); + if (ret == null) { + ret = (Extension) extensionClass.getConstructors()[0].newInstance(); } } if (ret != null) { diff --git a/src/graphtea/plugins/algorithmanimator/core/AlgorithmAnimator.java b/src/graphtea/plugins/algorithmanimator/core/AlgorithmAnimator.java index 0bace57a..0360193d 100755 --- a/src/graphtea/plugins/algorithmanimator/core/AlgorithmAnimator.java +++ b/src/graphtea/plugins/algorithmanimator/core/AlgorithmAnimator.java @@ -19,6 +19,7 @@ import javax.swing.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.util.Objects; import java.util.Vector; /** @@ -105,7 +106,7 @@ public Event dispatchEvent(Event event) { showMessageFor(html, event); Event output = animateEvent(event); - if (event.getMessage() != output.getMessage()) + if (!Objects.equals(event.getMessage(), output.getMessage())) showMessageFor(html, output); if (oneStep && event instanceof AlgorithmStep) { @@ -123,7 +124,7 @@ public Event dispatchEvent(Event event) { } private void showMessageFor(GHTMLPageComponent html, Event event1) { - if (event1 != null && event1.getMessage() != null && event1.getMessage() != "") { + if (event1 != null && event1.getMessage() != null && !Objects.equals(event1.getMessage(), "")) { html.appendHTML(event1.getMessage()); } } diff --git a/src/graphtea/plugins/algorithmanimator/core/atoms/GraphSelect.java b/src/graphtea/plugins/algorithmanimator/core/atoms/GraphSelect.java index 48240f0a..817a47c9 100755 --- a/src/graphtea/plugins/algorithmanimator/core/atoms/GraphSelect.java +++ b/src/graphtea/plugins/algorithmanimator/core/atoms/GraphSelect.java @@ -15,10 +15,6 @@ * @author Azin Azadi */ public class GraphSelect implements AtomAnimator { -/// public boolean isAnimatable(Event event) { -// return event instanceof VertexRequest; -// } - public boolean isAnimatable(Event e) { return e instanceof GraphRequest; } diff --git a/src/graphtea/plugins/algorithmanimator/core/atoms/PrePostWork.java b/src/graphtea/plugins/algorithmanimator/core/atoms/PrePostWork.java index add6c412..878d3ce9 100755 --- a/src/graphtea/plugins/algorithmanimator/core/atoms/PrePostWork.java +++ b/src/graphtea/plugins/algorithmanimator/core/atoms/PrePostWork.java @@ -20,7 +20,6 @@ * @author Azin Azadi */ public class PrePostWork implements AtomAnimator { - private PostWorkEvent t; PreWorkEvent tt; public boolean isAnimatable(Event event) { @@ -34,7 +33,7 @@ public Event animate(Event event, BlackBoard b) { return tt; } if (event instanceof PostWorkEvent) { - t = (PostWorkEvent) event; + PostWorkEvent t = (PostWorkEvent) event; leave(t.to); return t; } diff --git a/src/graphtea/plugins/algorithmanimator/core/atoms/extension/AtomAnimatorExtensionAction.java b/src/graphtea/plugins/algorithmanimator/core/atoms/extension/AtomAnimatorExtensionAction.java index 2773dd1e..8eded660 100755 --- a/src/graphtea/plugins/algorithmanimator/core/atoms/extension/AtomAnimatorExtensionAction.java +++ b/src/graphtea/plugins/algorithmanimator/core/atoms/extension/AtomAnimatorExtensionAction.java @@ -10,11 +10,9 @@ public class AtomAnimatorExtensionAction extends AbstractExtensionAction { - private final AtomAnimatorExtension em; public AtomAnimatorExtensionAction(BlackBoard bb, AtomAnimatorExtension sp) { super(bb, sp); - this.em = sp; } @Override diff --git a/src/graphtea/plugins/commandline/ShellConsole.java b/src/graphtea/plugins/commandline/ShellConsole.java index f0e6d73e..520b696c 100755 --- a/src/graphtea/plugins/commandline/ShellConsole.java +++ b/src/graphtea/plugins/commandline/ShellConsole.java @@ -57,7 +57,6 @@ public PrintStream getErr() { private final JPopupMenu menu; private final JTextPane text; - private final DefaultStyledDocument doc; NameCompletion nameCompletion; final int SHOW_AMBIG_MAX = 15; @@ -84,6 +83,7 @@ public ShellConsole(InputStream cin, OutputStream cout) { // Special TextPane which catches for cut and paste, both L&F keys and // programmatic behaviour + DefaultStyledDocument doc; text = new JTextPane(doc = new DefaultStyledDocument()) { public void cut() { if (text.getCaretPosition() < cmdStart) { @@ -312,7 +312,7 @@ private void doCommandCompletion(String part) { part = part.substring(i + 1); - if (part.length() < 1) // reasonable completion length + if (part.isEmpty()) // reasonable completion length return; @@ -409,7 +409,7 @@ private void forceCaretMoveToStart() { private void enter() { String s = getCmd(); - if (s.length() == 0) // special hack for empty return! + if (s.isEmpty()) // special hack for empty return! s = ";\n"; else { history.addElement(s); @@ -434,7 +434,7 @@ private String getCmd() { } private void historyUp() { - if (history.size() == 0) + if (history.isEmpty()) return; if (histLine == 0) // save current line startedLine = getCmd(); diff --git a/src/graphtea/plugins/commandline/commands/NativeCommands.java b/src/graphtea/plugins/commandline/commands/NativeCommands.java index d568c1ad..98c8f168 100755 --- a/src/graphtea/plugins/commandline/commands/NativeCommands.java +++ b/src/graphtea/plugins/commandline/commands/NativeCommands.java @@ -19,12 +19,9 @@ * @author Mohammad Ali Rostami */ public class NativeCommands { - private final BlackBoard bb; - private final GraphData datas; public NativeCommands(BlackBoard bb) { - this.bb = bb; - datas = new GraphData(bb); + GraphData datas = new GraphData(bb); } private native String homomorph(String graph_format1, String graph_format2); diff --git a/src/graphtea/plugins/commandline/commands/ShellServerCommands.java b/src/graphtea/plugins/commandline/commands/ShellServerCommands.java index a079fd0d..7f8cbbe4 100755 --- a/src/graphtea/plugins/commandline/commands/ShellServerCommands.java +++ b/src/graphtea/plugins/commandline/commands/ShellServerCommands.java @@ -103,6 +103,6 @@ public void error(Object object) { , description = "") public void exit() { - thread.stop(); + thread.interrupt(); } } diff --git a/src/graphtea/plugins/commandline/extensionloader/BSHExtensionLoader.java b/src/graphtea/plugins/commandline/extensionloader/BSHExtensionLoader.java index a034974a..f784b9af 100755 --- a/src/graphtea/plugins/commandline/extensionloader/BSHExtensionLoader.java +++ b/src/graphtea/plugins/commandline/extensionloader/BSHExtensionLoader.java @@ -38,11 +38,11 @@ public Extension ExtensionLoader(String extFileName) { System.err.println("File not Found"); } do { + assert s != null; String line = s.nextLine(); if (!lineComment) { if (line.contains("/*")) { - if (!lineComment) line = line.substring(0, line.indexOf("/*")); lineComment = true; } diff --git a/src/graphtea/plugins/commandline/parsers/DefaultParser.java b/src/graphtea/plugins/commandline/parsers/DefaultParser.java index 0baa0312..b446c59e 100755 --- a/src/graphtea/plugins/commandline/parsers/DefaultParser.java +++ b/src/graphtea/plugins/commandline/parsers/DefaultParser.java @@ -171,7 +171,7 @@ public String parse(String statement) { int bracketIndex = statement.indexOf("["); String p = statement.substring(0, bracketIndex); p = p.trim(); - if (p.length() != 0) { + if (!p.isEmpty()) { if (p.charAt(p.length() - 1) == '=' || p.charAt(p.length() - 1) == '(' || p.charAt(p.length() - 1) == ',') { int rbracet = eatExtraBracket(statement, bracketIndex); diff --git a/src/graphtea/plugins/commonplugin/undo/UndoAction.java b/src/graphtea/plugins/commonplugin/undo/UndoAction.java index 1480b91b..fc96a38d 100755 --- a/src/graphtea/plugins/commonplugin/undo/UndoAction.java +++ b/src/graphtea/plugins/commonplugin/undo/UndoAction.java @@ -28,7 +28,7 @@ public void pushUndo(GraphModel g) { redoers.put(g, new Stack<>()); //reset redo for this graph - if (undoers.get(g) == null || undoers.get(g).size() == 0) { + if (undoers.get(g) == null || undoers.get(g).isEmpty()) { undoers.put(g, new Stack<>()); undoers.get(g).push(gso); return; @@ -57,7 +57,7 @@ public void pushUndo(GraphModel g) { public GraphSaveObject popUndo(GraphModel label) { if (undoers.get(label) == null) return null; - if (undoers.get(label).size() == 0) return null; + if (undoers.get(label).isEmpty()) return null; GraphSaveObject temp = undoers.get(label).pop(); redoers.putIfAbsent(label, new Stack<>()); redoers.get(label).push(temp); @@ -66,7 +66,7 @@ public GraphSaveObject popUndo(GraphModel label) { public GraphSaveObject popRedo(GraphModel label) { if (redoers.get(label) == null) return null; - if (redoers.get(label).size() == 0) return null; + if (redoers.get(label).isEmpty()) return null; GraphSaveObject temp = redoers.get(label).pop(); if (undoers.get(label) != null) undoers.get(label).push(temp); return temp; diff --git a/src/graphtea/plugins/main/Init.java b/src/graphtea/plugins/main/Init.java index 2f8d2b22..71be61df 100755 --- a/src/graphtea/plugins/main/Init.java +++ b/src/graphtea/plugins/main/Init.java @@ -27,6 +27,7 @@ import java.net.MalformedURLException; import java.net.URL; import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; import java.util.LinkedList; import static graphtea.platform.StaticUtils.addExceptionLog; @@ -126,7 +127,7 @@ public static void trackError(String stacktrace) { static LinkedList tracks = new LinkedList<>(); public static String encode(String in){ try{ - return URLEncoder.encode(in, "UTF-8").replace("+", "%20"); + return URLEncoder.encode(in, StandardCharsets.UTF_8).replace("+", "%20"); } catch (Exception e) {e.printStackTrace(); return in;} } public static void sendEvent(AEvent e) { diff --git a/src/graphtea/plugins/main/core/actions/edge/AddEdge.java b/src/graphtea/plugins/main/core/actions/edge/AddEdge.java index b03a82c2..d794ce88 100755 --- a/src/graphtea/plugins/main/core/actions/edge/AddEdge.java +++ b/src/graphtea/plugins/main/core/actions/edge/AddEdge.java @@ -28,7 +28,6 @@ public class AddEdge extends AbstractAction implements PaintHandler { // private double lasty; // private double lastx; private GPoint lastPos; - private final SelectPluginMethods selMethods; /** * constructor @@ -37,7 +36,7 @@ public class AddEdge extends AbstractAction implements PaintHandler { */ public AddEdge(BlackBoard bb) { super(bb); - selMethods = new SelectPluginMethods(bb); + SelectPluginMethods selMethods = new SelectPluginMethods(bb); listen4Event(VertexEvent.EVENT_KEY); // listen4Event(GraphEvent.name); // listen4Event(VertexDropData.event); diff --git a/src/graphtea/plugins/main/core/actions/edge/DragEdge.java b/src/graphtea/plugins/main/core/actions/edge/DragEdge.java index ca66d3b0..d4335096 100755 --- a/src/graphtea/plugins/main/core/actions/edge/DragEdge.java +++ b/src/graphtea/plugins/main/core/actions/edge/DragEdge.java @@ -44,7 +44,7 @@ public DragEdge(BlackBoard bb) { // protected int y1; // protected int cx; // protected int cy; - private GPoint lastPos, firstPos, cpfirstPos; + private GPoint lastPos; private GPoint clickPos; public void track(){} @@ -59,8 +59,8 @@ public void performAction(String eventName, Object value) { if (ee.eventType == EdgeEvent.DRAGGING_STARTED) { // if (ee.mouseBtn == MouseEvent.BUTTON3) { lastPos = ee.mousePos; - firstPos = ee.mousePos; - cpfirstPos = edge.getCurveControlPoint(); + GPoint firstPos = ee.mousePos; + GPoint cpfirstPos = edge.getCurveControlPoint(); // startPainting(ee.e); // } // else { diff --git a/src/graphtea/plugins/main/core/actions/vertex/AddVertex.java b/src/graphtea/plugins/main/core/actions/vertex/AddVertex.java index 47fe378a..f36b3eb5 100755 --- a/src/graphtea/plugins/main/core/actions/vertex/AddVertex.java +++ b/src/graphtea/plugins/main/core/actions/vertex/AddVertex.java @@ -59,7 +59,7 @@ public void performAction(String key, Object value) { if (aBoolean == null) return; boolean b = aBoolean; - if (b && (sd == null || (sd.vertices.size() == 0 && sd.edges.size() == 0))) { + if (b && (sd == null || (sd.vertices.isEmpty() && sd.edges.isEmpty()))) { GraphEvent gpd = blackboard.getData(GraphEvent.EVENT_KEY); if (gpd.eventType != GraphEvent.CLICKED || gpd.mouseBtn != MouseEvent.BUTTON1) { return; diff --git a/src/graphtea/plugins/main/saveload/core/extension/GraphIOExtensionHandler.java b/src/graphtea/plugins/main/saveload/core/extension/GraphIOExtensionHandler.java index 0dc34b74..832bc63d 100755 --- a/src/graphtea/plugins/main/saveload/core/extension/GraphIOExtensionHandler.java +++ b/src/graphtea/plugins/main/saveload/core/extension/GraphIOExtensionHandler.java @@ -21,7 +21,6 @@ */ public class GraphIOExtensionHandler implements ExtensionHandler, StorableOnExit { private final boolean handlingReaders; - private AbstractAction a = null; { SETTINGS.registerSetting(this, "Only Storable"); @@ -43,7 +42,7 @@ public GraphIOExtensionHandler(boolean isHandlingReaders) { * @return null if ext doesn't implements GraphReaderExtension */ public AbstractAction handle(BlackBoard b, Object ext) { - a = null; + AbstractAction a = null; if (!handlingReaders) { if (ext instanceof GraphWriterExtension) { try { diff --git a/src/graphtea/plugins/main/saveload/matrix/SaveMatrix.java b/src/graphtea/plugins/main/saveload/matrix/SaveMatrix.java index 67ed6902..8ec1332e 100755 --- a/src/graphtea/plugins/main/saveload/matrix/SaveMatrix.java +++ b/src/graphtea/plugins/main/saveload/matrix/SaveMatrix.java @@ -49,7 +49,7 @@ public String getDescription() { public static void saveMatrixes(File file, GraphModel g, boolean isDirected) throws IOException { FileWriter output = new FileWriter(file,true); - output.append(System.getProperty("line.separator")); + output.append(System.lineSeparator()); output.append(Matrix.Matrix2String(Matrix.graph2Matrix(g))); output.close(); } diff --git a/src/graphtea/plugins/main/saveload/xmlparser/GraphmlHandlerImpl.java b/src/graphtea/plugins/main/saveload/xmlparser/GraphmlHandlerImpl.java index 671b00cb..f23c24f0 100755 --- a/src/graphtea/plugins/main/saveload/xmlparser/GraphmlHandlerImpl.java +++ b/src/graphtea/plugins/main/saveload/xmlparser/GraphmlHandlerImpl.java @@ -25,7 +25,6 @@ public class GraphmlHandlerImpl implements GraphmlHandler { public GraphModel g; private Vertex curv = null; - private Edge cure = null; public BlackBoard bb; private VertexAttrSet curvAS; private EdgeAttrSet cureAS; @@ -85,7 +84,6 @@ public void start_edge(final Attributes meta) throws SAXException { //todo: the id can not be setted (it's a fix value) // e.setID(meta.getValue(Edge.ID)); g.insertEdge(e); - cure = e; cureAS = new EdgeAttrSet(e); if (DEBUG) System.err.println("start_edge: " + meta); } diff --git a/src/graphtea/plugins/main/select/ClearSelection.java b/src/graphtea/plugins/main/select/ClearSelection.java index 7a184586..97db2742 100755 --- a/src/graphtea/plugins/main/select/ClearSelection.java +++ b/src/graphtea/plugins/main/select/ClearSelection.java @@ -36,16 +36,14 @@ public ClearSelection(BlackBoard bb) { } public void track(){} - private SubGraph sd; - public void performAction(String eventName, Object value) { GraphEvent gpd = (GraphEvent) value; if (gpd.eventType != GraphEvent.CLICKED) { return; } - sd = Select.getSelection(blackboard); - if (sd.vertices.size() != 0 || sd.edges.size() != 0) { + SubGraph sd = Select.getSelection(blackboard); + if (!sd.vertices.isEmpty() || !sd.edges.isEmpty()) { blackboard.setData(lastTimeGraphWasClear, false); clearSelected(blackboard); super.track(); diff --git a/src/graphtea/plugins/main/select/MoveSelected.java b/src/graphtea/plugins/main/select/MoveSelected.java index 77487cdd..60db1bfe 100755 --- a/src/graphtea/plugins/main/select/MoveSelected.java +++ b/src/graphtea/plugins/main/select/MoveSelected.java @@ -40,7 +40,6 @@ public void track(){} GraphData gd; - private GPoint[] verticesPositionsBackUp; public void performAction(String eventName, Object value) { gv = blackboard.getData(AbstractGraphRenderer.EVENT_KEY); @@ -56,7 +55,7 @@ public void performAction(String eventName, Object value) { if (sd.vertices.contains(vdd.v)) //start if the vertex selected { if (vdd.eventType == VertexEvent.DRAGGING_STARTED) { - verticesPositionsBackUp = new GPoint[gd.getGraph().getVerticesCount()]; + GPoint[] verticesPositionsBackUp = new GPoint[gd.getGraph().getVerticesCount()]; for (Vertex vertex : gd.getGraph()) { verticesPositionsBackUp[vertex.getId()] = vertex.getLocation(); } diff --git a/src/graphtea/plugins/main/select/SelectPluginMethods.java b/src/graphtea/plugins/main/select/SelectPluginMethods.java index 30410fea..39d06a65 100755 --- a/src/graphtea/plugins/main/select/SelectPluginMethods.java +++ b/src/graphtea/plugins/main/select/SelectPluginMethods.java @@ -76,7 +76,7 @@ public void setSelectedEdges(Collection selectedEdges) { } public boolean isSelectionEmpty() { - return getSelectedEdges().size() == 0 && getSelectedVertices().size() == 0; + return getSelectedEdges().isEmpty() && getSelectedVertices().isEmpty(); } public void clearSelection() { diff --git a/src/graphtea/plugins/main/ui/GraphColoringRenderer.java b/src/graphtea/plugins/main/ui/GraphColoringRenderer.java index ceef036b..2622b4d9 100755 --- a/src/graphtea/plugins/main/ui/GraphColoringRenderer.java +++ b/src/graphtea/plugins/main/ui/GraphColoringRenderer.java @@ -34,13 +34,13 @@ public Component getRendererComponent(GraphColoring coloring) { if (myColoring.label != null && !myColoring.label.equals("")) { txt = txt + "" + myColoring.label + ": "; } - if (myColoring.vertexColors != null && myColoring.vertexColors.size() > 0) { + if (myColoring.vertexColors != null && !myColoring.vertexColors.isEmpty()) { txt = txt + "Vertex colors: "; for (Map.Entry p : myColoring.vertexColors.entrySet()) { txt = txt + p.getKey().getLabel() + ":" + p.getValue() + " , "; } } - if (myColoring.edgeColors != null && myColoring.edgeColors.size() > 0) { + if (myColoring.edgeColors != null && !myColoring.edgeColors.isEmpty()) { txt = txt + "
Edge colors: "; for (Map.Entry p : myColoring.edgeColors.entrySet()) { txt = txt + p.getKey().getLabel() + ":" + p.getValue() + " , "; diff --git a/src/graphtea/plugins/main/ui/SubGraphRenderer.java b/src/graphtea/plugins/main/ui/SubGraphRenderer.java index c5011a15..248f0679 100755 --- a/src/graphtea/plugins/main/ui/SubGraphRenderer.java +++ b/src/graphtea/plugins/main/ui/SubGraphRenderer.java @@ -36,14 +36,14 @@ public Component getRendererComponent(SubGraph sd) { txt += "" + mysd.label + ":
"; } - if (mysd.vertices != null && mysd.vertices.size() > 0) { + if (mysd.vertices != null && !mysd.vertices.isEmpty()) { txt = txt + "V: {"; for (Vertex v : mysd.vertices) { txt = txt + v.getLabel() + ", "; } txt = txt.substring(0, txt.length() - 2) + "}"; } - if (mysd.edges != null && mysd.edges.size() > 0) { + if (mysd.edges != null && !mysd.edges.isEmpty()) { txt += "
E: {"; for (Edge e : mysd.edges) { txt = txt + e.source.getLabel() + "-"+ e.target.getLabel() + ", "; diff --git a/src/graphtea/plugins/visualization/circular/CircularDispatchVisualization.java b/src/graphtea/plugins/visualization/circular/CircularDispatchVisualization.java index 3afbfcc2..8eed3f27 100755 --- a/src/graphtea/plugins/visualization/circular/CircularDispatchVisualization.java +++ b/src/graphtea/plugins/visualization/circular/CircularDispatchVisualization.java @@ -114,7 +114,7 @@ private void findCycle(Vector currentLevel, int minLength, int color) { } } - if (nextLevel.size() != 0) { + if (!nextLevel.isEmpty()) { findCycle(nextLevel, minLength, color + 1); } else { return; @@ -136,7 +136,7 @@ private int maxHeight(Vector currentLevel, int maxLevel) { } } maxLevel++; - if (nextLevel.size() != 0) { + if (!nextLevel.isEmpty()) { return maxHeight(nextLevel, maxLevel); } else { return maxLevel; diff --git a/src/graphtea/plugins/visualization/hierarchical/BendedTrees.java b/src/graphtea/plugins/visualization/hierarchical/BendedTrees.java index abf118ea..f989b49b 100755 --- a/src/graphtea/plugins/visualization/hierarchical/BendedTrees.java +++ b/src/graphtea/plugins/visualization/hierarchical/BendedTrees.java @@ -74,7 +74,7 @@ private int BFS(Vector marked, Vector currentLevel, int maxLevel } } maxLevel++; - if (nextLevel.size() != 0) { + if (!nextLevel.isEmpty()) { return BFS(marked, nextLevel, maxLevel); } else { return maxLevel; diff --git a/src/graphtea/plugins/visualization/treevisualizations/BackwardTrees.java b/src/graphtea/plugins/visualization/treevisualizations/BackwardTrees.java index e17dba86..f4ea3670 100755 --- a/src/graphtea/plugins/visualization/treevisualizations/BackwardTrees.java +++ b/src/graphtea/plugins/visualization/treevisualizations/BackwardTrees.java @@ -74,7 +74,7 @@ private int BFS(Vector currentLevel, int maxLevel) { } } maxLevel++; - if (nextLevel.size() != 0) { + if (!nextLevel.isEmpty()) { return BFS(nextLevel, maxLevel); } else { return maxLevel; @@ -83,7 +83,7 @@ private int BFS(Vector currentLevel, int maxLevel) { public Vector findNextLevelChildren(Vector currentLevelVertices) { Vector newChildren = new Vector<>(); - if (currentLevelVertices.size() != 0) { + if (!currentLevelVertices.isEmpty()) { for (Vertex v : currentLevelVertices) { Iterator e = g.edgeIterator(v); while (e.hasNext()) { diff --git a/src/graphtea/plugins/visualization/treevisualizations/CircularTreeVisualization.java b/src/graphtea/plugins/visualization/treevisualizations/CircularTreeVisualization.java index 568a8da4..6699720f 100755 --- a/src/graphtea/plugins/visualization/treevisualizations/CircularTreeVisualization.java +++ b/src/graphtea/plugins/visualization/treevisualizations/CircularTreeVisualization.java @@ -75,7 +75,7 @@ private int maxHeight(Vector currentLevel, int maxLevel) { } } maxLevel++; - if (nextLevel.size() != 0) { + if (!nextLevel.isEmpty()) { return maxHeight(nextLevel, maxLevel); } else { return maxLevel; diff --git a/src/graphtea/plugins/visualization/treevisualizations/HierarchicalTreeVisualization.java b/src/graphtea/plugins/visualization/treevisualizations/HierarchicalTreeVisualization.java index c8315780..56fad116 100755 --- a/src/graphtea/plugins/visualization/treevisualizations/HierarchicalTreeVisualization.java +++ b/src/graphtea/plugins/visualization/treevisualizations/HierarchicalTreeVisualization.java @@ -91,7 +91,7 @@ private int BFS(Vector currentLevel, int maxLevel) { } } maxLevel++; - if (nextLevel.size() != 0) { + if (!nextLevel.isEmpty()) { return BFS(nextLevel, maxLevel); } else { return maxLevel; @@ -100,7 +100,7 @@ private int BFS(Vector currentLevel, int maxLevel) { public Vector findNextLevelChildren(Vector currentLevelVertices) { Vector newChildren = new Vector<>(); - if (currentLevelVertices.size() != 0) { + if (!currentLevelVertices.isEmpty()) { for (Vertex v : currentLevelVertices) { Iterator e = g.edgeIterator(v); while (e.hasNext()) { diff --git a/src/graphtea/plugins/visualization/treevisualizations/SparseTreeVisualization.java b/src/graphtea/plugins/visualization/treevisualizations/SparseTreeVisualization.java index 6c2f337b..c449e7d3 100755 --- a/src/graphtea/plugins/visualization/treevisualizations/SparseTreeVisualization.java +++ b/src/graphtea/plugins/visualization/treevisualizations/SparseTreeVisualization.java @@ -67,7 +67,7 @@ private int BFS(Vector currentLevel, int maxLevel) { } } maxLevel++; - if (nextLevel.size() != 0) { + if (!nextLevel.isEmpty()) { return BFS(nextLevel, maxLevel); } else { return maxLevel; diff --git a/src/graphtea/samples/ui/texteditor/myplugin/actions/ReadWriteTextFile.java b/src/graphtea/samples/ui/texteditor/myplugin/actions/ReadWriteTextFile.java index 2e4100d9..7c874ed7 100755 --- a/src/graphtea/samples/ui/texteditor/myplugin/actions/ReadWriteTextFile.java +++ b/src/graphtea/samples/ui/texteditor/myplugin/actions/ReadWriteTextFile.java @@ -34,7 +34,7 @@ static public String getContents(File aFile) { * it returns an empty String if two newlines appear in a row. */ while ((line = input.readLine()) != null) { - contents.append(line).append(System.getProperty("line.separator")); + contents.append(line).append(System.lineSeparator()); } } catch (IOException ex) { ex.printStackTrace(); @@ -84,7 +84,7 @@ static public void setContents(File aFile, String aContents) try { //use buffering //FileWriter always assumes default encoding is OK! - aContents = aContents.replaceAll("\n", System.getProperty("line.separator")); + aContents = aContents.replaceAll("\n", System.lineSeparator()); output = new BufferedWriter(new FileWriter(aFile)); output.write(aContents); } diff --git a/src/graphtea/ui/components/ExtensionConfigFrame.java b/src/graphtea/ui/components/ExtensionConfigFrame.java index 10f60174..c596861f 100755 --- a/src/graphtea/ui/components/ExtensionConfigFrame.java +++ b/src/graphtea/ui/components/ExtensionConfigFrame.java @@ -67,13 +67,14 @@ public ExtensionConfigFrame(Extension e, final ExtensionExternalData data) { private void initComponents() { java.awt.GridBagConstraints gridBagConstraints; - jPanel1 = new javax.swing.JPanel(); - jLabel1 = new javax.swing.JLabel(); + JPanel jPanel1 = new JPanel(); + JLabel jLabel1 = new JLabel(); extensionParametersPanel = new javax.swing.JPanel(); - jPanel2 = new javax.swing.JPanel(); + JPanel jPanel2 = new JPanel(); helpBtn = new javax.swing.JButton(); sourceCodeBtn = new javax.swing.JButton(); - descriptionLabel = new javax.swing.JLabel(); + // Variables declaration - do not modify + JLabel descriptionLabel = new JLabel(); getContentPane().setLayout(new java.awt.GridBagLayout()); @@ -127,13 +128,8 @@ private void initComponents() { }// - // Variables declaration - do not modify - private javax.swing.JLabel descriptionLabel; private javax.swing.JPanel extensionParametersPanel; private javax.swing.JButton helpBtn; - private javax.swing.JLabel jLabel1; - private javax.swing.JPanel jPanel1; - private javax.swing.JPanel jPanel2; private javax.swing.JButton sourceCodeBtn; // End of variables declaration diff --git a/src/graphtea/ui/components/GStatusBar.java b/src/graphtea/ui/components/GStatusBar.java index ceb48917..71d4fc03 100755 --- a/src/graphtea/ui/components/GStatusBar.java +++ b/src/graphtea/ui/components/GStatusBar.java @@ -19,11 +19,9 @@ public class GStatusBar extends JPanel { * */ private static final long serialVersionUID = 7638151469264118382L; - private final BlackBoard blackboard; public GStatusBar(BlackBoard blackboard) { super(); - this.blackboard = blackboard; FlowLayout l = new FlowLayout(FlowLayout.LEFT, 1, 1); setLayout(l); setBorder(new EmptyBorder(1, 1, 0, 1)); diff --git a/src/graphtea/ui/components/GToolbar.java b/src/graphtea/ui/components/GToolbar.java index 8eb4b56c..a14bc1b5 100755 --- a/src/graphtea/ui/components/GToolbar.java +++ b/src/graphtea/ui/components/GToolbar.java @@ -73,11 +73,9 @@ public JToolBar getLastToolBar() { } class pair implements Comparator { - private final JToolBar b; private final Integer index; public pair(JToolBar j, Integer index) { - this.b = j; this.index = index; } diff --git a/src/graphtea/ui/components/gpropertyeditor/utils/JFontChooser.java b/src/graphtea/ui/components/gpropertyeditor/utils/JFontChooser.java index b4b9a8dc..d20ac7c9 100755 --- a/src/graphtea/ui/components/gpropertyeditor/utils/JFontChooser.java +++ b/src/graphtea/ui/components/gpropertyeditor/utils/JFontChooser.java @@ -24,9 +24,6 @@ public class JFontChooser extends JComponent { private final JCheckBox cbItalic; private final JTextArea txtSample; - private final String[] sizes = new String[] - {"2", "4", "6", "8", "10", "12", "13", "14", "16", "18", "20", "22", "24", "30", "36", "48", "72"}; - public JFontChooser() { // create all components @@ -41,6 +38,8 @@ public Dimension getPreferredScrollableViewportSize() { fontList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + String[] sizes = new String[] + {"2", "4", "6", "8", "10", "12", "13", "14", "16", "18", "20", "22", "24", "30", "36", "48", "72"}; sizeList = new JList(sizes) { private static final long serialVersionUID = -2474666139561694389L; diff --git a/src/graphtea/ui/components/gsidebar/GSideBarPanel.java b/src/graphtea/ui/components/gsidebar/GSideBarPanel.java index 2ab0a4e3..06006d4d 100755 --- a/src/graphtea/ui/components/gsidebar/GSideBarPanel.java +++ b/src/graphtea/ui/components/gsidebar/GSideBarPanel.java @@ -33,9 +33,10 @@ public GSideBarPanel(GBody gBody, Component leftPanel, String label) { } private void initComponents() { - jPanel1 = new javax.swing.JPanel(); + javax.swing.JPanel jPanel1 = new javax.swing.JPanel(); jLabel1 = new javax.swing.JLabel(); - jButton1 = new javax.swing.JButton(); + // Variables declaration - do not modify + javax.swing.JButton jButton1 = new javax.swing.JButton(); jPanel2 = new javax.swing.JPanel(); setLayout(new java.awt.BorderLayout()); @@ -75,10 +76,7 @@ private void jButton1MouseDragged(java.awt.event.MouseEvent evt) { } - // Variables declaration - do not modify - private javax.swing.JButton jButton1; private javax.swing.JLabel jLabel1; - private javax.swing.JPanel jPanel1; public javax.swing.JPanel jPanel2; // End of variables declaration diff --git a/src/graphtea/ui/components/prefeditor/GPrefPane.java b/src/graphtea/ui/components/prefeditor/GPrefPane.java index cd4695f9..340b2f06 100755 --- a/src/graphtea/ui/components/prefeditor/GPrefPane.java +++ b/src/graphtea/ui/components/prefeditor/GPrefPane.java @@ -30,7 +30,6 @@ public class GPrefPane extends GFrame { private final GPropertyEditor tabPane; private final JButton ok; private final JButton cancel; - private final JButton apply; private final JLabel label; // End of variables declaration @@ -49,7 +48,7 @@ public GPrefPane(BlackBoard bb, HashMap items) { cancel = new JButton("Cancel"); cancel.addActionListener(e -> closeDialog()); - apply = new JButton("Apply"); + JButton apply = new JButton("Apply"); label = new JLabel("Preferences:"); setLayout(new java.awt.GridBagLayout()); @@ -186,16 +185,12 @@ private void jList1ValueChanged(javax.swing.event.ListSelectionEvent evt) { setTab(); } - private boolean status = false; - private boolean finished = false; - private void closeDialog() { - finished = true; + boolean finished = true; dispose(); } private void finished(boolean status) { - this.status = status; closeDialog(); dispose(); } diff --git a/src/graphtea/ui/components/prefeditor/GTabbedAttributeFrame.java b/src/graphtea/ui/components/prefeditor/GTabbedAttributeFrame.java index bc7918ef..7a14fd22 100755 --- a/src/graphtea/ui/components/prefeditor/GTabbedAttributeFrame.java +++ b/src/graphtea/ui/components/prefeditor/GTabbedAttributeFrame.java @@ -86,10 +86,9 @@ public void keyTyped(KeyEvent e) { } private boolean status = false; - private boolean finished = false; private void closeDialog() { - finished = true; + boolean finished = true; } private void finished(boolean status) { diff --git a/src/graphtea/ui/components/prefeditor/GTabbedAttributePane.java b/src/graphtea/ui/components/prefeditor/GTabbedAttributePane.java index ae84b11b..90f7f3f3 100755 --- a/src/graphtea/ui/components/prefeditor/GTabbedAttributePane.java +++ b/src/graphtea/ui/components/prefeditor/GTabbedAttributePane.java @@ -96,10 +96,9 @@ public void initComponents() { } private boolean status = false; - private boolean finished = false; private void closeDialog() { - finished = true; + boolean finished = true; } private void finished(boolean status) { diff --git a/src/graphtea/ui/components/utils/GAttrFrame.java b/src/graphtea/ui/components/utils/GAttrFrame.java index 6e55d6e8..f325155f 100755 --- a/src/graphtea/ui/components/utils/GAttrFrame.java +++ b/src/graphtea/ui/components/utils/GAttrFrame.java @@ -75,10 +75,9 @@ public void keyTyped(KeyEvent e) { } private boolean status = false; - private boolean finished = false; private void closeDialog() { - finished = true; + boolean finished = true; } private void finished(boolean status) { diff --git a/test/BasicReportsTest.java b/src/test/BasicReportsTest.java similarity index 60% rename from test/BasicReportsTest.java rename to src/test/BasicReportsTest.java index d31819e6..105239a5 100755 --- a/test/BasicReportsTest.java +++ b/src/test/BasicReportsTest.java @@ -1,15 +1,16 @@ +package test; + import graphtea.extensions.generators.CircleGenerator; import graphtea.extensions.generators.CompleteGraphGenerator; import graphtea.extensions.generators.GeneralizedPetersonGenerator; import graphtea.extensions.reports.basicreports.*; import graphtea.graph.graph.GraphModel; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; - +import org.junit.Assert; +import org.junit.Test; import java.util.ArrayList; public class BasicReportsTest { - GraphModel peterson = GeneralizedPetersonGenerator.generateGeneralizedPeterson(5,2); + GraphModel peterson = GeneralizedPetersonGenerator.generateGeneralizedPeterson(5, 2); GraphModel circle4 = CircleGenerator.generateCircle(4); GraphModel circle5 = CircleGenerator.generateCircle(5); GraphModel complete4 = CompleteGraphGenerator.generateCompleteGraph(4); @@ -18,64 +19,53 @@ public class BasicReportsTest { @Test public void testGirthSize() { GirthSize girthSize = new GirthSize(); - Assertions.assertEquals(girthSize.calculate(peterson),5); + Assert.assertEquals(5, girthSize.calculate(peterson).intValue()); } @Test public void testIsBipartite() { IsBipartite isBipartite = new IsBipartite(); - Assertions.assertTrue(isBipartite.calculate(circle4)); + Assert.assertTrue(isBipartite.calculate(circle4)); } @Test public void testIsEulerian() { IsEulerian isEulerian = new IsEulerian(); - Assertions.assertTrue(isEulerian.calculate(circle5)); - Assertions.assertTrue(isEulerian.calculate(complete5)); - Assertions.assertFalse(isEulerian.calculate(complete4)); + Assert.assertTrue(isEulerian.calculate(circle5)); + Assert.assertTrue(isEulerian.calculate(complete5)); + Assert.assertFalse(isEulerian.calculate(complete4)); } @Test public void testMaxAndMinDegree() { MaxAndMinDegree maxAndMinDegree = new MaxAndMinDegree(); ArrayList al = maxAndMinDegree.calculate(peterson); - Assertions.assertEquals(al.get(0),3); - Assertions.assertEquals(al.get(1),3); + Assert.assertEquals(3, al.get(0).intValue()); + Assert.assertEquals(3, al.get(1).intValue()); } @Test public void testNumOfConnectedComponents() { NumOfConnectedComponents numOfConnectedComponents = new NumOfConnectedComponents(); - Assertions.assertEquals(numOfConnectedComponents.calculate(peterson),1); + Assert.assertEquals(1, numOfConnectedComponents.calculate(peterson).intValue()); } @Test public void testNumOfEdges() { NumOfEdges numOfEdges = new NumOfEdges(); - Assertions.assertEquals(numOfEdges.calculate(peterson),15); + Assert.assertEquals(15, numOfEdges.calculate(peterson).intValue()); } @Test public void testNumOfVertices() { NumOfVertices numOfVertices = new NumOfVertices(); - Assertions.assertEquals(numOfVertices.calculate(peterson),10); + Assert.assertEquals(10, numOfVertices.calculate(peterson).intValue()); } @Test public void testNumOfVerticesWithDegK() { NumOfVerticesWithDegK numOfVerticesWithDegK = new NumOfVerticesWithDegK(); NumOfVerticesWithDegK.k = 3; - Assertions.assertEquals(numOfVerticesWithDegK.calculate(peterson),10); + Assert.assertEquals(10, numOfVerticesWithDegK.calculate(peterson).intValue()); } - -// -// @Test -// public void testPathsOfL - - -// @Test public void testDominationNumber() { -// DominationNumber dn = new DominationNumber(); -// Assertions.assertEquals( -// dn.calculate(GeneralizedPetersonGenerator.generateGeneralizedPeterson(5,2)), 3); -// } } \ No newline at end of file diff --git a/test/GeneratorsTest.java b/src/test/GeneratorsTest.java similarity index 69% rename from test/GeneratorsTest.java rename to src/test/GeneratorsTest.java index 9e66ba46..6062f904 100755 --- a/test/GeneratorsTest.java +++ b/src/test/GeneratorsTest.java @@ -1,11 +1,13 @@ +package test; import graphtea.extensions.generators.*; import graphtea.graph.graph.GraphModel; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; import graphtea.extensions.reports.basicreports.Diameter; import graphtea.extensions.reports.basicreports.GirthSize; import graphtea.extensions.reports.basicreports.MaxAndMinDegree; +import org.junit.Assert; +import org.junit.Test; + import java.util.ArrayList; public class GeneratorsTest { @@ -24,12 +26,12 @@ public void testWheelGenerator() { int minDegree = maxAndMinDegree.get(1); int girth = new GirthSize().calculate(g); int diameter = new Diameter().calculate(g); - Assertions.assertEquals(girth, 3); - Assertions.assertEquals(diameter, 2); - Assertions.assertEquals(numOfVertices, n); - Assertions.assertEquals(numOfEdges, 2*(n-1)); - Assertions.assertEquals(maxDegree, n - 1); - Assertions.assertEquals(minDegree, 3); + Assert.assertEquals(3, girth); + Assert.assertEquals(2, diameter); + Assert.assertEquals(numOfVertices, n); + Assert.assertEquals(numOfEdges, 2*(n-1)); + Assert.assertEquals(maxDegree, n - 1); + Assert.assertEquals(3, minDegree); } @Test @@ -47,12 +49,12 @@ public void testModifiedGeneralizedWebGraph() { int minDegree = maxAndMinDegree.get(1); int girth = new GirthSize().calculate(g); int diameter = new Diameter().calculate(g); - Assertions.assertEquals(girth, 3); - Assertions.assertEquals(diameter, n/2 + 2); - Assertions.assertEquals(numOfVertices, (t+1)*n + 1); - Assertions.assertEquals(numOfEdges, (2*t*n)+n); - Assertions.assertEquals(maxDegree, 4); - Assertions.assertEquals(minDegree, 1); + Assert.assertEquals(3, girth); + Assert.assertEquals(diameter, n/2 + 2); + Assert.assertEquals(numOfVertices, (long) (t + 1) *n + 1); + Assert.assertEquals(numOfEdges, (2L *t*n)+n); + Assert.assertEquals(4, maxDegree); + Assert.assertEquals(1, minDegree); } @Test @@ -68,12 +70,12 @@ public void testWebGraph() { int minDegree = maxAndMinDegree.get(1); int girth = new GirthSize().calculate(g); int diameter = new Diameter().calculate(g); - Assertions.assertEquals(girth, n); - Assertions.assertEquals(diameter, n/2 + 2); - Assertions.assertEquals(numOfVertices, 3*n ); - Assertions.assertEquals(numOfEdges, 4*n); - Assertions.assertEquals(maxDegree, 4); - Assertions.assertEquals(minDegree, 1); + Assert.assertEquals(girth, n); + Assert.assertEquals(diameter, n/2 + 2); + Assert.assertEquals(numOfVertices, 3*n ); + Assert.assertEquals(numOfEdges, 4*n); + Assert.assertEquals(4, maxDegree); + Assert.assertEquals(1, minDegree); } @Test @@ -90,12 +92,12 @@ public void testCompleteGraphGenerator() { int girth = new GirthSize().calculate(g); int diameter = new Diameter().calculate(g); //assume n is bigger than 3 - Assertions.assertEquals(girth, 3); - Assertions.assertEquals(diameter, 1); - Assertions.assertEquals(numOfVertices, n); - Assertions.assertEquals(numOfEdges, n*(n-1)/2); - Assertions.assertEquals(maxDegree, n-1); - Assertions.assertEquals(minDegree, n-1); + Assert.assertEquals(3, girth); + Assert.assertEquals(1, diameter); + Assert.assertEquals(numOfVertices, n); + Assert.assertEquals(numOfEdges, (long) n *(n-1)/2); + Assert.assertEquals(maxDegree, n-1); + Assert.assertEquals(minDegree, n-1); } @Test @@ -111,12 +113,12 @@ public void testCircleGenerator() { int minDegree = maxAndMinDegree.get(1); int girth = new GirthSize().calculate(g); int diameter = new Diameter().calculate(g); - Assertions.assertEquals(girth, n); - Assertions.assertEquals(diameter, n/2); - Assertions.assertEquals(numOfVertices, n); - Assertions.assertEquals(numOfEdges, n); - Assertions.assertEquals(maxDegree, 2); - Assertions.assertEquals(minDegree, 2); + Assert.assertEquals(girth, n); + Assert.assertEquals(diameter, n/2); + Assert.assertEquals(numOfVertices, n); + Assert.assertEquals(numOfEdges, n); + Assert.assertEquals(2, maxDegree); + Assert.assertEquals(2, minDegree); } @Test @@ -132,12 +134,12 @@ public void testPathGenerator() { int minDegree = maxAndMinDegree.get(1); int girth = new GirthSize().calculate(g); int diameter = new Diameter().calculate(g); - Assertions.assertEquals(girth, 0); - Assertions.assertEquals(diameter, n-1); - Assertions.assertEquals(numOfVertices, n); - Assertions.assertEquals(numOfEdges, n-1); - Assertions.assertEquals(maxDegree, 2); - Assertions.assertEquals(minDegree, 1); + Assert.assertEquals(0, girth); + Assert.assertEquals(diameter, n-1); + Assert.assertEquals(numOfVertices, n); + Assert.assertEquals(numOfEdges, n-1); + Assert.assertEquals(2, maxDegree); + Assert.assertEquals(1, minDegree); } @Test @@ -153,12 +155,12 @@ public void testHelmGraph() { int minDegree = maxAndMinDegree.get(1); int girth = new GirthSize().calculate(g); int diameter = new Diameter().calculate(g); - Assertions.assertEquals(girth, 3); - Assertions.assertEquals(diameter, 4); - Assertions.assertEquals(numOfVertices, 2*n+1); - Assertions.assertEquals(numOfEdges, 3*n); - Assertions.assertEquals(maxDegree, n); - Assertions.assertEquals(minDegree, 1); + Assert.assertEquals(3, girth); + Assert.assertEquals(4, diameter); + Assert.assertEquals(numOfVertices, 2L *n+1); + Assert.assertEquals(numOfEdges, 3*n); + Assert.assertEquals(maxDegree, n); + Assert.assertEquals(1, minDegree); } @Test @@ -176,12 +178,12 @@ public void testCmnGenerator() { int minDegree = maxAndMinDegree.get(1); int girth = new GirthSize().calculate(g); int diameter = new Diameter().calculate(g); - Assertions.assertEquals(girth, 4); - Assertions.assertEquals(diameter, n/2 + m/2);//??? - Assertions.assertEquals(numOfVertices, n * m); - Assertions.assertEquals(numOfEdges, 2*n * m);//??? - Assertions.assertEquals(maxDegree, 4); - Assertions.assertEquals(minDegree, 4); + Assert.assertEquals(4, girth); + Assert.assertEquals(diameter, n/2 + m/2);//??? + Assert.assertEquals(numOfVertices, n * m); + Assert.assertEquals(numOfEdges, 2*n * m);//??? + Assert.assertEquals(4, maxDegree); + Assert.assertEquals(4, minDegree); } // @Test @@ -197,12 +199,12 @@ public void testCmnGenerator() { // int minDegree = maxAndMinDegree.get(1); // int girth = new GirthSize().calculate(g); // int diameter = new Diameter().calculate(g); -// Assertions.assertEquals(girth, n); -// Assertions.assertEquals(diameter, n); -// Assertions.assertEquals(numOfVertices, n); -// Assertions.assertEquals(numOfEdges, n); -// Assertions.assertEquals(maxDegree, n); -// Assertions.assertEquals(minDegree, n); +// Assert.assertEquals(girth, n); +// Assert.assertEquals(diameter, n); +// Assert.assertEquals(numOfVertices, n); +// Assert.assertEquals(numOfEdges, n); +// Assert.assertEquals(maxDegree, n); +// Assert.assertEquals(minDegree, n); // } // // @Test @@ -218,12 +220,12 @@ public void testCmnGenerator() { // int minDegree = maxAndMinDegree.get(1); // int girth = new GirthSize().calculate(g); // int diameter = new Diameter().calculate(g); -// Assertions.assertEquals(girth, n); -// Assertions.assertEquals(diameter, n); -// Assertions.assertEquals(numOfVertices, n); -// Assertions.assertEquals(numOfEdges, n); -// Assertions.assertEquals(maxDegree, n); -// Assertions.assertEquals(minDegree, n); +// Assert.assertEquals(girth, n); +// Assert.assertEquals(diameter, n); +// Assert.assertEquals(numOfVertices, n); +// Assert.assertEquals(numOfEdges, n); +// Assert.assertEquals(maxDegree, n); +// Assert.assertEquals(minDegree, n); // } @Test @@ -240,12 +242,12 @@ public void testSunletCrownGraph() { int girth = new GirthSize().calculate(g); int diameter = new Diameter().calculate(g); //assume n >= 3 - Assertions.assertEquals(girth, n);//??? - Assertions.assertEquals(diameter, 2 + n/2); - Assertions.assertEquals(numOfVertices, 2*n); - Assertions.assertEquals(numOfEdges, 2*n); - Assertions.assertEquals(maxDegree, 3); - Assertions.assertEquals(minDegree, 1); + Assert.assertEquals(girth, n);//??? + Assert.assertEquals(diameter, 2 + n/2); + Assert.assertEquals(numOfVertices, 2*n); + Assert.assertEquals(numOfEdges, 2*n); + Assert.assertEquals(3, maxDegree); + Assert.assertEquals(1, minDegree); } @Test @@ -262,13 +264,13 @@ public void testCrownGraph() { int girth = new GirthSize().calculate(g); int diameter = new Diameter().calculate(g); //assume n >= 3 - if(n == 3) Assertions.assertEquals(girth, 6); - else Assertions.assertEquals(girth, 4); - Assertions.assertEquals(diameter, 3); - Assertions.assertEquals(numOfVertices, 2*n); - Assertions.assertEquals(numOfEdges, n*(n-1)); - Assertions.assertEquals(maxDegree, n - 1); - Assertions.assertEquals(minDegree, n - 1); + if(n == 3) Assert.assertEquals(6, girth); + else Assert.assertEquals(4, girth); + Assert.assertEquals(3, diameter); + Assert.assertEquals(numOfVertices, 2*n); + Assert.assertEquals(numOfEdges, n*(n-1)); + Assert.assertEquals(maxDegree, n - 1); + Assert.assertEquals(minDegree, n - 1); } @Test @@ -284,12 +286,12 @@ public void testPrismGraph() { int minDegree = maxAndMinDegree.get(1); int girth = new GirthSize().calculate(g); int diameter = new Diameter().calculate(g); - Assertions.assertEquals(girth, 4); - Assertions.assertEquals(diameter, n/2 + 1); - Assertions.assertEquals(numOfVertices, 2*n); - Assertions.assertEquals(numOfEdges, 3*n); - Assertions.assertEquals(maxDegree, 3); - Assertions.assertEquals(minDegree, 3); + Assert.assertEquals(4, girth); + Assert.assertEquals(diameter, n/2 + 1); + Assert.assertEquals(numOfVertices, 2*n); + Assert.assertEquals(numOfEdges, 3*n); + Assert.assertEquals(3, maxDegree); + Assert.assertEquals(3, minDegree); } @Test @@ -307,12 +309,12 @@ public void testBananaTreeGenerator() { int minDegree = maxAndMinDegree.get(1); int girth = new GirthSize().calculate(g); int diameter = new Diameter().calculate(g); - Assertions.assertEquals(girth, 0); - Assertions.assertEquals(diameter, 4); - Assertions.assertEquals(numOfVertices, n*k + 1); - Assertions.assertEquals(numOfEdges, n*k); - Assertions.assertEquals(maxDegree, Math.max(n,k)); - Assertions.assertEquals(minDegree, 1); + Assert.assertEquals(0, girth); + Assert.assertEquals(4, diameter); + Assert.assertEquals(numOfVertices, (long) n *k + 1); + Assert.assertEquals(numOfEdges, n*k); + Assert.assertEquals(maxDegree, Math.max(n,k)); + Assert.assertEquals(1, minDegree); } @Test @@ -331,12 +333,12 @@ public void testGeneralizedPetersonGenerator() { int minDegree = maxAndMinDegree.get(1); int girth = new GirthSize().calculate(g); int diameter = new Diameter().calculate(g); - Assertions.assertEquals(girth, 5); - Assertions.assertEquals(diameter, 2); - Assertions.assertEquals(numOfVertices, 10); - Assertions.assertEquals(numOfEdges, 15); - Assertions.assertEquals(maxDegree, 3); - Assertions.assertEquals(minDegree, 3); + Assert.assertEquals(5, girth); + Assert.assertEquals(2, diameter); + Assert.assertEquals(10, numOfVertices); + Assert.assertEquals(15, numOfEdges); + Assert.assertEquals(3, maxDegree); + Assert.assertEquals(3, minDegree); } @Test @@ -354,12 +356,12 @@ public void testTadpoleGenerator() { int minDegree = maxAndMinDegree.get(1); int girth = new GirthSize().calculate(g); int diameter = new Diameter().calculate(g); - Assertions.assertEquals(girth, n); - Assertions.assertEquals(diameter, n/2 + k); - Assertions.assertEquals(numOfVertices, k+n); - Assertions.assertEquals(numOfEdges, k+n); - Assertions.assertEquals(maxDegree, 3); - Assertions.assertEquals(minDegree, 1); + Assert.assertEquals(girth, n); + Assert.assertEquals(diameter, n/2 + k); + Assert.assertEquals(numOfVertices, k+n); + Assert.assertEquals(numOfEdges, k+n); + Assert.assertEquals(3, maxDegree); + Assert.assertEquals(1, minDegree); } @Test @@ -375,12 +377,12 @@ public void testAntiprismGraph() { int minDegree = maxAndMinDegree.get(1); int girth = new GirthSize().calculate(g); int diameter = new Diameter().calculate(g); - Assertions.assertEquals(girth, 3); - Assertions.assertEquals(diameter, n/2 + n%2); - Assertions.assertEquals(numOfVertices, 2*n); - Assertions.assertEquals(numOfEdges, 4*n); - Assertions.assertEquals(maxDegree, 4); - Assertions.assertEquals(minDegree, 4); + Assert.assertEquals(3, girth); + Assert.assertEquals(diameter, n/2 + n%2); + Assert.assertEquals(numOfVertices, 2*n); + Assert.assertEquals(numOfEdges, 4*n); + Assert.assertEquals(4, maxDegree); + Assert.assertEquals(4, minDegree); } @Test @@ -396,12 +398,12 @@ public void testGearGenerator() { int minDegree = maxAndMinDegree.get(1); int girth = new GirthSize().calculate(g); int diameter = new Diameter().calculate(g); - Assertions.assertEquals(girth, 4); - Assertions.assertEquals(diameter, 4); - Assertions.assertEquals(numOfVertices, 2*n+1); - Assertions.assertEquals(numOfEdges, 3*n); - Assertions.assertEquals(maxDegree, n); - Assertions.assertEquals(minDegree, 2); + Assert.assertEquals(4, girth); + Assert.assertEquals(4, diameter); + Assert.assertEquals(numOfVertices, 2L *n+1); + Assert.assertEquals(numOfEdges, 3*n); + Assert.assertEquals(maxDegree, n); + Assert.assertEquals(2, minDegree); } @Test @@ -419,12 +421,13 @@ public void testTreeGenerator() { int minDegree = maxAndMinDegree.get(1); int girth = new GirthSize().calculate(g); int diameter = new Diameter().calculate(g); - Assertions.assertEquals(girth, 0); - Assertions.assertEquals(diameter, 2*depth); - Assertions.assertEquals(numOfVertices, (Math.pow(degree, depth + 1) - 1) / (degree - 1)); - Assertions.assertEquals(numOfEdges, ((Math.pow(degree, depth + 1) - 1) / (degree - 1)) - 1); - Assertions.assertEquals(maxDegree, degree + 1); - Assertions.assertEquals(minDegree, 1); + Assert.assertEquals(0, girth); + Assert.assertEquals(diameter, 2*depth); + double actual_value = (Math.pow(degree, depth + 1) - 1) / (degree - 1); + Assert.assertEquals(numOfVertices, (int) actual_value); + Assert.assertEquals(numOfEdges, (int) actual_value - 1); + Assert.assertEquals(maxDegree, degree + 1); + Assert.assertEquals(1, minDegree); } @Test @@ -442,12 +445,12 @@ public void testRegularGraphGenerator() { int minDegree = maxAndMinDegree.get(1); int girth = new GirthSize().calculate(g); int diameter = new Diameter().calculate(g); - Assertions.assertEquals(girth, deg + 1); -// Assertions.assertEquals(diameter, n); ? do not know how to calculate - Assertions.assertEquals(numOfVertices, n); - Assertions.assertEquals(numOfEdges, (n*deg)/2); - Assertions.assertEquals(maxDegree, deg); - Assertions.assertEquals(minDegree, deg); + Assert.assertEquals(girth, deg + 1); +// Assert.assertEquals(diameter, n); ? do not know how to calculate + Assert.assertEquals(numOfVertices, n); + Assert.assertEquals(numOfEdges, ((long) n *deg)/2); + Assert.assertEquals(maxDegree, deg); + Assert.assertEquals(minDegree, deg); } @Test @@ -463,12 +466,12 @@ public void testStarGenerator() { int minDegree = maxAndMinDegree.get(1); int girth = new GirthSize().calculate(g); int diameter = new Diameter().calculate(g); - Assertions.assertEquals(girth, 0); - Assertions.assertEquals(diameter, 2); - Assertions.assertEquals(numOfVertices, n); - Assertions.assertEquals(numOfEdges, n - 1); - Assertions.assertEquals(maxDegree, n - 1); - Assertions.assertEquals(minDegree, 1); + Assert.assertEquals(0, girth); + Assert.assertEquals(2, diameter); + Assert.assertEquals(numOfVertices, n); + Assert.assertEquals(numOfEdges, n - 1); + Assert.assertEquals(maxDegree, n - 1); + Assert.assertEquals(1, minDegree); } @Test @@ -484,12 +487,12 @@ public void testCocktailPartyGraph() { int minDegree = maxAndMinDegree.get(1); int girth = new GirthSize().calculate(g); int diameter = new Diameter().calculate(g); - Assertions.assertEquals(girth, 3); - Assertions.assertEquals(diameter, 2); - Assertions.assertEquals(numOfVertices, 2*n); - Assertions.assertEquals(numOfEdges, n*(2*n-1) - n); - Assertions.assertEquals(maxDegree, 2*n-2); - Assertions.assertEquals(minDegree, 2*n-2); + Assert.assertEquals(3, girth); + Assert.assertEquals(2, diameter); + Assert.assertEquals(numOfVertices, 2*n); + Assert.assertEquals(numOfEdges, n*(2L *n-1) - n); + Assert.assertEquals(maxDegree, 2L *n-2); + Assert.assertEquals(minDegree, 2L *n-2); } @Test @@ -507,12 +510,12 @@ public void testKmnGenerator() { int minDegree = maxAndMinDegree.get(1); int girth = new GirthSize().calculate(g); int diameter = new Diameter().calculate(g); - Assertions.assertEquals(girth, 4); - Assertions.assertEquals(diameter, 2); - Assertions.assertEquals(numOfVertices, n+m); - Assertions.assertEquals(numOfEdges, n*m); - Assertions.assertEquals(maxDegree, Math.max(m,n)); - Assertions.assertEquals(minDegree, Math.min(m,n)); + Assert.assertEquals(4, girth); + Assert.assertEquals(2, diameter); + Assert.assertEquals(numOfVertices, n+m); + Assert.assertEquals(numOfEdges, n*m); + Assert.assertEquals(maxDegree, Math.max(m,n)); + Assert.assertEquals(minDegree, Math.min(m,n)); } @Test @@ -528,12 +531,12 @@ public void testCrossedPrismGraph() { int minDegree = maxAndMinDegree.get(1); int girth = new GirthSize().calculate(g); int diameter = new Diameter().calculate(g); - Assertions.assertEquals(girth, 4); - Assertions.assertEquals(diameter, n/2); - Assertions.assertEquals(numOfVertices, 2*n); - Assertions.assertEquals(numOfEdges, 3*n); - Assertions.assertEquals(maxDegree, 3); - Assertions.assertEquals(minDegree, 3); + Assert.assertEquals(4, girth); + Assert.assertEquals(diameter, n/2); + Assert.assertEquals(numOfVertices, 2*n); + Assert.assertEquals(numOfEdges, 3*n); + Assert.assertEquals(3, maxDegree); + Assert.assertEquals(3, minDegree); } @Test @@ -553,10 +556,10 @@ public void testKmnoGenerator() { int minDegree = maxAndMinDegree.get(1); int girth = new GirthSize().calculate(g); int diameter = new Diameter().calculate(g); - Assertions.assertEquals(girth, 3); - Assertions.assertEquals(diameter, 2); - Assertions.assertEquals(numOfVertices, n + m + o); - Assertions.assertEquals(numOfEdges, n*m + n*o + m*o); + Assert.assertEquals(3, girth); + Assert.assertEquals(2, diameter); + Assert.assertEquals(numOfVertices, n + m + o); + Assert.assertEquals(numOfEdges, (long) n *m + (long) n *o + (long) m *o); int maxdeg = 0, mindeg = 0; if(m >= n && m >= o) { maxdeg = m + Math.max(n,o); @@ -568,8 +571,8 @@ public void testKmnoGenerator() { maxdeg = o + Math.max(n,m); mindeg = n + m; } - Assertions.assertEquals(maxDegree, maxdeg); - Assertions.assertEquals(minDegree, mindeg); + Assert.assertEquals(maxDegree, maxdeg); + Assert.assertEquals(minDegree, mindeg); } // Returns factorial of n @@ -600,12 +603,12 @@ public void testKndKneserGraphGenerator() { int minDegree = maxAndMinDegree.get(1); int girth = new GirthSize().calculate(g); int diameter = new Diameter().calculate(g); -// Assertions.assertEquals(girth, n); -// Assertions.assertEquals(diameter, Math.ceil((d-1)/(n-2*d)) + 2); -// Assertions.assertEquals(numOfVertices, nCk(n,d)); -// Assertions.assertEquals(numOfEdges, nCk(n,d)*nCk(n-d,d)/2); -// Assertions.assertEquals(maxDegree, n); -// Assertions.assertEquals(minDegree, n); +// Assert.assertEquals(girth, n); +// Assert.assertEquals(diameter, Math.ceil((d-1)/(n-2*d)) + 2); +// Assert.assertEquals(numOfVertices, nCk(n,d)); +// Assert.assertEquals(numOfEdges, nCk(n,d)*nCk(n-d,d)/2); +// Assert.assertEquals(maxDegree, n); +// Assert.assertEquals(minDegree, n); } @Test @@ -623,12 +626,12 @@ public void testKneserGraphGenerator() { int minDegree = maxAndMinDegree.get(1); int girth = new GirthSize().calculate(g); int diameter = new Diameter().calculate(g); -// Assertions.assertEquals(girth, n); - Assertions.assertEquals(diameter, Math.ceil((k-1)/(n-2*k)) + 1); - Assertions.assertEquals(numOfVertices, nCk(n,k)); - Assertions.assertEquals(numOfEdges, nCk(n,k)*nCk(n-k,k)/2); - Assertions.assertEquals(maxDegree, nCk(n-k,k)); - Assertions.assertEquals(minDegree, nCk(n-k,k)); +// Assert.assertEquals(girth, n); + Assert.assertEquals(diameter, (int) Math.ceil((double) (k - 1) /(n-2*k)) + 1); + Assert.assertEquals(numOfVertices, nCk(n,k)); + Assert.assertEquals(numOfEdges, (long) nCk(n, k) *nCk(n-k,k)/2); + Assert.assertEquals(maxDegree, nCk(n-k,k)); + Assert.assertEquals(minDegree, nCk(n-k,k)); } @Test @@ -646,12 +649,12 @@ public void testPmnGenerator() { int minDegree = maxAndMinDegree.get(1); int girth = new GirthSize().calculate(g); int diameter = new Diameter().calculate(g); - Assertions.assertEquals(girth, 4); - Assertions.assertEquals(diameter, n + m - 2); - Assertions.assertEquals(numOfVertices, n*m); - Assertions.assertEquals(numOfEdges, 2*n*m - n - m); - Assertions.assertEquals(maxDegree, 4); - Assertions.assertEquals(minDegree, 2); + Assert.assertEquals(4, girth); + Assert.assertEquals(diameter, n + m - 2); + Assert.assertEquals(numOfVertices, n*m); + Assert.assertEquals(numOfEdges, 2L *n*m - n - m); + Assert.assertEquals(4, maxDegree); + Assert.assertEquals(2, minDegree); } @Test @@ -667,12 +670,12 @@ public void testFlowerGraph() { int minDegree = maxAndMinDegree.get(1); int girth = new GirthSize().calculate(g); int diameter = new Diameter().calculate(g); - Assertions.assertEquals(numOfVertices, 2*n+1); - Assertions.assertEquals(numOfEdges, 4*n); - Assertions.assertEquals(maxDegree, 2*n); - Assertions.assertEquals(minDegree, 2); - Assertions.assertEquals(girth, 3); - Assertions.assertEquals(diameter, 2); + Assert.assertEquals(numOfVertices, 2L *n+1); + Assert.assertEquals(numOfEdges, 4*n); + Assert.assertEquals(maxDegree, 2*n); + Assert.assertEquals(2, minDegree); + Assert.assertEquals(3, girth); + Assert.assertEquals(2, diameter); } } \ No newline at end of file diff --git a/test/ProductsTest.java b/src/test/ProductsTest.java similarity index 81% rename from test/ProductsTest.java rename to src/test/ProductsTest.java index 36672e6a..8adb8286 100755 --- a/test/ProductsTest.java +++ b/src/test/ProductsTest.java @@ -1,3 +1,5 @@ +package test; + import graphtea.extensions.actions.product.GStrongProduct; import graphtea.extensions.generators.CircleGenerator; import graphtea.extensions.generators.CompleteGraphGenerator; @@ -5,8 +7,9 @@ import graphtea.extensions.generators.PathGenerator; import graphtea.extensions.reports.basicreports.*; import graphtea.graph.graph.GraphModel; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; +import org.junit.Assert; +import org.junit.Test; + import java.util.ArrayList; @@ -31,11 +34,11 @@ public void testStrongProduct() { int minDegree = maxAndMinDegree.get(1); int girth = new GirthSize().calculate(g); int diameter = new Diameter().calculate(g); - Assertions.assertEquals(girth, 3); - Assertions.assertEquals(numOfVertices, n*m); - Assertions.assertEquals(numOfEdges, 4*m*n - 3*(n+m) + 2); - Assertions.assertEquals(maxDegree, 8); - Assertions.assertEquals(minDegree, 3); + Assert.assertEquals(3, girth); + Assert.assertEquals(n*m, numOfVertices); + Assert.assertEquals(4*m*n - 3*(n+m) + 2, numOfEdges); + Assert.assertEquals(8, maxDegree); + Assert.assertEquals(3, minDegree); } } \ No newline at end of file diff --git a/test/RenderTableTest.java b/src/test/RenderTableTest.java similarity index 90% rename from test/RenderTableTest.java rename to src/test/RenderTableTest.java index 9cd388f5..42b158a6 100755 --- a/test/RenderTableTest.java +++ b/src/test/RenderTableTest.java @@ -1,5 +1,7 @@ +package test; + import graphtea.graph.graph.RenderTable; -import org.junit.jupiter.api.Test; +import org.junit.Test; import java.util.Arrays; import java.util.Vector; diff --git a/test/ReportsTest.java b/src/test/ReportsTest.java similarity index 53% rename from test/ReportsTest.java rename to src/test/ReportsTest.java index 84acfcbe..3a5c1c06 100755 --- a/test/ReportsTest.java +++ b/src/test/ReportsTest.java @@ -1,3 +1,4 @@ +package test; import graphtea.extensions.generators.*; import graphtea.extensions.io.g6format.LoadGraph6Format; @@ -14,9 +15,9 @@ import graphtea.extensions.reports.hamilton.*; import graphtea.extensions.reports.matching.*; import graphtea.graph.graph.GraphModel; -import org.junit.jupiter.api.Assertions; import graphtea.graph.graph.SubGraph; -import org.junit.jupiter.api.Test; +import org.junit.Assert; +import org.junit.Test; import java.io.File; import java.util.ArrayList; @@ -40,50 +41,50 @@ public class ReportsTest { @Test public void testGreedyColoring() { HeuristicGreedyColoringNumber hgc = new HeuristicGreedyColoringNumber(); - Assertions.assertEquals(hgc.calculate(circle3),3); - Assertions.assertEquals(hgc.calculate(circle4),2); - Assertions.assertEquals(hgc.calculate(circle5),3); - Assertions.assertEquals(hgc.calculate(complete4),4); - Assertions.assertEquals(hgc.calculate(complete5),5); - Assertions.assertEquals(hgc.calculate(peterson),3); + Assert.assertEquals(3, hgc.calculate(circle3).intValue()); + Assert.assertEquals(2, hgc.calculate(circle4).intValue()); + Assert.assertEquals(3, hgc.calculate(circle5).intValue()); + Assert.assertEquals(4, hgc.calculate(complete4).intValue()); + Assert.assertEquals(5, hgc.calculate(complete5).intValue()); + Assert.assertEquals(3, hgc.calculate(peterson).intValue()); } @Test public void testMaxCliqueNumber() { MaxCliqueSize mcs = new MaxCliqueSize(); - Assertions.assertEquals(mcs.calculate(circle3),3); - Assertions.assertEquals(mcs.calculate(circle4),2); - Assertions.assertEquals(mcs.calculate(circle5),2); - Assertions.assertEquals(mcs.calculate(complete4),4); - Assertions.assertEquals(mcs.calculate(complete5),5); - Assertions.assertEquals(mcs.calculate(peterson),2); + Assert.assertEquals(3, mcs.calculate(circle3).intValue()); + Assert.assertEquals(2, mcs.calculate(circle4).intValue()); + Assert.assertEquals(2, mcs.calculate(circle5).intValue()); + Assert.assertEquals(4, mcs.calculate(complete4).intValue()); + Assert.assertEquals(5, mcs.calculate(complete5).intValue()); + Assert.assertEquals(2, mcs.calculate(peterson).intValue()); LoadGraph6Format loadGraph6Format = new LoadGraph6Format(); GraphModel g = loadGraph6Format.read(new File("examples/example.g6")); - Assertions.assertEquals(mcs.calculate(g),3); + Assert.assertEquals(3, mcs.calculate(g).intValue()); } @Test public void testChromaticNumber() { ChromaticNumber varChromaticNumber = new ChromaticNumber(); - Assertions.assertEquals(varChromaticNumber.calculate(peterson),0); + Assert.assertEquals(3, varChromaticNumber.calculate(peterson).intValue()); } @Test public void testMaxCut() { MaxCut varMaxCut = new MaxCut(); - Assertions.assertEquals(varMaxCut.calculate(peterson),0); + Assert.assertTrue(varMaxCut.calculate(peterson) <= 12); } @Test public void testMaxIndependentSetReport() { MaxIndependentSetReport varMaxIndependentSetReport = new MaxIndependentSetReport(); - Assertions.assertEquals(varMaxIndependentSetReport.calculate(peterson).get(0),new SubGraph()); + Assert.assertEquals(new SubGraph(), varMaxIndependentSetReport.calculate(peterson).get(0)); } @Test public void testWienerDiameterReport() { WienerDiameterReport varWienerDiameterReport = new WienerDiameterReport(); - Assertions.assertEquals(varWienerDiameterReport.calculate(peterson).iterator().next().get(0),0); + Assert.assertEquals(75, varWienerDiameterReport.calculate(peterson).iterator().next().get(0)); } @Test @@ -94,61 +95,61 @@ public void testColoringReport() { @Test public void testRandomMatching() { RandomMatching varRandomMatching = new RandomMatching(); - Assertions.assertEquals(varRandomMatching.calculate(peterson).get(0),new Object()); + Assert.assertEquals(new Object(), varRandomMatching.calculate(peterson).get(0)); } @Test public void testMSTPrimExtension() { MSTPrimExtension varMSTPrimExtension = new MSTPrimExtension(); - Assertions.assertEquals(varMSTPrimExtension.calculate(peterson),new SubGraph()); + Assert.assertEquals(new SubGraph(), varMSTPrimExtension.calculate(peterson)); } @Test public void testDegreeDistance() { DegreeDistance varDegreeDistance = new DegreeDistance(); - Assertions.assertEquals(varDegreeDistance.calculate(peterson),0); + Assert.assertEquals(0, varDegreeDistance.calculate(peterson).intValue()); } @Test public void testHarmonicIndex() { HarmonicIndex varHarmonicIndex = new HarmonicIndex(); - Assertions.assertEquals(varHarmonicIndex.calculate(peterson).get(0),""); + Assert.assertEquals("", varHarmonicIndex.calculate(peterson).get(0)); } @Test public void testEccentricConnectivityIndex() { EccentricConnectiveIndex varEccentricConnectivityIndex = new EccentricConnectiveIndex(); - Assertions.assertEquals(varEccentricConnectivityIndex.calculate(peterson),""); + Assert.assertEquals(0, varEccentricConnectivityIndex.calculate(peterson).intValue()); } @Test public void testZagrebCoindex() { ZagrebCoindex varZagrebCoindex = new ZagrebCoindex(); - Assertions.assertEquals(varZagrebCoindex.calculate(peterson).get(0),""); + Assert.assertEquals("", varZagrebCoindex.calculate(peterson).get(0)); } @Test public void testM3Final() { M3Final varM3Final = new M3Final(); - Assertions.assertEquals(varM3Final.calculate(peterson).iterator().next().get(0),0); + Assert.assertEquals(0, varM3Final.calculate(peterson).iterator().next().get(0)); } @Test public void testISIBound() { ISIBound varISIBound = new ISIBound(); - Assertions.assertEquals(varISIBound.calculate(peterson).iterator().next().get(0),0); + Assert.assertEquals(0, varISIBound.calculate(peterson).iterator().next().get(0)); } @Test public void testReciprocalDegreeDistance() { ReciprocalDegreeDistance varReciprocalDegreeDistance = new ReciprocalDegreeDistance(); - Assertions.assertEquals(varReciprocalDegreeDistance.calculate(peterson),0); + Assert.assertEquals(0, varReciprocalDegreeDistance.calculate(peterson).intValue()); } @Test public void testPathZagrebIndex() { PathZagrebIndex varPathZagrebIndex = new PathZagrebIndex(); - Assertions.assertEquals(varPathZagrebIndex.calculate(peterson).get(0),""); + Assert.assertEquals("", varPathZagrebIndex.calculate(peterson).get(0)); } @Test @@ -156,441 +157,435 @@ public void testWeightedWienerIndex() { WeightedWienerIndex varWeightedWienerIndex = new WeightedWienerIndex(); } - @Test - public void testEdgesDegreesList() { - EdgesDegreesList varEdgesDegreesList = new EdgesDegreesList(); - Assertions.assertEquals(varEdgesDegreesList.calculate(peterson).get(0),0); - } - @Test public void testZagrebCoindexSelectedEdges() { ZagrebCoindexSelectedEdges varZagrebCoindexSelectedEdges = new ZagrebCoindexSelectedEdges(); - Assertions.assertEquals(varZagrebCoindexSelectedEdges.calculate(peterson).get(0),""); + Assert.assertEquals("", varZagrebCoindexSelectedEdges.calculate(peterson).get(0)); } @Test public void testEM1UpperBound() { EM1UpperBound varEM1UpperBound = new EM1UpperBound(); - Assertions.assertEquals(varEM1UpperBound.calculate(peterson).iterator().next().get(0),0); + Assert.assertEquals(0, varEM1UpperBound.calculate(peterson).iterator().next().get(0)); } @Test public void testInde() { Inde varInde = new Inde(); - Assertions.assertEquals(varInde.calculate(peterson).iterator().next().get(0),0); + Assert.assertEquals(0, varInde.calculate(peterson).iterator().next().get(0)); } @Test public void testAGIndex() { AGIndex varAGIndex = new AGIndex(); - Assertions.assertEquals(varAGIndex.calculate(peterson).iterator().next().get(0),0); + Assert.assertEquals(0, varAGIndex.calculate(peterson).iterator().next().get(0)); } @Test public void testIncrementalZagrebIndexSelectedEdges() { IncrementalZagrebIndexSelectedEdges varIncrementalZagrebIndexSelectedEdges = new IncrementalZagrebIndexSelectedEdges(); - Assertions.assertEquals(varIncrementalZagrebIndexSelectedEdges.calculate(peterson).iterator().next().get(0),0); + Assert.assertEquals(0, varIncrementalZagrebIndexSelectedEdges.calculate(peterson).iterator().next().get(0)); } @Test public void testAdditiveHarary() { AdditiveHarary varAdditiveHarary = new AdditiveHarary(); - Assertions.assertEquals(varAdditiveHarary.calculate(peterson),0); + Assert.assertEquals(0, varAdditiveHarary.calculate(peterson).intValue()); } @Test public void testFinalNewM2Lower() { FinalNewM2Lower varFinalNewM2Lower = new FinalNewM2Lower(); - Assertions.assertEquals(varFinalNewM2Lower.calculate(peterson).iterator().next().get(0),0); + Assert.assertEquals(0, varFinalNewM2Lower.calculate(peterson).iterator().next().get(0)); } @Test public void testECIConjecture() { ECIConjecture varECIConjecture = new ECIConjecture(); - Assertions.assertEquals(varECIConjecture.calculate(peterson).iterator().next().get(0),0); + Assert.assertEquals(0, varECIConjecture.calculate(peterson).iterator().next().get(0)); } @Test public void testPB() { PB varPB = new PB(); - Assertions.assertEquals(varPB.calculate(peterson).iterator().next().get(0),0); + Assert.assertEquals(0, varPB.calculate(peterson).iterator().next().get(0)); } @Test public void testWienerPolarityIndex() { WienerPolarityIndex varWienerPolarityIndex = new WienerPolarityIndex(); - Assertions.assertEquals(varWienerPolarityIndex.calculate(peterson),0); + Assert.assertEquals(0, varWienerPolarityIndex.calculate(peterson).intValue()); } @Test public void testSDD() { SDD varSDD = new SDD(); - Assertions.assertEquals(varSDD.calculate(peterson).iterator().next().get(0),0); + Assert.assertEquals(0, varSDD.calculate(peterson).iterator().next().get(0)); } @Test public void testHyperWienerIndex() { HyperWienerIndex varHyperWienerIndex = new HyperWienerIndex(); - Assertions.assertEquals(varHyperWienerIndex.calculate(peterson),0); + Assert.assertEquals(0, varHyperWienerIndex.calculate(peterson).intValue()); } @Test public void testGutmanIndex() { GutmanIndex varGutmanIndex = new GutmanIndex(); - Assertions.assertEquals(varGutmanIndex.calculate(peterson),0); + Assert.assertEquals(0, varGutmanIndex.calculate(peterson).intValue()); } @Test public void testEM1LowerBound() { EM1LowerBound varEM1LowerBound = new EM1LowerBound(); - Assertions.assertEquals(varEM1LowerBound.calculate(peterson).iterator().next().get(0),0); + Assert.assertEquals(0, varEM1LowerBound.calculate(peterson).iterator().next().get(0)); } @Test public void testConnectiveEccentricIndex() { ConnectiveEccentricIndex varConnectiveEccentricIndex = new ConnectiveEccentricIndex(); - Assertions.assertEquals(varConnectiveEccentricIndex.calculate(peterson),""); + Assert.assertEquals(0, (int) varConnectiveEccentricIndex.calculate(peterson).doubleValue()); } @Test public void testInverseSum() { InverseSum varInverseSum = new InverseSum(); - Assertions.assertEquals(varInverseSum.calculate(peterson).iterator().next().get(0),0); + Assert.assertEquals(0, varInverseSum.calculate(peterson).iterator().next().get(0)); } @Test public void testM3CompIndCoindConjecture() { M3CompIndCoindConjecture varM3CompIndCoindConjecture = new M3CompIndCoindConjecture(); - Assertions.assertEquals(varM3CompIndCoindConjecture.calculate(peterson).iterator().next().get(0),0); + Assert.assertEquals(0, varM3CompIndCoindConjecture.calculate(peterson).iterator().next().get(0)); } @Test public void testHarary() { Harary varHarary = new Harary(); - Assertions.assertEquals(varHarary.calculate(peterson),0); + Assert.assertEquals(0, varHarary.calculate(peterson).intValue()); } @Test public void testZagrebIndex() { ZagrebIndex varZagrebIndex = new ZagrebIndex(); -// Assertions.assertEquals(varZagrebIndex.calculate(peterson).get(0),""); +// Assert.assertEquals(varZagrebIndex.calculate(peterson).get(0),""); } @Test public void testInverseDegree() { InverseDegree varInverseDegree = new InverseDegree(); - Assertions.assertEquals(varInverseDegree.calculate(peterson).iterator().next().get(0),0); + Assert.assertEquals(0, varInverseDegree.calculate(peterson).iterator().next().get(0)); } @Test public void testExp() { Exp varExp = new Exp(); - Assertions.assertEquals(varExp.calculate(peterson).iterator().next().get(0),0); + Assert.assertEquals(0, varExp.calculate(peterson).iterator().next().get(0)); } @Test public void testModifiedFirstZagrebConnectionIndex() { ModifiedFirstZagrebConnectionIndex varModifiedFirstZagrebConnectionIndex = new ModifiedFirstZagrebConnectionIndex(); - Assertions.assertEquals(varModifiedFirstZagrebConnectionIndex.calculate(peterson).get(0),""); + Assert.assertEquals("", varModifiedFirstZagrebConnectionIndex.calculate(peterson).get(0)); } @Test public void testIncrementalZagrebCoindex() { IncrementalZagrebCoindex varIncrementalZagrebCoindex = new IncrementalZagrebCoindex(); - Assertions.assertEquals(varIncrementalZagrebCoindex.calculate(peterson).iterator().next().get(0),0); + Assert.assertEquals(0, varIncrementalZagrebCoindex.calculate(peterson).iterator().next().get(0)); } @Test public void testEccentricityComplexityIndex() { EccentricityComplexityIndex varEccentricityComplexityIndex = new EccentricityComplexityIndex(); - Assertions.assertEquals(varEccentricityComplexityIndex.calculate(peterson),0); + Assert.assertEquals(0, varEccentricityComplexityIndex.calculate(peterson).intValue()); } @Test public void testEdgeDegree() { EdgeDegree varEdgeDegree = new EdgeDegree(); - Assertions.assertEquals(varEdgeDegree.calculate(peterson),0); + Assert.assertEquals(0, varEdgeDegree.calculate(peterson).intValue()); } @Test public void testConnectivityEccentricityIndex() { ConnectivityEccentricityIndex varConnectivityEccentricityIndex = new ConnectivityEccentricityIndex(); - Assertions.assertEquals(varConnectivityEccentricityIndex.calculate(peterson),0); + Assert.assertEquals(0, varConnectivityEccentricityIndex.calculate(peterson).intValue()); } @Test public void testEccentricityConnectivityIndex() { EccentricConnectiveIndex varEccentricityConnectivityIndex = new EccentricConnectiveIndex(); - Assertions.assertEquals(varEccentricityConnectivityIndex.calculate(peterson),0); + Assert.assertEquals(0, varEccentricityConnectivityIndex.calculate(peterson).intValue()); } @Test public void testWienerIndex() { WienerIndex varWienerIndex = new WienerIndex(); - Assertions.assertEquals(varWienerIndex.calculate(circle3),3); - Assertions.assertEquals(varWienerIndex.calculate(circle4),8); - Assertions.assertEquals(varWienerIndex.calculate(circle5),15); - Assertions.assertEquals(varWienerIndex.calculate(complete4),6); - Assertions.assertEquals(varWienerIndex.calculate(complete5),10); - Assertions.assertEquals(varWienerIndex.calculate(antiprism3),18); + Assert.assertEquals(3, varWienerIndex.calculate(circle3).intValue()); + Assert.assertEquals(8, varWienerIndex.calculate(circle4).intValue()); + Assert.assertEquals(15, varWienerIndex.calculate(circle5).intValue()); + Assert.assertEquals(6, varWienerIndex.calculate(complete4).intValue()); + Assert.assertEquals(10, varWienerIndex.calculate(complete5).intValue()); + Assert.assertEquals(18, varWienerIndex.calculate(antiprism3).intValue()); } @Test public void testVariableZagrebIndex() { VariableZagrebIndex varVariableZagrebIndex = new VariableZagrebIndex(); - Assertions.assertEquals(varVariableZagrebIndex.calculate(peterson).get(0),""); + Assert.assertEquals("", varVariableZagrebIndex.calculate(peterson).get(0)); } @Test public void testTotalEccentricityIndex() { TotalEccentricityIndex varTotalEccentricityIndex = new TotalEccentricityIndex(); - Assertions.assertEquals(varTotalEccentricityIndex.calculate(peterson),0); + Assert.assertEquals(0, varTotalEccentricityIndex.calculate(peterson).intValue()); } @Test public void testHyperZagrebIndex() { HyperZagrebIndex varHyperZagrebIndex = new HyperZagrebIndex(); - Assertions.assertEquals(varHyperZagrebIndex.calculate(peterson).get(0),""); + Assert.assertEquals("", varHyperZagrebIndex.calculate(peterson).get(0)); } @Test public void testM3BoundConjecture() { M3BoundConjecture varM3BoundConjecture = new M3BoundConjecture(); - Assertions.assertEquals(varM3BoundConjecture.calculate(peterson).iterator().next().get(0),0); + Assert.assertEquals(0, varM3BoundConjecture.calculate(peterson).iterator().next().get(0)); } @Test public void testHyperCheck() { HyperCheck varHyperCheck = new HyperCheck(); - Assertions.assertEquals(varHyperCheck.calculate(peterson).iterator().next().get(0),0); + Assert.assertEquals(0, varHyperCheck.calculate(peterson).iterator().next().get(0)); } @Test public void testAllCheck() { AllCheck varAllCheck = new AllCheck(); - Assertions.assertEquals(varAllCheck.calculate(peterson).iterator().next().get(0),0); + Assert.assertEquals(0, varAllCheck.calculate(peterson).iterator().next().get(0)); } @Test public void testEM1Lower() { EM1Lower varEM1Lower = new EM1Lower(); - Assertions.assertEquals(varEM1Lower.calculate(peterson).iterator().next().get(0),0); + Assert.assertEquals(0, varEM1Lower.calculate(peterson).iterator().next().get(0)); } @Test public void testSecondMixZagrebIndex() { SecondMixZagrebIndex varSecondMixZagrebIndex = new SecondMixZagrebIndex(); - Assertions.assertEquals(varSecondMixZagrebIndex.calculate(peterson).get(0),""); + Assert.assertEquals("", varSecondMixZagrebIndex.calculate(peterson).get(0)); } @Test public void testLanzhou() { Lanzhou varLanzhou = new Lanzhou(); - Assertions.assertEquals(varLanzhou.calculate(peterson).iterator().next().get(0),0); + Assert.assertEquals(0, varLanzhou.calculate(peterson).iterator().next().get(0)); } @Test public void testZagrebIndexSelectedEdges() { ZagrebIndexSelectedEdges varZagrebIndexSelectedEdges = new ZagrebIndexSelectedEdges(); - Assertions.assertEquals(varZagrebIndexSelectedEdges.calculate(peterson).get(0),""); + Assert.assertEquals("", varZagrebIndexSelectedEdges.calculate(peterson).get(0)); } @Test public void testMWienerIndex() { MWienerIndex varMWienerIndex = new MWienerIndex(); - Assertions.assertEquals(varMWienerIndex.calculate(peterson),0); + Assert.assertEquals(0, varMWienerIndex.calculate(peterson).intValue()); } @Test public void testEM2UpperBound() { EM2UpperBound varEM2UpperBound = new EM2UpperBound(); - Assertions.assertEquals(varEM2UpperBound.calculate(peterson).iterator().next().get(0),0); + Assert.assertEquals(0, varEM2UpperBound.calculate(peterson).iterator().next().get(0)); } @Test public void testIncrementalVariableZagrebIndex() { IncrementalVariableZagrebIndex varIncrementalVariableZagrebIndex = new IncrementalVariableZagrebIndex(); - Assertions.assertEquals(varIncrementalVariableZagrebIndex.calculate(peterson).iterator().next().get(0),0); + Assert.assertEquals(0, varIncrementalVariableZagrebIndex.calculate(peterson).iterator().next().get(0)); } @Test public void testIncrementalZagrebCoindexSelectedEdges() { IncrementalZagrebCoindexSelectedEdges varIncrementalZagrebCoindexSelectedEdges = new IncrementalZagrebCoindexSelectedEdges(); - Assertions.assertEquals(varIncrementalZagrebCoindexSelectedEdges.calculate(peterson).iterator().next().get(0),0); + Assert.assertEquals(0, varIncrementalZagrebCoindexSelectedEdges.calculate(peterson).iterator().next().get(0)); } @Test public void testEM2LowerBound() { EM2LowerBound varEM2LowerBound = new EM2LowerBound(); - Assertions.assertEquals(varEM2LowerBound.calculate(peterson).iterator().next().get(0),0); + Assert.assertEquals(0, varEM2LowerBound.calculate(peterson).iterator().next().get(0)); } @Test public void testcomparision() { comparision varcomparision = new comparision(); - Assertions.assertEquals(varcomparision.calculate(peterson).iterator().next().get(0),0); + Assert.assertEquals(0, varcomparision.calculate(peterson).iterator().next().get(0)); } @Test public void testExponential() { Exponential varExponential = new Exponential(); - Assertions.assertEquals(varExponential.calculate(peterson).iterator().next().get(0),0); + Assert.assertEquals(0, varExponential.calculate(peterson).iterator().next().get(0)); } @Test public void testRandicIndex() { RandicIndex varRandicIndex = new RandicIndex(); - Assertions.assertEquals(varRandicIndex.calculate(peterson).get(0),""); + Assert.assertEquals("", varRandicIndex.calculate(peterson).get(0)); } @Test public void testAutographixConj() { AutographixConj varAutographixConj = new AutographixConj(); - Assertions.assertEquals(varAutographixConj.calculate(peterson).get(0),""); + Assert.assertEquals("", varAutographixConj.calculate(peterson).get(0)); } @Test public void testSumConnectivityIndex() { SumConnectivityIndex varSumConnectivityIndex = new SumConnectivityIndex(); - Assertions.assertEquals(varSumConnectivityIndex.calculate(peterson).get(0),""); + Assert.assertEquals("", varSumConnectivityIndex.calculate(peterson).get(0)); } @Test public void testWinerPolarity() { WinerPolarity varWinerPolarity = new WinerPolarity(); - Assertions.assertEquals(varWinerPolarity.calculate(peterson).iterator().next().get(0),0); + Assert.assertEquals(0, varWinerPolarity.calculate(peterson).iterator().next().get(0)); } @Test public void testMere() { Mere varMere = new Mere(); - Assertions.assertEquals(varMere.calculate(peterson).iterator().next().get(0),0); + Assert.assertEquals(0, varMere.calculate(peterson).iterator().next().get(0)); } @Test public void testIncrementalZagrebIndex() { IncrementalZagrebIndex varIncrementalZagrebIndex = new IncrementalZagrebIndex(); - Assertions.assertEquals(varIncrementalZagrebIndex.calculate(peterson).iterator().next().get(0),0); + Assert.assertEquals(0, varIncrementalZagrebIndex.calculate(peterson).iterator().next().get(0)); } @Test public void testWienerPolarity() { WienerPolarity varWienerPolarity = new WienerPolarity(); - Assertions.assertEquals(varWienerPolarity.calculate(peterson),0); + Assert.assertEquals(0, varWienerPolarity.calculate(peterson).intValue()); } @Test public void testThirdZagrebIndex() { ThirdZagrebIndex varThirdZagrebIndex = new ThirdZagrebIndex(); - Assertions.assertEquals(varThirdZagrebIndex.calculate(peterson).get(0),""); + Assert.assertEquals("", varThirdZagrebIndex.calculate(peterson).get(0)); } @Test public void testISIUpper() { ISIUpper varISIUpper = new ISIUpper(); - Assertions.assertEquals(varISIUpper.calculate(peterson).iterator().next().get(0),0); + Assert.assertEquals(0, varISIUpper.calculate(peterson).iterator().next().get(0)); } @Test public void testMultiplicativeHarary() { MultiplicativeHarary varMultiplicativeHarary = new MultiplicativeHarary(); - Assertions.assertEquals(varMultiplicativeHarary.calculate(peterson),0); + Assert.assertEquals(0, varMultiplicativeHarary.calculate(peterson).intValue()); } @Test public void testBalabanIndex() { BalabanIndex varBalabanIndex = new BalabanIndex(); - Assertions.assertEquals(varBalabanIndex.calculate(peterson).iterator().next().get(0),0); + Assert.assertEquals(0, varBalabanIndex.calculate(peterson).iterator().next().get(0)); } @Test public void testMostar() { Mostar varMostar = new Mostar(); - Assertions.assertEquals(varMostar.calculate(peterson).iterator().next().get(0),0); + Assert.assertEquals(0, varMostar.calculate(peterson).iterator().next().get(0)); } @Test public void testMaxCliqueExtension() { MaxCliqueExtension varMaxCliqueExtension = new MaxCliqueExtension(); - Assertions.assertEquals(varMaxCliqueExtension.calculate(peterson).get(0),new SubGraph()); + Assert.assertEquals(new SubGraph(), varMaxCliqueExtension.calculate(peterson).get(0)); } @Test public void testKF_Wiener() { KF_Wiener varKF_Wiener = new KF_Wiener(); - Assertions.assertEquals(varKF_Wiener.calculate(peterson).iterator().next().get(0),0); + Assert.assertEquals(0, varKF_Wiener.calculate(peterson).iterator().next().get(0)); } @Test public void testLEL_vs_KF() { LEL_vs_KF varLEL_vs_KF = new LEL_vs_KF(); - Assertions.assertEquals(varLEL_vs_KF.calculate(peterson).iterator().next().get(0),0); + Assert.assertEquals(0, varLEL_vs_KF.calculate(peterson).iterator().next().get(0)); } @Test public void testMixSignlessLaplacianEnergy() { MixSignlessLaplacianEnergy varMixSignlessLaplacianEnergy = new MixSignlessLaplacianEnergy(); - Assertions.assertEquals(varMixSignlessLaplacianEnergy.calculate(peterson).get(0),""); + Assert.assertEquals("", varMixSignlessLaplacianEnergy.calculate(peterson).get(0)); } @Test public void testSignlessLaplacianEstrada() { SignlessLaplacianEstrada varSignlessLaplacianEstrada = new SignlessLaplacianEstrada(); - Assertions.assertEquals(varSignlessLaplacianEstrada.calculate(peterson).iterator().next().get(0),0); + Assert.assertEquals(0, varSignlessLaplacianEstrada.calculate(peterson).iterator().next().get(0)); } @Test public void testCograph() { Cograph varCograph = new Cograph(); - Assertions.assertEquals(varCograph.calculate(peterson).iterator().next().get(0),0); + Assert.assertEquals(0, varCograph.calculate(peterson).iterator().next().get(0)); } @Test public void testEnergy() { Energy varEnergy = new Energy(); -// Assertions.assertEquals(varEnergy.calculate(peterson).iterator().next().get(0),0); +// Assert.assertEquals(varEnergy.calculate(peterson).iterator().next().get(0),0); } @Test public void testLaplacianEstrada() { LaplacianEstrada varLaplacianEstrada = new LaplacianEstrada(); - Assertions.assertEquals(varLaplacianEstrada.calculate(peterson).iterator().next().get(0),0); + Assert.assertEquals(0, varLaplacianEstrada.calculate(peterson).iterator().next().get(0)); } @Test public void testAllEnergies() { AllEnergies varAllEnergies = new AllEnergies(); - Assertions.assertEquals(varAllEnergies.calculate(peterson).iterator().next().get(0),0); + Assert.assertEquals(0, varAllEnergies.calculate(peterson).iterator().next().get(0)); } @Test public void testConjecture() { Conjecture varConjecture = new Conjecture(); - Assertions.assertEquals(varConjecture.calculate(peterson).iterator().next().get(0),0); + Assert.assertEquals(0, varConjecture.calculate(peterson).iterator().next().get(0)); } @Test public void testUpperBounds() { UpperBounds varUpperBounds = new UpperBounds(); - Assertions.assertEquals(varUpperBounds.calculate(peterson).iterator().next().get(0),0); + Assert.assertEquals(0, varUpperBounds.calculate(peterson).iterator().next().get(0)); } @Test public void testLinear() { Linear varLinear = new Linear(); - Assertions.assertEquals(varLinear.calculate(peterson).iterator().next().get(0),0); + Assert.assertEquals(0, varLinear.calculate(peterson).iterator().next().get(0)); } @Test public void testEstrada() { Estrada varEstrada = new Estrada(); - Assertions.assertEquals(varEstrada.calculate(peterson).iterator().next().get(0),0); + Assert.assertEquals(0, varEstrada.calculate(peterson).iterator().next().get(0)); } @Test public void testComplement() { Complement varComplement = new Complement(); - Assertions.assertEquals(varComplement.calculate(peterson).iterator().next().get(0),0); + Assert.assertEquals(0, varComplement.calculate(peterson).iterator().next().get(0)); } @Test @@ -601,256 +596,250 @@ public void testNewLowerBounds() { @Test public void testDominationNumber() { DominationNumber varDominationNumber = new DominationNumber(); - Assertions.assertEquals(varDominationNumber.calculate(peterson),0); + Assert.assertEquals(0, varDominationNumber.calculate(peterson).intValue()); } @Test public void testAllPairShortestPathsWithoutWeight() { AllPairShortestPathsWithoutWeight varAllPairShortestPathsWithoutWeight = new AllPairShortestPathsWithoutWeight(); - Assertions.assertEquals(varAllPairShortestPathsWithoutWeight.calculate(peterson).iterator().next().get(0),0); + Assert.assertEquals(0, varAllPairShortestPathsWithoutWeight.calculate(peterson).iterator().next().get(0)); } @Test public void testIsBipartite() { IsBipartite varIsBipartite = new IsBipartite(); - Assertions.assertFalse(varIsBipartite.calculate(peterson)); - Assertions.assertTrue(varIsBipartite.calculate(circle4)); - Assertions.assertFalse(varIsBipartite.calculate(circle5)); - Assertions.assertFalse(varIsBipartite.calculate(complete4)); - Assertions.assertFalse(varIsBipartite.calculate(complete5)); + Assert.assertFalse(varIsBipartite.calculate(peterson)); + Assert.assertTrue(varIsBipartite.calculate(circle4)); + Assert.assertFalse(varIsBipartite.calculate(circle5)); + Assert.assertFalse(varIsBipartite.calculate(complete4)); + Assert.assertFalse(varIsBipartite.calculate(complete5)); } @Test public void testNumOfConnectedComponents() { NumOfConnectedComponents varNumOfConnectedComponents = new NumOfConnectedComponents(); - Assertions.assertEquals(varNumOfConnectedComponents.calculate(peterson),0); + Assert.assertEquals(1, varNumOfConnectedComponents.calculate(peterson).intValue()); } @Test public void testIsEulerian() { IsEulerian varIsEulerian = new IsEulerian(); - Assertions.assertFalse(varIsEulerian.calculate(peterson)); - Assertions.assertTrue(varIsEulerian.calculate(circle4)); - Assertions.assertTrue(varIsEulerian.calculate(circle5)); - Assertions.assertFalse(varIsEulerian.calculate(complete4)); - Assertions.assertTrue(varIsEulerian.calculate(complete5)); + Assert.assertFalse(varIsEulerian.calculate(peterson)); + Assert.assertTrue(varIsEulerian.calculate(circle4)); + Assert.assertTrue(varIsEulerian.calculate(circle5)); + Assert.assertFalse(varIsEulerian.calculate(complete4)); + Assert.assertTrue(varIsEulerian.calculate(complete5)); } @Test public void testGirthSize() { GirthSize varGirthSize = new GirthSize(); - Assertions.assertEquals(varGirthSize.calculate(peterson),5); - Assertions.assertEquals(varGirthSize.calculate(circle4),4); - Assertions.assertEquals(varGirthSize.calculate(circle5),5); - Assertions.assertEquals(varGirthSize.calculate(complete4), 3); - Assertions.assertEquals(varGirthSize.calculate(complete5), 3); + Assert.assertEquals(5, varGirthSize.calculate(peterson).intValue()); + Assert.assertEquals(4, varGirthSize.calculate(circle4).intValue()); + Assert.assertEquals(5, varGirthSize.calculate(circle5).intValue()); + Assert.assertEquals(3, varGirthSize.calculate(complete4).intValue()); + Assert.assertEquals(3, varGirthSize.calculate(complete5).intValue()); } @Test public void testNumOfTriangles() { NumOfTriangles varNumOfTriangles = new NumOfTriangles(); - Assertions.assertEquals(varNumOfTriangles.calculate(peterson),0); - Assertions.assertEquals(varNumOfTriangles.calculate(circle4),0); - Assertions.assertEquals(varNumOfTriangles.calculate(circle5),0); - Assertions.assertEquals(varNumOfTriangles.calculate(complete4), 4); - Assertions.assertEquals(varNumOfTriangles.calculate(complete5), 10); - } - - @Test - public void testVerticesDegreesList() { - VerticesDegreesList varVerticesDegreesList = new VerticesDegreesList(); - Assertions.assertEquals(varVerticesDegreesList.calculate(peterson).get(0),0); + Assert.assertEquals(0, varNumOfTriangles.calculate(peterson).intValue()); + Assert.assertEquals(0, varNumOfTriangles.calculate(circle4).intValue()); + Assert.assertEquals(0, varNumOfTriangles.calculate(circle5).intValue()); + Assert.assertEquals(4, varNumOfTriangles.calculate(complete4).intValue()); + Assert.assertEquals(10, varNumOfTriangles.calculate(complete5).intValue()); } @Test public void testNumOfEdges() { NumOfEdges varNumOfEdges = new NumOfEdges(); - Assertions.assertEquals(varNumOfEdges.calculate(peterson),15); - Assertions.assertEquals(varNumOfEdges.calculate(circle4),4); - Assertions.assertEquals(varNumOfEdges.calculate(circle5),5); - Assertions.assertEquals(varNumOfEdges.calculate(complete4), 6); - Assertions.assertEquals(varNumOfEdges.calculate(complete5), 10); + Assert.assertEquals(15, varNumOfEdges.calculate(peterson).intValue()); + Assert.assertEquals(4, varNumOfEdges.calculate(circle4).intValue()); + Assert.assertEquals(5, varNumOfEdges.calculate(circle5).intValue()); + Assert.assertEquals(6, varNumOfEdges.calculate(complete4).intValue()); + Assert.assertEquals(10, varNumOfEdges.calculate(complete5).intValue()); } @Test public void testSubTreeCounting() { SubTreeCounting varSubTreeCounting = new SubTreeCounting(); - Assertions.assertEquals(varSubTreeCounting.calculate(peterson).iterator().next().get(0),0); + Assert.assertEquals(0, varSubTreeCounting.calculate(peterson).iterator().next().get(0)); } @Test public void testMaxAndMinDegree() { MaxAndMinDegree varMaxAndMinDegree = new MaxAndMinDegree(); ArrayList maxmin = varMaxAndMinDegree.calculate(peterson); - Assertions.assertEquals(maxmin.get(0),3); - Assertions.assertEquals(maxmin.get(1),3); + Assert.assertEquals(3, maxmin.get(0).intValue()); + Assert.assertEquals(3, maxmin.get(1).intValue()); maxmin = varMaxAndMinDegree.calculate(circle4); - Assertions.assertEquals(maxmin.get(0),2); - Assertions.assertEquals(maxmin.get(1),2); + Assert.assertEquals(2, maxmin.get(0).intValue()); + Assert.assertEquals(2, maxmin.get(1).intValue()); maxmin = varMaxAndMinDegree.calculate(circle5); - Assertions.assertEquals(maxmin.get(0),2); - Assertions.assertEquals(maxmin.get(1),2); + Assert.assertEquals(2, maxmin.get(0).intValue()); + Assert.assertEquals(2, maxmin.get(1).intValue()); maxmin = varMaxAndMinDegree.calculate(complete4); - Assertions.assertEquals(maxmin.get(0),3); - Assertions.assertEquals(maxmin.get(1),3); + Assert.assertEquals(3, maxmin.get(0).intValue()); + Assert.assertEquals(3, maxmin.get(1).intValue()); maxmin = varMaxAndMinDegree.calculate(complete5); - Assertions.assertEquals(maxmin.get(0),4); - Assertions.assertEquals(maxmin.get(1),4); + Assert.assertEquals(4, maxmin.get(0).intValue()); + Assert.assertEquals(4, maxmin.get(1).intValue()); } @Test public void testNumOfStars() { NumOfStars varNumOfStars = new NumOfStars(); - Assertions.assertEquals(varNumOfStars.calculate(peterson),0); - Assertions.assertEquals(varNumOfStars.calculate(circle4),0); - Assertions.assertEquals(varNumOfStars.calculate(circle5),0); - Assertions.assertEquals(varNumOfStars.calculate(complete4), 0); - Assertions.assertEquals(varNumOfStars.calculate(complete5), 0); + Assert.assertEquals(30, varNumOfStars.calculate(peterson).intValue()); + Assert.assertEquals(8, varNumOfStars.calculate(circle4).intValue()); + Assert.assertEquals(0, varNumOfStars.calculate(circle5).intValue()); + Assert.assertEquals(0, varNumOfStars.calculate(complete4).intValue()); + Assert.assertEquals(0, varNumOfStars.calculate(complete5).intValue()); } @Test public void testMaxOfIndSets() { MaxOfIndSets varMaxOfIndSets = new MaxOfIndSets(); - Assertions.assertEquals(varMaxOfIndSets.calculate(peterson),0); + Assert.assertEquals(0, varMaxOfIndSets.calculate(peterson).intValue()); } @Test public void testAdjacencyMatrix() { SpectrumOfAdjacencyMatrix varAdjacencyMatrix = new SpectrumOfAdjacencyMatrix(); - Assertions.assertEquals(varAdjacencyMatrix.calculate(peterson).get(0),""); + Assert.assertEquals("", varAdjacencyMatrix.calculate(peterson).get(0)); } @Test public void testNumOfIndSets() { NumOfIndSets varNumOfIndSets = new NumOfIndSets(); - Assertions.assertEquals(varNumOfIndSets.calculate(peterson),0); + Assert.assertEquals(0, varNumOfIndSets.calculate(peterson).intValue()); } @Test public void testPathsofLengthTwo() { PathsofLengthTwo varPathsofLengthTwo = new PathsofLengthTwo(); - Assertions.assertEquals(varPathsofLengthTwo.calculate(peterson),30);//??? - Assertions.assertEquals(varPathsofLengthTwo.calculate(circle4),4); - Assertions.assertEquals(varPathsofLengthTwo.calculate(circle5),5); - Assertions.assertEquals(varPathsofLengthTwo.calculate(complete4), 15); - Assertions.assertEquals(varPathsofLengthTwo.calculate(complete5), 45); + Assert.assertEquals(30, varPathsofLengthTwo.calculate(peterson).intValue());//??? + Assert.assertEquals(4, varPathsofLengthTwo.calculate(circle4).intValue()); + Assert.assertEquals(5, varPathsofLengthTwo.calculate(circle5).intValue()); + Assert.assertEquals(15, varPathsofLengthTwo.calculate(complete4).intValue()); + Assert.assertEquals(45, varPathsofLengthTwo.calculate(complete5).intValue()); } @Test public void testRadius() { Radius varRadius = new Radius(); - Assertions.assertEquals(varRadius.calculate(TreeForRadiusDiameterTest1),2); - Assertions.assertEquals(varRadius.calculate(TreeForRadiusDiameterTest2),2); - Assertions.assertEquals(varRadius.calculate(circle5),2); - Assertions.assertEquals(varRadius.calculate(complete4), 1); - Assertions.assertEquals(varRadius.calculate(complete5), 1); + Assert.assertEquals(2, varRadius.calculate(TreeForRadiusDiameterTest1).intValue()); + Assert.assertEquals(2, varRadius.calculate(TreeForRadiusDiameterTest2).intValue()); + Assert.assertEquals(2, varRadius.calculate(circle5).intValue()); + Assert.assertEquals(1, varRadius.calculate(complete4).intValue()); + Assert.assertEquals(1, varRadius.calculate(complete5).intValue()); } @Test public void testDiameter() { Diameter varDiameter = new Diameter(); - Assertions.assertEquals(varDiameter.calculate(peterson),2); - Assertions.assertEquals(varDiameter.calculate(circle4),2); - Assertions.assertEquals(varDiameter.calculate(circle5),2); - Assertions.assertEquals(varDiameter.calculate(complete4), 1); - Assertions.assertEquals(varDiameter.calculate(complete5), 1); - Assertions.assertEquals(varDiameter.calculate(TreeForRadiusDiameterTest1),4); - Assertions.assertEquals(varDiameter.calculate(TreeForRadiusDiameterTest2),3); + Assert.assertEquals(2, varDiameter.calculate(peterson).intValue()); + Assert.assertEquals(2, varDiameter.calculate(circle4).intValue()); + Assert.assertEquals(2, varDiameter.calculate(circle5).intValue()); + Assert.assertEquals(1, varDiameter.calculate(complete4).intValue()); + Assert.assertEquals(1, varDiameter.calculate(complete5).intValue()); + Assert.assertEquals(4, varDiameter.calculate(TreeForRadiusDiameterTest1).intValue()); + Assert.assertEquals(3, varDiameter.calculate(TreeForRadiusDiameterTest2).intValue()); } @Test public void testNumOfVertices() { NumOfVertices varNumOfVertices = new NumOfVertices(); - Assertions.assertEquals(varNumOfVertices.calculate(peterson),10); - Assertions.assertEquals(varNumOfVertices.calculate(circle4),4); - Assertions.assertEquals(varNumOfVertices.calculate(circle5),5); - Assertions.assertEquals(varNumOfVertices.calculate(complete4), 4); - Assertions.assertEquals(varNumOfVertices.calculate(complete5), 5); + Assert.assertEquals(10, varNumOfVertices.calculate(peterson).intValue()); + Assert.assertEquals(4, varNumOfVertices.calculate(circle4).intValue()); + Assert.assertEquals(5, varNumOfVertices.calculate(circle5).intValue()); + Assert.assertEquals(4, varNumOfVertices.calculate(complete4).intValue()); + Assert.assertEquals(5, varNumOfVertices.calculate(complete5).intValue()); } @Test public void testNumOfQuadrangle() { NumOfQuadrangle varNumOfQuadrangle = new NumOfQuadrangle(); - Assertions.assertEquals(varNumOfQuadrangle.calculate(peterson),0); - Assertions.assertEquals(varNumOfQuadrangle.calculate(circle4),1); - Assertions.assertEquals(varNumOfQuadrangle.calculate(circle5),0); - Assertions.assertEquals(varNumOfQuadrangle.calculate(complete4), 3);//??? - Assertions.assertEquals(varNumOfQuadrangle.calculate(complete5), 12); + Assert.assertEquals(0, varNumOfQuadrangle.calculate(peterson).intValue()); + Assert.assertEquals(1, varNumOfQuadrangle.calculate(circle4).intValue()); + Assert.assertEquals(0, varNumOfQuadrangle.calculate(circle5).intValue()); + Assert.assertEquals(3, varNumOfQuadrangle.calculate(complete4).intValue());//??? + Assert.assertEquals(12, varNumOfQuadrangle.calculate(complete5).intValue()); } @Test public void testTotalNumOfStars() { TotalNumOfStars varTotalNumOfStars = new TotalNumOfStars(); - Assertions.assertEquals(varTotalNumOfStars.calculate(peterson).get(0),""); + Assert.assertEquals("", varTotalNumOfStars.calculate(peterson).get(0)); } @Test public void testNumOfVerticesWithDegK() { NumOfVerticesWithDegK.k = 3; NumOfVerticesWithDegK varNumOfVerticesWithDegK = new NumOfVerticesWithDegK(); - Assertions.assertEquals(varNumOfVerticesWithDegK.calculate(peterson),10); - Assertions.assertEquals(varNumOfVerticesWithDegK.calculate(circle4),0); - Assertions.assertEquals(varNumOfVerticesWithDegK.calculate(circle5),0); - Assertions.assertEquals(varNumOfVerticesWithDegK.calculate(complete4), 4);//??? - Assertions.assertEquals(varNumOfVerticesWithDegK.calculate(complete5), 0); + Assert.assertEquals(10, varNumOfVerticesWithDegK.calculate(peterson).intValue()); + Assert.assertEquals(0, varNumOfVerticesWithDegK.calculate(circle4).intValue()); + Assert.assertEquals(0, varNumOfVerticesWithDegK.calculate(circle5).intValue()); + Assert.assertEquals(4, varNumOfVerticesWithDegK.calculate(complete4).intValue());//??? + Assert.assertEquals(0, varNumOfVerticesWithDegK.calculate(complete5).intValue()); } @Test public void testKConnected() { KConnected varKConnected = new KConnected(); - Assertions.assertEquals(varKConnected.calculate(peterson),0); + Assert.assertEquals(3, varKConnected.calculate(peterson).intValue()); } @Test public void testSignlessLaplacianEnergy() { SignlessLaplacianEnergy varSignlessLaplacianEnergy = new SignlessLaplacianEnergy(); - Assertions.assertEquals(varSignlessLaplacianEnergy.calculate(peterson),""); + Assert.assertEquals("", varSignlessLaplacianEnergy.calculate(peterson)); } @Test public void testEigenValues() { EigenValues varEigenValues = new EigenValues(); - Assertions.assertEquals(varEigenValues.calculate(peterson).get(0),""); + Assert.assertEquals("", varEigenValues.calculate(peterson).get(0)); } @Test public void testLaplacianEnergyLike() { LaplacianEnergyLike varLaplacianEnergyLike = new LaplacianEnergyLike(); - Assertions.assertEquals(varLaplacianEnergyLike.calculate(peterson),""); + Assert.assertEquals("", varLaplacianEnergyLike.calculate(peterson)); } @Test public void testEccentricityMatrixOfGraph() { EccentricityMatrixOfGraph varEccentricityMatrixOfGraph = new EccentricityMatrixOfGraph(); - Assertions.assertEquals(varEccentricityMatrixOfGraph.calculate(peterson).get(0),""); + Assert.assertEquals("", varEccentricityMatrixOfGraph.calculate(peterson).get(0)); } @Test public void testLaplacianEnergy() { LaplacianEnergy varLaplacianEnergy = new LaplacianEnergy(); - Assertions.assertEquals(varLaplacianEnergy.calculate(peterson),""); + Assert.assertEquals("", varLaplacianEnergy.calculate(peterson)); } @Test public void testLaplacianOfGraph() { LaplacianOfGraph varLaplacianOfGraph = new LaplacianOfGraph(); - Assertions.assertEquals(varLaplacianOfGraph.calculate(peterson).get(0),""); + Assert.assertEquals("", varLaplacianOfGraph.calculate(peterson).get(0)); } @Test public void testKirchhoffIndex() { KirchhoffIndex varKirchhoffIndex = new KirchhoffIndex(); - Assertions.assertEquals(varKirchhoffIndex.calculate(peterson),""); + Assert.assertEquals("", varKirchhoffIndex.calculate(peterson)); } @Test public void testSignlessLaplacianOfGraph() { SignlessLaplacianOfGraph varSignlessLaplacianOfGraph = new SignlessLaplacianOfGraph(); - Assertions.assertEquals(varSignlessLaplacianOfGraph.calculate(peterson).get(0),""); + Assert.assertEquals("", varSignlessLaplacianOfGraph.calculate(peterson).get(0)); } @Test @@ -871,79 +860,78 @@ public void testMaximumFlow() { @Test public void testMaxMatchingExtension() { MaxMatchingExtension varMaxMatchingExtension = new MaxMatchingExtension(); - Assertions.assertEquals(varMaxMatchingExtension.calculate(peterson).get(0),new Object()); } @Test public void testHamiltonianCycleExtension() { HamiltonianCycleExtension varHamiltonianCycleExtension = new HamiltonianCycleExtension(); - Assertions.assertEquals(varHamiltonianCycleExtension.calculate(peterson),new SubGraph()); + Assert.assertEquals(0, varHamiltonianCycleExtension.calculate(peterson).vertices.size()); } @Test public void testHamiltonianPathExtension() { HamiltonianPathExtension varHamiltonianPathExtension = new HamiltonianPathExtension(); - Assertions.assertEquals(varHamiltonianPathExtension.calculate(peterson),new SubGraph()); + Assert.assertEquals(0, varHamiltonianPathExtension.calculate(peterson).vertices.size()); } @Test public void testSzegedIndex() { SzegedIndex varSzegedIndex = new SzegedIndex(); - Assertions.assertEquals(varSzegedIndex.calculate(peterson),0); + Assert.assertEquals(0, varSzegedIndex.calculate(peterson).intValue()); } @Test public void testAllEccen() { AllEccen varAllEccen = new AllEccen(); - Assertions.assertEquals(varAllEccen.calculate(peterson).iterator().next().get(0),0); + Assert.assertEquals(0, varAllEccen.calculate(peterson).iterator().next().get(0)); } @Test public void testRevisedSzegedIndex() { RevisedSzegedIndex varRevisedSzegedIndex = new RevisedSzegedIndex(); - Assertions.assertEquals(varRevisedSzegedIndex.calculate(peterson),0); + Assert.assertEquals(375, varRevisedSzegedIndex.calculate(peterson).intValue()); } @Test public void testMostarIndex() { MostarIndex varMostarIndex = new MostarIndex(); - Assertions.assertEquals(varMostarIndex.calculate(peterson),0); + Assert.assertEquals(0, varMostarIndex.calculate(peterson).intValue()); } @Test public void testMerrifieldSimmons() { MerrifieldSimmons varMerrifieldSimmons = new MerrifieldSimmons(); - Assertions.assertEquals(varMerrifieldSimmons.calculate(peterson).iterator().next().get(0),0); + Assert.assertEquals(0, varMerrifieldSimmons.calculate(peterson).iterator().next().get(0)); } @Test public void testWeightedPiIndex() { WeightedPiIndex varWeightedPiIndex = new WeightedPiIndex(); - Assertions.assertEquals(varWeightedPiIndex.calculate(peterson),0); + Assert.assertEquals(540, varWeightedPiIndex.calculate(peterson).intValue()); } @Test public void testPeripheralVerticesCount() { PeripheralVerticesCount varPeripheralVerticesCount = new PeripheralVerticesCount(); - Assertions.assertEquals(varPeripheralVerticesCount.calculate(peterson),0); + Assert.assertEquals(0, varPeripheralVerticesCount.calculate(peterson).intValue()); } @Test public void testEccentricityEnergy() { EccentricityEnergy varEccentricityEnergy = new EccentricityEnergy(); - Assertions.assertEquals(varEccentricityEnergy.calculate(peterson).iterator().next().get(0),0); + Assert.assertEquals(10, varEccentricityEnergy.calculate(peterson).iterator().next().get(0)); } @Test public void testWeightedSzegedIndex() { WeightedSzegedIndex varWeightedSzegedIndex = new WeightedSzegedIndex(); - Assertions.assertEquals(varWeightedSzegedIndex.calculate(peterson),0); + Assert.assertEquals(810, varWeightedSzegedIndex.calculate(peterson).intValue()); } @Test public void testPeripheralWienerIndex() { PeripheralWienerIndex varPeripheralWienerIndex = new PeripheralWienerIndex(); - Assertions.assertEquals(varPeripheralWienerIndex.calculate(peterson),0); + Assert.assertEquals(75, varPeripheralWienerIndex.calculate(peterson).intValue()); } @Test @@ -954,12 +942,12 @@ public void testPeripheralVertices() { @Test public void testEccentricity() { Eccentricity varEccentricity = new Eccentricity(); - Assertions.assertEquals(varEccentricity.calculate(peterson).iterator().next().get(0),0); + Assert.assertEquals(9, varEccentricity.calculate(peterson).iterator().next().get(0)); } @Test public void testPiIndex() { PiIndex varPiIndex = new PiIndex(); - Assertions.assertEquals(varPiIndex.calculate(peterson),0); + Assert.assertEquals(90, varPiIndex.calculate(peterson).intValue()); } } \ No newline at end of file diff --git a/test/TestActions.java b/src/test/TestActions.java similarity index 92% rename from test/TestActions.java rename to src/test/TestActions.java index e8dc0a23..0a0480cf 100755 --- a/test/TestActions.java +++ b/src/test/TestActions.java @@ -1,3 +1,5 @@ +package test; + import graphtea.extensions.AlgorithmUtils; import graphtea.extensions.generators.CircleGenerator; import graphtea.extensions.generators.CompleteGraphGenerator; @@ -6,8 +8,8 @@ import graphtea.graph.graph.Edge; import graphtea.graph.graph.GraphModel; import graphtea.graph.graph.Vertex; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; +import org.junit.Assert; +import org.junit.Test; public class TestActions { GraphModel peterson = GeneralizedPetersonGenerator.generateGeneralizedPeterson(5,2); @@ -36,6 +38,6 @@ public void testLineGraph() { if(!isCorrect) break; } - Assertions.assertTrue(isCorrect); + Assert.assertTrue(isCorrect); } } diff --git a/test/TestChemicalGraphIndices.java b/src/test/TestChemicalGraphIndices.java similarity index 51% rename from test/TestChemicalGraphIndices.java rename to src/test/TestChemicalGraphIndices.java index 717fba95..8ac1408c 100755 --- a/test/TestChemicalGraphIndices.java +++ b/src/test/TestChemicalGraphIndices.java @@ -1,11 +1,13 @@ +package test; + import graphtea.extensions.G6Format; import graphtea.extensions.reports.others.PeripheralWienerIndex; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; +import org.junit.Assert; +import org.junit.Test; public class TestChemicalGraphIndices { @Test public void testPhericalIndex() { - Assertions.assertEquals(new PeripheralWienerIndex().calculate(G6Format.stringToGraphModel("GnCG[?")),9); + Assert.assertEquals(9, new PeripheralWienerIndex().calculate(G6Format.stringToGraphModel("GnCG[?")).intValue()); } } diff --git a/test/TestHomomorphism.java b/src/test/TestHomomorphism.java similarity index 86% rename from test/TestHomomorphism.java rename to src/test/TestHomomorphism.java index 1174863b..fd186f0f 100755 --- a/test/TestHomomorphism.java +++ b/src/test/TestHomomorphism.java @@ -1,3 +1,5 @@ +package test; + import graphtea.extensions.AllSetPartitions; import graphtea.extensions.algorithms.homomorphism.Homomorphism; import graphtea.extensions.algorithms.shortestpath.algs.FloydWarshall; @@ -7,8 +9,8 @@ import graphtea.extensions.reports.HeuristicGreedyColoring; import graphtea.graph.graph.GraphModel; import graphtea.graph.graph.Vertex; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; +import org.junit.Assert; +import org.junit.Test; import java.util.*; @@ -28,7 +30,7 @@ public void testDegreeHomomorphism() { HashMap hmFunc = hm.getHomomorphism(); int[][] distPeterson = fw.getAllPairsShortestPathWithoutWeight(peterson); int[][] distRange = fw.getAllPairsShortestPathWithoutWeight(hm.getRange()); - Assertions.assertTrue(hm.isValid()); + Assert.assertTrue(hm.isValid()); boolean isCorrect = false; // Collary 1.2 from Pavol Hell Book @@ -41,7 +43,7 @@ public void testDegreeHomomorphism() { break; } } - Assertions.assertTrue(isCorrect); + Assert.assertTrue(isCorrect); } @Test @@ -60,12 +62,3 @@ public void testPartitioner() { System.out.println(allpartitions.size()); } } -// -//class MySubSetListener implements SubSetListener { -// -// @Override -// public boolean subsetFound(int t, ArrayDeque complement, ArrayDeque set) { -// System.out.println(set.size()); -// return false; -// } -//} diff --git a/test/TestListGraph.java b/src/test/TestListGraph.java similarity index 98% rename from test/TestListGraph.java rename to src/test/TestListGraph.java index 2c8a329f..f7d12a48 100755 --- a/test/TestListGraph.java +++ b/src/test/TestListGraph.java @@ -1,4 +1,4 @@ -// GraphTea Project: http://github.com/graphtheorysoftware/GraphTea +package test;// GraphTea Project: http://github.com/graphtheorysoftware/GraphTea // Copyright (C) 2012 Graph Theory Software Foundation: http://GraphTheorySoftware.com // Copyright (C) 2008 Mathematical Science Department of Sharif University of Technology // Distributed under the terms of the GNU Lesser General Public License (LGPL): http://www.gnu.org/licenses/ @@ -18,7 +18,6 @@ /** * TestListGraph.java - * * Created on November 15, 2004, 4:30 AM * @author Omid Aladini */ @@ -231,7 +230,7 @@ public static void mainOld(String[] args) { Iterator> eIterator = myList.edgeIterator(); System.out.print('\n'); while (eIterator.hasNext()) { - BaseEdge e = eIterator.next(); + BaseEdge e = eIterator.next(); System.out.println("An Edge from:" + e.source.getId() + " to:" + e.target.getId()); } @@ -250,7 +249,6 @@ public static void mainOld(String[] args) { } catch (Exception e) { System.out.println("Noooooo:"); - e.printStackTrace(); } } diff --git a/test/TestMatrixGraph.java b/src/test/TestMatrixGraph.java similarity index 98% rename from test/TestMatrixGraph.java rename to src/test/TestMatrixGraph.java index 34552cc3..357d7b6f 100755 --- a/test/TestMatrixGraph.java +++ b/src/test/TestMatrixGraph.java @@ -1,4 +1,4 @@ -// GraphTea Project: http://github.com/graphtheorysoftware/GraphTea +package test;// GraphTea Project: http://github.com/graphtheorysoftware/GraphTea // Copyright (C) 2012 Graph Theory Software Foundation: http://GraphTheorySoftware.com // Copyright (C) 2008 Mathematical Science Department of Sharif University of Technology // Distributed under the terms of the GNU Lesser General Public License (LGPL): http://www.gnu.org/licenses/ @@ -17,7 +17,6 @@ /** * TestMatrixGraph.java - * * Created on November 15, 2004, 4:30 AM * @author Omid Aladini */ diff --git a/test/TestNewEdge.java b/src/test/TestNewEdge.java similarity index 91% rename from test/TestNewEdge.java rename to src/test/TestNewEdge.java index 2c21de9d..bba22d4c 100755 --- a/test/TestNewEdge.java +++ b/src/test/TestNewEdge.java @@ -1,4 +1,4 @@ -// GraphTea Project: http://github.com/graphtheorysoftware/GraphTea +package test;// GraphTea Project: http://github.com/graphtheorysoftware/GraphTea // Copyright (C) 2012 Graph Theory Software Foundation: http://GraphTheorySoftware.com // Copyright (C) 2008 Mathematical Science Department of Sharif University of Technology // Distributed under the terms of the GNU Lesser General Public License (LGPL): http://www.gnu.org/licenses/ diff --git a/test/TestPropertyEditor.java b/src/test/TestPropertyEditor.java similarity index 91% rename from test/TestPropertyEditor.java rename to src/test/TestPropertyEditor.java index 16827d39..1e562a22 100755 --- a/test/TestPropertyEditor.java +++ b/src/test/TestPropertyEditor.java @@ -1,4 +1,4 @@ -// GraphTea Project: http://github.com/graphtheorysoftware/GraphTea +package test;// GraphTea Project: http://github.com/graphtheorysoftware/GraphTea // Copyright (C) 2012 Graph Theory Software Foundation: http://GraphTheorySoftware.com // Copyright (C) 2008 Mathematical Science Department of Sharif University of Technology // Distributed under the terms of the GNU General Public License (GPL): http://www.gnu.org/licenses/ @@ -38,7 +38,7 @@ public static void main(String[] args) { atr.setDescription("azin", "azin>desc"); - x.put("xaray", new ArrayX("azin", "azin", "azadi", "yazdi", "graph")); + x.put("xaray", new ArrayX<>("azin", "azin", "azadi", "yazdi", "graph")); // x.put("---", new ArrayX(true, false, "azin", Color.red)); x.put("bi", new BoundedInteger(20, 30, 10)); From da7fd1313d2bb8a2a851f632dd05a51ece406f19 Mon Sep 17 00:00:00 2001 From: Ali Rostami Date: Tue, 20 May 2025 15:22:39 +0200 Subject: [PATCH 2/7] refactoring --- .github/workflows/ant.yml | 4 ++-- .../spectralreports/SpectraofAvgTransmissionMatrix.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ant.yml b/.github/workflows/ant.yml index 7c1620d7..93da33e2 100755 --- a/.github/workflows/ant.yml +++ b/.github/workflows/ant.yml @@ -9,9 +9,9 @@ jobs: steps: - uses: actions/checkout@v1 - - name: Set up JDK 1.8 + - name: Set up JDK 21 uses: actions/setup-java@v1 with: - java-version: 1.8 + java-version: 21 - name: Build with Ant run: ant -noinput -buildfile build.xml diff --git a/src/graphtea/extensions/reports/spectralreports/SpectraofAvgTransmissionMatrix.java b/src/graphtea/extensions/reports/spectralreports/SpectraofAvgTransmissionMatrix.java index d4235a8e..c251aa6e 100755 --- a/src/graphtea/extensions/reports/spectralreports/SpectraofAvgTransmissionMatrix.java +++ b/src/graphtea/extensions/reports/spectralreports/SpectraofAvgTransmissionMatrix.java @@ -3,7 +3,7 @@ // Copyright (C) 2008 Mathematical Science Department of Sharif University of Technology // Distributed under the terms of the GNU General Public License (GPL): http://www.gnu.org/licenses/ -package graphtea.extensions.reports.basicreports; +package graphtea.extensions.reports.spectralreports; import Jama.EigenvalueDecomposition; import Jama.Matrix; From 60b192a876784259fb0c88b479668d8c5164275a Mon Sep 17 00:00:00 2001 From: Ali Rostami Date: Tue, 20 May 2025 16:07:24 +0200 Subject: [PATCH 3/7] refactoring --- .../reports/topological/{Irr => irr}/AlbertsonIdnexReport.java | 2 +- .../reports/topological/{Irr => irr}/AlbertsonIndex.java | 3 +-- .../extensions/reports/topological/{Irr => irr}/Irr_G.java | 2 +- .../extensions/reports/topological/{Irr => irr}/Irr_t_G.java | 2 +- 4 files changed, 4 insertions(+), 5 deletions(-) rename src/graphtea/extensions/reports/topological/{Irr => irr}/AlbertsonIdnexReport.java (98%) rename src/graphtea/extensions/reports/topological/{Irr => irr}/AlbertsonIndex.java (92%) rename src/graphtea/extensions/reports/topological/{Irr => irr}/Irr_G.java (99%) rename src/graphtea/extensions/reports/topological/{Irr => irr}/Irr_t_G.java (99%) diff --git a/src/graphtea/extensions/reports/topological/Irr/AlbertsonIdnexReport.java b/src/graphtea/extensions/reports/topological/irr/AlbertsonIdnexReport.java similarity index 98% rename from src/graphtea/extensions/reports/topological/Irr/AlbertsonIdnexReport.java rename to src/graphtea/extensions/reports/topological/irr/AlbertsonIdnexReport.java index 2a8f59ef..4eab65ab 100755 --- a/src/graphtea/extensions/reports/topological/Irr/AlbertsonIdnexReport.java +++ b/src/graphtea/extensions/reports/topological/irr/AlbertsonIdnexReport.java @@ -1,4 +1,4 @@ -package graphtea.extensions.reports.topological.Irr; +package graphtea.extensions.reports.topological.irr; import graphtea.extensions.AlgorithmUtils; import graphtea.extensions.reports.basicreports.NumOfTriangles; diff --git a/src/graphtea/extensions/reports/topological/Irr/AlbertsonIndex.java b/src/graphtea/extensions/reports/topological/irr/AlbertsonIndex.java similarity index 92% rename from src/graphtea/extensions/reports/topological/Irr/AlbertsonIndex.java rename to src/graphtea/extensions/reports/topological/irr/AlbertsonIndex.java index 2da2f0ca..9504d180 100755 --- a/src/graphtea/extensions/reports/topological/Irr/AlbertsonIndex.java +++ b/src/graphtea/extensions/reports/topological/irr/AlbertsonIndex.java @@ -2,9 +2,8 @@ // Copyright (C) 2012 Graph Theory Software Foundation: http://GraphTheorySoftware.com // Copyright (C) 2008 Mathematical Science Department of Sharif University of Technology // Distributed under the terms of the GNU General Public License (GPL): http://www.gnu.org/licenses/ -package graphtea.extensions.reports.topological.Irr; +package graphtea.extensions.reports.topological.irr; -import graphtea.extensions.algorithms.shortestpath.algs.FloydWarshall; import graphtea.graph.graph.GraphModel; import graphtea.graph.graph.Vertex; import graphtea.platform.lang.CommandAttitude; diff --git a/src/graphtea/extensions/reports/topological/Irr/Irr_G.java b/src/graphtea/extensions/reports/topological/irr/Irr_G.java similarity index 99% rename from src/graphtea/extensions/reports/topological/Irr/Irr_G.java rename to src/graphtea/extensions/reports/topological/irr/Irr_G.java index c9c7e160..db602a55 100755 --- a/src/graphtea/extensions/reports/topological/Irr/Irr_G.java +++ b/src/graphtea/extensions/reports/topological/irr/Irr_G.java @@ -1,4 +1,4 @@ -package graphtea.extensions.reports.topological.Irr; +package graphtea.extensions.reports.topological.irr; import graphtea.extensions.AlgorithmUtils; import graphtea.extensions.reports.basicreports.NumOfTriangles; diff --git a/src/graphtea/extensions/reports/topological/Irr/Irr_t_G.java b/src/graphtea/extensions/reports/topological/irr/Irr_t_G.java similarity index 99% rename from src/graphtea/extensions/reports/topological/Irr/Irr_t_G.java rename to src/graphtea/extensions/reports/topological/irr/Irr_t_G.java index 4432fd59..94cf75f4 100755 --- a/src/graphtea/extensions/reports/topological/Irr/Irr_t_G.java +++ b/src/graphtea/extensions/reports/topological/irr/Irr_t_G.java @@ -1,4 +1,4 @@ -package graphtea.extensions.reports.topological.Irr; +package graphtea.extensions.reports.topological.irr; import graphtea.extensions.AlgorithmUtils; import graphtea.extensions.reports.basicreports.NumOfTriangles; From cd7fd366d2f3dbc98c52720cb607320283671945 Mon Sep 17 00:00:00 2001 From: Ali Rostami Date: Tue, 20 May 2025 16:09:06 +0200 Subject: [PATCH 4/7] refactoring --- src/graphtea/extensions/G6Format.java | 18 ++-- .../actions/g6/G6CSVStringLoader.java | 2 +- .../extensions/algorithms/GreedyColoring.java | 3 - .../shortestpath/DijkstraAlgorithm.java | 8 +- .../algorithms/shortestpath/algs/Johnson.java | 1 - .../algorithms/spanningtree/Prim.java | 5 - .../generators/BananaTreeGenerator.java | 4 +- .../extensions/generators/CrownGraph.java | 3 +- .../generators/ExampleChainGraph1.java | 2 - .../extensions/generators/HelmGraph.java | 2 +- .../generators/KneserGraphGenerator.java | 5 +- .../ModifiedGeneralizedWebGraph.java | 4 +- .../extensions/generators/Sudoko.java | 2 - .../generators/SunletCrownGraph.java | 4 +- .../extensions/generators/TreeGenerator.java | 2 +- .../extensions/generators/WebGraph.java | 4 +- src/graphtea/extensions/io/LatexWriter.java | 43 ++------- .../io/g6format/LoadGraph6Format.java | 10 +- .../io/specialjson/LoadSpecialjson.java | 35 ++++--- .../SpectraofTransmissionMatrix.java | 2 +- .../forall/filters/DivideBigData.java | 2 +- .../forall/filters/QIntegralFilter.java | 2 +- .../reports/clique/MaxCliqueAlg.java | 2 +- .../extensions/reports/coloring/NDMetis.java | 6 +- .../reports/energy/AllEnergies.java | 8 +- .../reports/energy/AllEnergies1.java | 59 ++++++------ .../extensions/reports/energy/Energy.java | 8 +- .../extensions/reports/energy/Linear.java | 14 +-- .../energy/MixSignlessLaplacianEnergy.java | 4 +- .../reports/energy/NewLowerBounds.java | 6 +- .../NormalizedLaplacianResolventEnergy.java | 2 +- .../reports/energy/ResolventEnergies.java | 8 +- .../reports/energy/ResolventEnergy.java | 4 +- .../energy/ResolventLaplacianEnergy.java | 5 +- .../ResolventSignlessLaplacianEnergy.java | 5 +- .../reports/energy/UpperBounds.java | 2 +- .../spectralreports/DegreeKirchhoffIndex.java | 2 +- .../EccentricityMatrixOfGraph.java | 2 +- .../reports/spectralreports/EigenValues.java | 4 +- .../spectralreports/KirchhoffIndex.java | 2 +- .../spectralreports/LaplacianEnergy.java | 5 +- .../spectralreports/LaplacianEnergyLike.java | 2 +- .../spectralreports/LaplacianOfGraph.java | 6 +- .../SignlessLaplacianEnergy.java | 4 +- .../SignlessLaplacianOfGraph.java | 6 +- .../SpectraofAvgTransmissionMatrix.java | 2 +- .../maxflowmincut/MaxFlow.java | 2 +- .../maxflowmincut/PushRelabel.java | 2 +- .../spectralreports/maxflowmincut/one.java | 12 +-- .../reports/topological/AGIndex.java | 87 +++++++++--------- .../reports/topological/ComparingE1E2.java | 91 ++++++++++--------- .../reports/topological/DegreeDistance.java | 2 +- .../topological/EccentricWienerIndex.java | 2 +- .../reports/topological/GutmanIndex.java | 2 +- .../IncrementalVariableZagrebIndex.java | 6 +- .../reports/topological/MWienerIndex.java | 2 +- .../reports/topological/VeIndex.java | 8 -- .../topological/WeightedWienerIndex.java | 2 +- .../reports/topological/WienerIndex.java | 2 +- .../reports/topological/WienerPolarity.java | 2 +- .../graph/graph/AbstractGraphRenderer.java | 5 +- src/graphtea/graph/graph/GraphColoring.java | 16 ++-- src/graphtea/graph/graph/SubGraph.java | 20 ++-- src/graphtea/graph/ui/GHTMLPageComponent.java | 2 +- src/graphtea/graph/ui/GTabbedGraphPane.java | 2 +- .../graph/ui/GTextFileRendererComponent.java | 6 +- src/graphtea/library/MatrixGraph.java | 2 +- src/graphtea/library/util/Ellipsoid.java | 2 +- src/graphtea/library/util/Msg.java | 4 +- src/graphtea/platform/core/BlackBoard.java | 2 +- .../platform/extension/BasicExtension.java | 2 +- .../extension/ExtensionClassLoader.java | 2 +- .../platform/extension/ExtensionLoader.java | 6 +- .../platform/lang/FromStringProvider.java | 2 +- src/graphtea/platform/lang/SetValidator.java | 8 +- src/graphtea/platform/plugin/Plugger.java | 2 +- .../commandline/commands/GraphCommands.java | 20 ++-- .../commandline/commands/NativeCommands.java | 19 ++-- .../extensionloader/BSHExtensionLoader.java | 34 +++---- .../parsers/InwardCommandParser.java | 53 ++++++----- .../CodeCompletionUtils.java | 44 ++++----- src/graphtea/plugins/main/Init.java | 8 +- src/graphtea/plugins/main/ccp/Paste.java | 4 +- .../core/actions/GraphPropertyEditor.java | 4 +- .../actions/LastSelectedStatusAction.java | 4 +- .../main/saveload/matrix/LoadMatrix.java | 26 +++--- .../plugins/main/saveload/matrix/Matrix.java | 22 ++--- .../main/select/RectangularSelect.java | 3 +- .../plugins/main/select/ScaleInSelection.java | 5 - src/graphtea/plugins/main/select/Select.java | 2 +- .../plugins/main/select/SelectUpdater.java | 9 +- .../plugins/main/ui/GShapeRenderer.java | 2 +- .../main/ui/GraphColoringRenderer.java | 35 ++++--- .../main/ui/IndSetColoringRenderer.java | 61 +++++++------ .../plugins/main/ui/SubGraphRenderer.java | 47 +++++----- .../visualization/localsfvis/animatorLSF.java | 8 +- .../HierarchicalTreeVisualization.java | 1 - .../SparseTreeVisualization.java | 3 - .../ui/texteditor/myplugin/UISample.java | 2 +- .../myplugin/actions/SaveAction.java | 2 +- src/graphtea/ui/AttributeSetView.java | 2 +- src/graphtea/ui/ParameterShower.java | 2 +- src/graphtea/ui/components/GButton.java | 2 +- .../gpropertyeditor/GPropertyEditor.java | 6 +- .../ui/extension/AbstractExtensionAction.java | 35 +++---- src/graphtea/ui/xml/UIHandlerImpl.java | 10 +- 106 files changed, 538 insertions(+), 573 deletions(-) diff --git a/src/graphtea/extensions/G6Format.java b/src/graphtea/extensions/G6Format.java index a9d9b865..e797deb5 100755 --- a/src/graphtea/extensions/G6Format.java +++ b/src/graphtea/extensions/G6Format.java @@ -126,29 +126,29 @@ public static String graphToG6(GraphModel g) { } public static String createAdjMatrix (Matrix m){ - String result=""; + StringBuilder result= new StringBuilder(); for (int i = 1, k = 1; k < m.getColumnDimension(); i++, k++) { for (int j = 0; j < i; j++) { - if (m.get(j,i) != 0) result += "1"; - else result += "0"; + if (m.get(j,i) != 0) result.append("1"); + else result.append("0"); } } - return result; + return result.toString(); } public static String encodeGraph(int NoNodes, String adjmatrix) { - String rv = ""; + StringBuilder rv = new StringBuilder(); int[] nn = encodeN(NoNodes); int[] adj = encodeR(adjmatrix); int[] res = new int[nn.length + adj.length]; System.arraycopy(nn, 0, res, 0, nn.length); System.arraycopy(adj, 0, res, nn.length, adj.length); for (int re : res) { - rv = rv + (char) re; + rv.append((char) re); } - return rv; + return rv.toString(); } private static int[] encodeN(long i) { @@ -196,9 +196,9 @@ private static String padR(String str) { } private static String padL(String str, int h) { - String retval = ""; + StringBuilder retval = new StringBuilder(); for (int i = 0; i < h - str.length(); i++) { - retval += "0"; + retval.append("0"); } return retval + str; } diff --git a/src/graphtea/extensions/actions/g6/G6CSVStringLoader.java b/src/graphtea/extensions/actions/g6/G6CSVStringLoader.java index 1e546976..d84cda41 100755 --- a/src/graphtea/extensions/actions/g6/G6CSVStringLoader.java +++ b/src/graphtea/extensions/actions/g6/G6CSVStringLoader.java @@ -60,7 +60,7 @@ public void action(GraphData graphData) { if (id == given_id) g6 = line.substring(line.lastIndexOf(",") + 1).trim(); } - if(!g6.equals("")) { + if(!g6.isEmpty()) { GraphModel g = G6Format.stringToGraphModel(g6); GPoint[] pp = PositionGenerators.circle(200, 400, 250, g.numOfVertices()); diff --git a/src/graphtea/extensions/algorithms/GreedyColoring.java b/src/graphtea/extensions/algorithms/GreedyColoring.java index 6aaf41ac..ad2f69e3 100755 --- a/src/graphtea/extensions/algorithms/GreedyColoring.java +++ b/src/graphtea/extensions/algorithms/GreedyColoring.java @@ -1,6 +1,5 @@ package graphtea.extensions.algorithms; -import graphtea.graph.graph.Edge; import graphtea.graph.graph.GraphModel; import graphtea.graph.graph.Vertex; import graphtea.platform.core.BlackBoard; @@ -8,9 +7,7 @@ import graphtea.plugins.algorithmanimator.extension.AlgorithmExtension; import graphtea.plugins.main.core.actions.ResetGraph; -import java.util.ArrayList; import java.util.Collections; -import java.util.Iterator; import java.util.Vector; /** diff --git a/src/graphtea/extensions/algorithms/shortestpath/DijkstraAlgorithm.java b/src/graphtea/extensions/algorithms/shortestpath/DijkstraAlgorithm.java index 525e570e..acc198c7 100755 --- a/src/graphtea/extensions/algorithms/shortestpath/DijkstraAlgorithm.java +++ b/src/graphtea/extensions/algorithms/shortestpath/DijkstraAlgorithm.java @@ -14,7 +14,7 @@ /** * This method finds the shortest path from a vertex to all vertices * of a graph. - * + *

* Created by rostam on 06.03.15. * @author M. Ali Rostami */ @@ -25,11 +25,11 @@ public DijkstraAlgorithm(BlackBoard blackBoard) { /** * This method finds a reference array using Dijkstra algorithm - * from which, one can find + * from which one can find * the shortest paths of all vertices of a graph from an arbitrary * given vertex. - * - * graph Graph object to be searched. + *

+ * graph Graph object to be searched. * vertex The source of the paths. * Creates Vector of vertices that for each i, it has a reference to * the vertex, before the vertex with ID number i in the shortest path diff --git a/src/graphtea/extensions/algorithms/shortestpath/algs/Johnson.java b/src/graphtea/extensions/algorithms/shortestpath/algs/Johnson.java index 52370d33..229a3d63 100755 --- a/src/graphtea/extensions/algorithms/shortestpath/algs/Johnson.java +++ b/src/graphtea/extensions/algorithms/shortestpath/algs/Johnson.java @@ -56,7 +56,6 @@ public int[][] ComputePaths(GraphModel g) { if (sp.computePaths(g, u) != null) { Vector pd = sp.computePaths(g, u); for (Vertex v : g) { - int dd = 0; Edge h; while (v != u) { diff --git a/src/graphtea/extensions/algorithms/spanningtree/Prim.java b/src/graphtea/extensions/algorithms/spanningtree/Prim.java index 2673efb9..48ae3f9f 100755 --- a/src/graphtea/extensions/algorithms/spanningtree/Prim.java +++ b/src/graphtea/extensions/algorithms/spanningtree/Prim.java @@ -67,11 +67,6 @@ public Prim(GraphModel graph, // throw new NullPointerException(); this.graph = graph; - /** - * Reference to a GraphConverter object which is responsible for duplication - * of the graph elements, because graph edges and vertices are going to be - * copied to the newly created spanning tree. - */ this.ec = new DefaultEdgeComparator(); } diff --git a/src/graphtea/extensions/generators/BananaTreeGenerator.java b/src/graphtea/extensions/generators/BananaTreeGenerator.java index 2bb599a1..0128c86b 100755 --- a/src/graphtea/extensions/generators/BananaTreeGenerator.java +++ b/src/graphtea/extensions/generators/BananaTreeGenerator.java @@ -14,8 +14,8 @@ /** * Author: Ali Rostami - * - * https://mathworld.wolfram.com/BananaTree.html + *

* ... */ @CommandAttitude(name = "generate_banana_tree", abbreviation = "_g_banana", description = "generates a Banana graph") diff --git a/src/graphtea/extensions/generators/CrownGraph.java b/src/graphtea/extensions/generators/CrownGraph.java index 51a9162d..3d045f21 100755 --- a/src/graphtea/extensions/generators/CrownGraph.java +++ b/src/graphtea/extensions/generators/CrownGraph.java @@ -19,9 +19,8 @@ /** * Author: Ali Rostami + * ...h.html">... * - * https://mathworld.wolfram.com/CrownGraph.html - * */ @CommandAttitude(name = "generate_crown", abbreviation = "_g_crown", description = "generates a Crown graph of order n") diff --git a/src/graphtea/extensions/generators/ExampleChainGraph1.java b/src/graphtea/extensions/generators/ExampleChainGraph1.java index 47d78e64..e7604687 100755 --- a/src/graphtea/extensions/generators/ExampleChainGraph1.java +++ b/src/graphtea/extensions/generators/ExampleChainGraph1.java @@ -17,8 +17,6 @@ import graphtea.plugins.graphgenerator.core.extension.GraphGeneratorExtension; import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; /** * @author azin azadi diff --git a/src/graphtea/extensions/generators/HelmGraph.java b/src/graphtea/extensions/generators/HelmGraph.java index 0221b625..5cf6a3ae 100755 --- a/src/graphtea/extensions/generators/HelmGraph.java +++ b/src/graphtea/extensions/generators/HelmGraph.java @@ -97,7 +97,7 @@ public GraphModel generateGraph() { /** * generates a Helm Graph with given parameters - * + *

* A helm graph, denoted Hn is a graph obtained by attaching a single * edge and node to each node of the outer circuit of a wheel graph Wn. * diff --git a/src/graphtea/extensions/generators/KneserGraphGenerator.java b/src/graphtea/extensions/generators/KneserGraphGenerator.java index 9809f17e..959780a2 100755 --- a/src/graphtea/extensions/generators/KneserGraphGenerator.java +++ b/src/graphtea/extensions/generators/KneserGraphGenerator.java @@ -17,15 +17,14 @@ import graphtea.plugins.graphgenerator.core.extension.GraphGeneratorExtension; import java.util.*; -import java.util.function.Predicate; import java.util.stream.Collectors; import java.util.stream.IntStream; import java.util.stream.Stream; /** * Author: M. Ali Rostami - * - * https://en.wikipedia.org/wiki/Kneser_graph + *

* ... * */ diff --git a/src/graphtea/extensions/generators/ModifiedGeneralizedWebGraph.java b/src/graphtea/extensions/generators/ModifiedGeneralizedWebGraph.java index ab3c6a31..621af2b5 100755 --- a/src/graphtea/extensions/generators/ModifiedGeneralizedWebGraph.java +++ b/src/graphtea/extensions/generators/ModifiedGeneralizedWebGraph.java @@ -19,8 +19,8 @@ /** * Author: M. Ali Rostami - * - * Modified version of https://mathworld.wolfram.com/WebGraph.html in which a central node is added + *

+ * Modified version...WebGraph.html">... in which a central node is added */ @CommandAttitude(name = "generate_webgraph", abbreviation = "_g_webg", description = "generates a Web graph of order n") public class ModifiedGeneralizedWebGraph implements GraphGeneratorExtension, Parametrizable, SimpleGeneratorInterface { diff --git a/src/graphtea/extensions/generators/Sudoko.java b/src/graphtea/extensions/generators/Sudoko.java index f52c3cfd..35d6a9c6 100755 --- a/src/graphtea/extensions/generators/Sudoko.java +++ b/src/graphtea/extensions/generators/Sudoko.java @@ -61,8 +61,6 @@ public Edge[] getEdges() { } for (int i = 0; i < Math.sqrt(n) * n * (Math.sqrt(n) - 1); i++) vs.add(new Edge(v[i], v[(int) (i + Math.sqrt(n) * n)])); - for (int i = 0; i < Math.sqrt(n); i++) { - } Edge[] ret = new Edge[vs.size()]; for (int i = 0; i < vs.size(); i++) ret[i] = vs.get(i); diff --git a/src/graphtea/extensions/generators/SunletCrownGraph.java b/src/graphtea/extensions/generators/SunletCrownGraph.java index 66175ac2..ff4ec02f 100755 --- a/src/graphtea/extensions/generators/SunletCrownGraph.java +++ b/src/graphtea/extensions/generators/SunletCrownGraph.java @@ -18,8 +18,8 @@ /** * Author: Mohsen Khaki - * - * https://mathworld.wolfram.com/SunletGraph.html + *

* ... */ @CommandAttitude(name = "generate_sunlet_crown", abbreviation = "_g_sunlet_crown", description = "generates a Crown graph of order n") diff --git a/src/graphtea/extensions/generators/TreeGenerator.java b/src/graphtea/extensions/generators/TreeGenerator.java index 8a8a672c..0b6f1e64 100755 --- a/src/graphtea/extensions/generators/TreeGenerator.java +++ b/src/graphtea/extensions/generators/TreeGenerator.java @@ -116,7 +116,7 @@ private GPoint[] getVertexPositionUpdown() { double xratio = vwidth / (vertexnInRow + 1); int firstInRow = 0; for (int j = 0; j <= i - 1; j++) { - firstInRow += Math.pow(degree, j); + firstInRow += (int) Math.pow(degree, j); } firstInRow++; diff --git a/src/graphtea/extensions/generators/WebGraph.java b/src/graphtea/extensions/generators/WebGraph.java index 0d8ce8eb..c89ec45f 100755 --- a/src/graphtea/extensions/generators/WebGraph.java +++ b/src/graphtea/extensions/generators/WebGraph.java @@ -19,8 +19,8 @@ /** * Author: M. Ali Rostami - * - * https://mathworld.wolfram.com/WebGraph.html + *

* ... */ @CommandAttitude(name = "generate_webgraph", abbreviation = "_g_webg", description = "generates a Web graph of order n") public class WebGraph implements GraphGeneratorExtension, Parametrizable, SimpleGeneratorInterface { diff --git a/src/graphtea/extensions/io/LatexWriter.java b/src/graphtea/extensions/io/LatexWriter.java index 74be78d4..bd43f6f9 100755 --- a/src/graphtea/extensions/io/LatexWriter.java +++ b/src/graphtea/extensions/io/LatexWriter.java @@ -85,55 +85,30 @@ public void write(File file, GraphModel graph) throws GraphIOException { "%\n" + "%Vertices\n"); - String vertices = " "; + StringBuilder vertices = new StringBuilder(" "); for (Vertex vm : graph) - vertices += "\\put(" - + (vm.getLocation().getX() / r.getMaxX()) * 100 - + "," - + (vm.getLocation().getY() / r.getMaxY()) * 100 - + "){\\circle*{2}}\n"; - output.write(vertices); + vertices.append("\\put(").append((vm.getLocation().getX() / r.getMaxX()) * 100).append(",").append((vm.getLocation().getY() / r.getMaxY()) * 100).append("){\\circle*{2}}\n"); + output.write(vertices.toString()); - String edges = ""; + StringBuilder edges = new StringBuilder(); Iterator em = graph.edgeIterator(); while (em.hasNext()) { Edge e = em.next(); final GPoint sx = e.source.getLocation(); if (!graph.isEdgesCurved()) { - edges += "%Edge Label:" + e.getLabel() + "\n"; - edges += "\\emline{" + - (sx.getX() / r.getMaxX()) * 100 - + "}{" + - (sx.getY() / r.getMaxY()) * 100 - + "}{1}{" + - - (e.target.getLocation().getX() / r.getMaxX()) * 100 - + "}{" + - (e.target.getLocation().getY() / r.getMaxY()) * 100 - + "}{2}\n"; + edges.append("%Edge Label:").append(e.getLabel()).append("\n"); + edges.append("\\emline{").append((sx.getX() / r.getMaxX()) * 100).append("}{").append((sx.getY() / r.getMaxY()) * 100).append("}{1}{").append((e.target.getLocation().getX() / r.getMaxX()) * 100).append("}{").append((e.target.getLocation().getY() / r.getMaxY()) * 100).append("}{2}\n"); } else { - edges += "%Edge Label:" + e.getLabel() + "\n"; + edges.append("%Edge Label:").append(e.getLabel()).append("\n"); double centerx, centery; centerx = (sx.getX() + e.target.getLocation().getX()) / 2; centery = (sx.getY() + e.target.getLocation().getY()) / 2; double cx = ((centerx + e.getCurveControlPoint().getX()) / r.getMaxX()) * 100; double cy = ((e.getCurveControlPoint().getY() + centery) / r.getMaxY()) * 100; - edges += "\\bezier{500}(" + - (sx.getX() / r.getMaxX()) * 100 - + "," + - (sx.getY() / r.getMaxY()) * 100 - + ")(" + - +cx - + "," + - cy - + ")(" + - (e.target.getLocation().getX() / r.getMaxX()) * 100 - + "," + - (e.target.getLocation().getY() / r.getMaxY()) * 100 - + ")\n"; + edges.append("\\bezier{500}(").append((sx.getX() / r.getMaxX()) * 100).append(",").append((sx.getY() / r.getMaxY()) * 100).append(")(").append(cx).append(",").append(cy).append(")(").append((e.target.getLocation().getX() / r.getMaxX()) * 100).append(",").append((e.target.getLocation().getY() / r.getMaxY()) * 100).append(")\n"); } } - output.write(edges); + output.write(edges.toString()); output.write("\n" + "\\end{picture}\n" + "\\end{figure}\n" + diff --git a/src/graphtea/extensions/io/g6format/LoadGraph6Format.java b/src/graphtea/extensions/io/g6format/LoadGraph6Format.java index 91f02f53..d8d2d139 100755 --- a/src/graphtea/extensions/io/g6format/LoadGraph6Format.java +++ b/src/graphtea/extensions/io/g6format/LoadGraph6Format.java @@ -58,26 +58,26 @@ public GraphModel read(File file) { } public GraphModel next(BufferedReader bri) { - String g = ""; + StringBuilder g = new StringBuilder(); try { bri.readLine(); - g=bri.readLine(); + g = new StringBuilder(bri.readLine()); } catch (IOException e) { e.printStackTrace(); } String tmp = g.substring(g.indexOf("order")); tmp = tmp.substring(tmp.indexOf(" "),tmp.length()-1); int numOfVertices = Integer.parseInt(tmp.trim()); - g+= "\n"; + g.append("\n"); for (int i = 0; i < numOfVertices; i++) { try { - g += bri.readLine() + "\n"; + g.append(bri.readLine()).append("\n"); } catch (IOException e) { e.printStackTrace(); return new GraphModel(); } } - return parseGraph(new Scanner(g)); + return parseGraph(new Scanner(g.toString())); } public String getDescription() { diff --git a/src/graphtea/extensions/io/specialjson/LoadSpecialjson.java b/src/graphtea/extensions/io/specialjson/LoadSpecialjson.java index e0731cfc..6524d162 100755 --- a/src/graphtea/extensions/io/specialjson/LoadSpecialjson.java +++ b/src/graphtea/extensions/io/specialjson/LoadSpecialjson.java @@ -132,21 +132,7 @@ public GraphModel read(File file) { Component rendererComponent = GCellRenderer.getRendererFor(rt); rendererComponent.setEnabled(true); jd.add(rendererComponent, BorderLayout.CENTER); - Button bt = new Button("Show settlements without coordinates"); - bt.addActionListener(actionEvent -> { - int i1 = 0; - for(Vertex v : g) { - if(sttlWithoutCoordinates.contains(v.getLabel())) { -// v.setColor(3); - //v.setLocation(new GPoint(200,200 + i*20)); - i1++; - } else { - v.setLocation(new GPoint(100,100)); - v.setColor(0); - } - } - }); - bt.setSize(new Dimension(200,50)); + Button bt = createButtonWithAction(g, sttlWithoutCoordinates); jd.add(bt, BorderLayout.SOUTH); jd.pack(); jd.setVisible(true); @@ -186,6 +172,25 @@ public GraphModel read(File file) { return g; } + private static Button createButtonWithAction(GraphModel g, Vector sttlWithoutCoordinates) { + Button bt = new Button("Show settlements without coordinates"); + bt.addActionListener(actionEvent -> { + int i1 = 0; + for(Vertex v : g) { + if(sttlWithoutCoordinates.contains(v.getLabel())) { +// v.setColor(3); + //v.setLocation(new GPoint(200,200 + i*20)); + i1++; + } else { + v.setLocation(new GPoint(100,100)); + v.setColor(0); + } + } + }); + bt.setSize(new Dimension(200,50)); + return bt; + } + GPoint convertLatLonToXY(double lat, double lon) { double mapWidth = 2000; double mapHeight = 1000; diff --git a/src/graphtea/extensions/reports/basicreports/SpectraofTransmissionMatrix.java b/src/graphtea/extensions/reports/basicreports/SpectraofTransmissionMatrix.java index 35840d11..64c8e555 100755 --- a/src/graphtea/extensions/reports/basicreports/SpectraofTransmissionMatrix.java +++ b/src/graphtea/extensions/reports/basicreports/SpectraofTransmissionMatrix.java @@ -34,7 +34,7 @@ public ArrayList calculate(GraphModel g) { double[] iv = ed.getImagEigenvalues(); for (int i = 0; i < rv.length; i++) if (iv[i] != 0) - res.add("" + AlgorithmUtils.round(rv[i], 5) + " + " + AlgorithmUtils.round(iv[i], 5) + "i"); + res.add(AlgorithmUtils.round(rv[i], 5) + " + " + AlgorithmUtils.round(iv[i], 5) + "i"); else res.add("" + AlgorithmUtils.round(rv[i], 5)); res.add("Eigen Vectors:\n"); diff --git a/src/graphtea/extensions/reports/boundcheck/forall/filters/DivideBigData.java b/src/graphtea/extensions/reports/boundcheck/forall/filters/DivideBigData.java index d2c4bcfc..a3db0298 100755 --- a/src/graphtea/extensions/reports/boundcheck/forall/filters/DivideBigData.java +++ b/src/graphtea/extensions/reports/boundcheck/forall/filters/DivideBigData.java @@ -26,7 +26,7 @@ public static void main(String[] args) throws IOException { String tmp = file.getAbsolutePath(); tmp = tmp.substring(0,tmp.lastIndexOf("/")+1); String tmp2 = file.getName().substring(0,file.getName().lastIndexOf(".")); - tmp = tmp + tmp2 + +(i+1) + ".g6"; + tmp = tmp + tmp2 + (i+1) + ".g6"; FileWriter fw = new FileWriter(tmp); for(int j=0;j < size;j++) { if(sc.hasNext()) { diff --git a/src/graphtea/extensions/reports/boundcheck/forall/filters/QIntegralFilter.java b/src/graphtea/extensions/reports/boundcheck/forall/filters/QIntegralFilter.java index b339101b..915272fe 100755 --- a/src/graphtea/extensions/reports/boundcheck/forall/filters/QIntegralFilter.java +++ b/src/graphtea/extensions/reports/boundcheck/forall/filters/QIntegralFilter.java @@ -21,7 +21,7 @@ private Matrix getSignlessLaplacian(Matrix A) { for (int i = 0; i < n; i++) { sum = 0; for (int j = 0; j < n; j++) { - sum += ATemp[j][i]; + sum += (int) ATemp[j][i]; } DTemp[i][i] = sum; } diff --git a/src/graphtea/extensions/reports/clique/MaxCliqueAlg.java b/src/graphtea/extensions/reports/clique/MaxCliqueAlg.java index 854cf81b..ab516d7b 100755 --- a/src/graphtea/extensions/reports/clique/MaxCliqueAlg.java +++ b/src/graphtea/extensions/reports/clique/MaxCliqueAlg.java @@ -11,7 +11,7 @@ /** * * Bron-Kerbosch clique detection algorithm - * + *

* Samudrala R.,Moult J.:A Graph-theoretic Algorithm for * comparative Modeling of Protein Structure; J.Mol. Biol. (1998); vol 279; pp. * 287-302 diff --git a/src/graphtea/extensions/reports/coloring/NDMetis.java b/src/graphtea/extensions/reports/coloring/NDMetis.java index 508d1cb9..f282da78 100755 --- a/src/graphtea/extensions/reports/coloring/NDMetis.java +++ b/src/graphtea/extensions/reports/coloring/NDMetis.java @@ -34,13 +34,13 @@ public void writeGraphForMetis(GraphModel g) { FileWriter fw = new FileWriter("mats/"+name); fw.write(g.numOfVertices()+ " " + g.getEdgesCount() + "\n"); for(int i=0;i titles = new Vector<>(); - - titles.add("m "); - titles.add("n "); - titles.add("E "); - titles.add("SLE -LE"); - // titles.add("check "); - // titles.add("LE "); - // titles.add("SLE "); - // titles.add("LE-Bar "); - // titles.add("SLE-Bar "); - // titles.add("DE"); - // titles.add("DLE"); -// titles.add("DLSE"); - - titles.add("Bipartite"); - // titles.add(" Components "); - // titles.add(" Resolvent-Energy "); - // titles.add(" Diameter "); - // titles.add(" Matching "); - // titles.add("R.H.S"); - ret.setTitles(titles); + RenderTable ret = getVectors(); double maxDeg = 0; double maxDeg2 = 0; @@ -182,6 +160,33 @@ public RenderTable calculate(GraphModel g) { return ret; } + private static RenderTable getVectors() { + RenderTable ret = new RenderTable(); + Vector titles = new Vector<>(); + + titles.add("m "); + titles.add("n "); + titles.add("E "); + titles.add("SLE -LE"); + // titles.add("check "); + // titles.add("LE "); + // titles.add("SLE "); + // titles.add("LE-Bar "); + // titles.add("SLE-Bar "); + // titles.add("DE"); + // titles.add("DLE"); +// titles.add("DLSE"); + + titles.add("Bipartite"); + // titles.add(" Components "); + // titles.add(" Resolvent-Energy "); + // titles.add(" Diameter "); + // titles.add(" Matching "); + // titles.add("R.H.S"); + ret.setTitles(titles); + return ret; + } + @Override public String getCategory() { return "Verification- Energy"; @@ -225,7 +230,7 @@ public Object SignlessLaplacianEnergy(GraphModel g) { // System.out.println(tmp); // num.plus(tmp); // } - return "" + AlgorithmUtils.round(num.re(), 12) + " + " + return AlgorithmUtils.round(num.re(), 12) + " + " + AlgorithmUtils.round(num.im(), 12) + "i"; } else { return "" + AlgorithmUtils.round(sum, 12); @@ -270,7 +275,7 @@ public Object Energy(GraphModel g) { // System.out.println(tmp); // num.plus(tmp); // } - return "" + AlgorithmUtils.round(num.re(), 22) + " + " + return AlgorithmUtils.round(num.re(), 22) + " + " + AlgorithmUtils.round(num.im(), 22) + "i"; } else { return "" + AlgorithmUtils.round(sum, 12); @@ -316,7 +321,7 @@ public Object ResolventEnergy(GraphModel g) { // System.out.println(tmp); // num.plus(tmp); // } - return "" + AlgorithmUtils.round(num.re(), 12) + " + " + return AlgorithmUtils.round(num.re(), 12) + " + " + AlgorithmUtils.round(num.im(), 12) + "i"; } else { return "" + AlgorithmUtils.round(sum, 12); @@ -372,7 +377,7 @@ public Object LaplacianEnergy(GraphModel g) { // System.out.println(tmp); // num.plus(tmp); // } - return "" + AlgorithmUtils.round(num.re(), 12) + " + " + return AlgorithmUtils.round(num.re(), 12) + " + " + AlgorithmUtils.round(num.im(), 12) + "i"; } else { return "" + AlgorithmUtils.round(sum, 12); diff --git a/src/graphtea/extensions/reports/energy/Energy.java b/src/graphtea/extensions/reports/energy/Energy.java index 5906f610..72ef5512 100755 --- a/src/graphtea/extensions/reports/energy/Energy.java +++ b/src/graphtea/extensions/reports/energy/Energy.java @@ -42,9 +42,7 @@ public String calculate(GraphModel g) { for (double v : iv) sum_i += Math.abs(v); if (sum_i != 0) { - //here is completely false System.out.println("imaginary part is available. So this function does not work."); - sum_i=0; Complex num = new Complex(0,0); // for(int i=0;i < iv.length;i++) { // Complex tmp = new Complex(rv[i], iv[i]); @@ -54,7 +52,7 @@ public String calculate(GraphModel g) { // System.out.println(tmp); // num.plus(tmp); // } - return "" + AlgorithmUtils.round(num.re(), 5) + " + " + return AlgorithmUtils.round(num.re(), 5) + " + " + AlgorithmUtils.round(num.im(), 5) + "i"; } else { return "" + AlgorithmUtils.round(sum, 5); @@ -76,8 +74,8 @@ public String getName() { * 2016, * Pages 2664-2671, * ISSN 0012-365X, - * https://doi.org/10.1016/j.disc.2016.04.022. - * @return + * href="https://doi.org/10.1016/j.disc.2016.04.022">.... + * @return the description */ public String getDescription() { return "Energy"; diff --git a/src/graphtea/extensions/reports/energy/Linear.java b/src/graphtea/extensions/reports/energy/Linear.java index 2595fc0e..91455556 100755 --- a/src/graphtea/extensions/reports/energy/Linear.java +++ b/src/graphtea/extensions/reports/energy/Linear.java @@ -215,7 +215,7 @@ public Object SignlessLaplacianEnergy(GraphModel g) { // System.out.println(tmp); // num.plus(tmp); // } - return "" + AlgorithmUtils.round(num.re(), 12) + " + " + return AlgorithmUtils.round(num.re(), 12) + " + " + AlgorithmUtils.round(num.im(), 12) + "i"; } else { return "" + AlgorithmUtils.round(sum, 12); @@ -261,7 +261,7 @@ public Object GaussEstrada(GraphModel g) { // System.out.println(tmp); // num.plus(tmp); // } - return "" + AlgorithmUtils.round(num.re(), 12) + " + " + return AlgorithmUtils.round(num.re(), 12) + " + " + AlgorithmUtils.round(num.im(), 12) + "i"; } else { return "" + AlgorithmUtils.round(sum, 12); @@ -310,7 +310,7 @@ public Object Estrada(GraphModel g) { // System.out.println(tmp); // num.plus(tmp); // } - return "" + AlgorithmUtils.round(num.re(), 12) + " + " + return AlgorithmUtils.round(num.re(), 12) + " + " + AlgorithmUtils.round(num.im(), 12) + "i"; } else { return "" + AlgorithmUtils.round(sum, 12); @@ -354,7 +354,7 @@ public Object DEnergy(GraphModel g) { // System.out.println(tmp); // num.plus(tmp); // } - return "" + AlgorithmUtils.round(num.re(), 12) + " + " + return AlgorithmUtils.round(num.re(), 12) + " + " + AlgorithmUtils.round(num.im(), 12) + "i"; } else { return "" + AlgorithmUtils.round(sum, 12); @@ -400,7 +400,7 @@ public Object Energy(GraphModel g) { // System.out.println(tmp); // num.plus(tmp); // } - return "" + AlgorithmUtils.round(num.re(), 12) + " + " + return AlgorithmUtils.round(num.re(), 12) + " + " + AlgorithmUtils.round(num.im(), 12) + "i"; } else { return "" + AlgorithmUtils.round(sum, 12); @@ -446,7 +446,7 @@ public Object ResolventEnergy(GraphModel g) { // System.out.println(tmp); // num.plus(tmp); // } - return "" + AlgorithmUtils.round(num.re(), 12) + " + " + return AlgorithmUtils.round(num.re(), 12) + " + " + AlgorithmUtils.round(num.im(), 12) + "i"; } else { return "" + AlgorithmUtils.round(sum, 12); @@ -502,7 +502,7 @@ public Object LaplacianEnergy(GraphModel g) { // System.out.println(tmp); // num.plus(tmp); // } - return "" + AlgorithmUtils.round(num.re(), 12) + " + " + return AlgorithmUtils.round(num.re(), 12) + " + " + AlgorithmUtils.round(num.im(), 12) + "i"; } else { return "" + AlgorithmUtils.round(sum, 12); diff --git a/src/graphtea/extensions/reports/energy/MixSignlessLaplacianEnergy.java b/src/graphtea/extensions/reports/energy/MixSignlessLaplacianEnergy.java index 4cb7c8ff..358c0fca 100755 --- a/src/graphtea/extensions/reports/energy/MixSignlessLaplacianEnergy.java +++ b/src/graphtea/extensions/reports/energy/MixSignlessLaplacianEnergy.java @@ -52,7 +52,7 @@ String signlessLaplacianEnergy(GraphModel g) { // System.out.println(tmp); // num.plus(tmp); // } - return "" + AlgorithmUtils.round(num.re(), 5) + " + " + return AlgorithmUtils.round(num.re(), 5) + " + " + AlgorithmUtils.round(num.im(), 5) + "i"; } else { return "" + AlgorithmUtils.round(sum, 5); @@ -98,7 +98,7 @@ String laplacianEnergy(GraphModel g) { // System.out.println(tmp); // num.plus(tmp); // } - return "" + AlgorithmUtils.round(num.re(), 5) + " + " + return AlgorithmUtils.round(num.re(), 5) + " + " + AlgorithmUtils.round(num.im(), 5) + "i"; } else { return "" + AlgorithmUtils.round(sum, 5); diff --git a/src/graphtea/extensions/reports/energy/NewLowerBounds.java b/src/graphtea/extensions/reports/energy/NewLowerBounds.java index 218635c4..b8ad8f3c 100755 --- a/src/graphtea/extensions/reports/energy/NewLowerBounds.java +++ b/src/graphtea/extensions/reports/energy/NewLowerBounds.java @@ -218,7 +218,7 @@ public Object Energy(GraphModel g) { // System.out.println(tmp); // num.plus(tmp); // } - return "" + AlgorithmUtils.round(num.re(), 10) + " + " + return AlgorithmUtils.round(num.re(), 10) + " + " + AlgorithmUtils.round(num.im(), 10) + "i"; } else { return "" + AlgorithmUtils.round(sum, 10); @@ -268,7 +268,7 @@ public Object SignlessLaplacianEnergy(GraphModel g) { // System.out.println(tmp); // num.plus(tmp); // } - return "" + AlgorithmUtils.round(num.re(), 12) + " + " + return AlgorithmUtils.round(num.re(), 12) + " + " + AlgorithmUtils.round(num.im(), 12) + "i"; } else { return "" + AlgorithmUtils.round(sum, 12); @@ -317,7 +317,7 @@ public Object LaplacianEnergy(GraphModel g) { // System.out.println(tmp); // num.plus(tmp); // } - return "" + AlgorithmUtils.round(num.re(), 12) + " + " + return AlgorithmUtils.round(num.re(), 12) + " + " + AlgorithmUtils.round(num.im(), 12) + "i"; } else { return "" + AlgorithmUtils.round(sum, 12); diff --git a/src/graphtea/extensions/reports/energy/NormalizedLaplacianResolventEnergy.java b/src/graphtea/extensions/reports/energy/NormalizedLaplacianResolventEnergy.java index 33a16b6a..8acaace0 100755 --- a/src/graphtea/extensions/reports/energy/NormalizedLaplacianResolventEnergy.java +++ b/src/graphtea/extensions/reports/energy/NormalizedLaplacianResolventEnergy.java @@ -63,7 +63,7 @@ public String calculate(GraphModel g) { // System.out.println(tmp); // num.plus(tmp); // } - return "" + round(num.re(), 5) + " + " + return round(num.re(), 5) + " + " + round(num.im(), 5) + "i"; } else { return "" + round(sum, 5); diff --git a/src/graphtea/extensions/reports/energy/ResolventEnergies.java b/src/graphtea/extensions/reports/energy/ResolventEnergies.java index d83d76c9..204b0476 100755 --- a/src/graphtea/extensions/reports/energy/ResolventEnergies.java +++ b/src/graphtea/extensions/reports/energy/ResolventEnergies.java @@ -243,7 +243,7 @@ public Object SignlessLaplacianEnergy(GraphModel g) { // System.out.println(tmp); // num.plus(tmp); // } - return "" + AlgorithmUtils.round(num.re(), 12) + " + " + return AlgorithmUtils.round(num.re(), 12) + " + " + AlgorithmUtils.round(num.im(), 12) + "i"; } else { return "" + AlgorithmUtils.round(sum, 12); @@ -288,7 +288,7 @@ public Object Energy(GraphModel g) { // System.out.println(tmp); // num.plus(tmp); // } - return "" + AlgorithmUtils.round(num.re(), 22) + " + " + return AlgorithmUtils.round(num.re(), 22) + " + " + AlgorithmUtils.round(num.im(), 22) + "i"; } else { return "" + AlgorithmUtils.round(sum, 12); @@ -334,7 +334,7 @@ public Object ResolventEnergy(GraphModel g) { // System.out.println(tmp); // num.plus(tmp); // } - return "" + AlgorithmUtils.round(num.re(), 12) + " + " + return AlgorithmUtils.round(num.re(), 12) + " + " + AlgorithmUtils.round(num.im(), 12) + "i"; } else { return "" + AlgorithmUtils.round(sum, 12); @@ -390,7 +390,7 @@ public Object LaplacianEnergy(GraphModel g) { // System.out.println(tmp); // num.plus(tmp); // } - return "" + AlgorithmUtils.round(num.re(), 12) + " + " + return AlgorithmUtils.round(num.re(), 12) + " + " + AlgorithmUtils.round(num.im(), 12) + "i"; } else { return "" + AlgorithmUtils.round(sum, 12); diff --git a/src/graphtea/extensions/reports/energy/ResolventEnergy.java b/src/graphtea/extensions/reports/energy/ResolventEnergy.java index 03f541ae..8c298f07 100755 --- a/src/graphtea/extensions/reports/energy/ResolventEnergy.java +++ b/src/graphtea/extensions/reports/energy/ResolventEnergy.java @@ -54,7 +54,7 @@ public String calculate(GraphModel g) { // System.out.println(tmp); // num.plus(tmp); // } - return "" + AlgorithmUtils.round(num.re(), 5) + " + " + return AlgorithmUtils.round(num.re(), 5) + " + " + AlgorithmUtils.round(num.im(), 5) + "i"; } else { return "" + AlgorithmUtils.round(sum, 5); @@ -76,7 +76,7 @@ public String getName() { * 2016, * Pages 2664-2671, * ISSN 0012-365X, - * https://doi.org/10.1016/j.disc.2016.04.022. + * .... * @return */ public String getDescription() { diff --git a/src/graphtea/extensions/reports/energy/ResolventLaplacianEnergy.java b/src/graphtea/extensions/reports/energy/ResolventLaplacianEnergy.java index 1aa6cd4e..3820ef57 100755 --- a/src/graphtea/extensions/reports/energy/ResolventLaplacianEnergy.java +++ b/src/graphtea/extensions/reports/energy/ResolventLaplacianEnergy.java @@ -44,17 +44,16 @@ public String calculate(GraphModel g) { if (sum_i != 0) { //here is completely false System.out.println("imaginary part is available. So this function does not work."); - sum_i=0; Complex num = new Complex(0,0); for(int i=0;i < iv.length;i++) { Complex tmp = new Complex(rv[i], iv[i]); System.out.println(tmp); - tmp.pow(new Complex(power,0)); + Complex.pow(new Complex(power,0)); System.out.println(power); System.out.println(tmp); num.plus(tmp); } - return "" + AlgorithmUtils.round(num.re(), 5) + " + " + return AlgorithmUtils.round(num.re(), 5) + " + " + AlgorithmUtils.round(num.im(), 5) + "i"; } else { return "" + AlgorithmUtils.round(sum, 5); diff --git a/src/graphtea/extensions/reports/energy/ResolventSignlessLaplacianEnergy.java b/src/graphtea/extensions/reports/energy/ResolventSignlessLaplacianEnergy.java index cc7d6897..f9d81865 100755 --- a/src/graphtea/extensions/reports/energy/ResolventSignlessLaplacianEnergy.java +++ b/src/graphtea/extensions/reports/energy/ResolventSignlessLaplacianEnergy.java @@ -55,7 +55,7 @@ public String calculate(GraphModel g) { // System.out.println(tmp); // num.plus(tmp); // } - return "" + AlgorithmUtils.round(num.re(), 5) + " + " + return AlgorithmUtils.round(num.re(), 5) + " + " + AlgorithmUtils.round(num.im(), 5) + "i"; } else { return "" + AlgorithmUtils.round(sum, 5); @@ -77,8 +77,7 @@ public String getName() { * 2016, * Pages 2664-2671, * ISSN 0012-365X, - * https://doi.org/10.1016/j.disc.2016.04.022. - * @return + * href="https://doi.org/10.1016/j.disc.2016.04.022">.... */ public String getDescription() { return "Resolvent Signless Laplacian Energy"; diff --git a/src/graphtea/extensions/reports/energy/UpperBounds.java b/src/graphtea/extensions/reports/energy/UpperBounds.java index bb392fad..da426add 100755 --- a/src/graphtea/extensions/reports/energy/UpperBounds.java +++ b/src/graphtea/extensions/reports/energy/UpperBounds.java @@ -166,7 +166,7 @@ public Object calc(GraphModel g) { Complex.pow(new Complex(power, 0)); num.plus(tmp); } - return "" + AlgorithmUtils.round(num.re(), 5) + " + " + return AlgorithmUtils.round(num.re(), 5) + " + " + AlgorithmUtils.round(num.im(), 5) + "i"; } else { return "" + AlgorithmUtils.round(sum, 5); diff --git a/src/graphtea/extensions/reports/spectralreports/DegreeKirchhoffIndex.java b/src/graphtea/extensions/reports/spectralreports/DegreeKirchhoffIndex.java index a82dfc8f..d6aa7785 100755 --- a/src/graphtea/extensions/reports/spectralreports/DegreeKirchhoffIndex.java +++ b/src/graphtea/extensions/reports/spectralreports/DegreeKirchhoffIndex.java @@ -63,7 +63,7 @@ public String calculate(GraphModel g) { // System.out.println(tmp); // num.plus(tmp); // } - return "" + round(num.re(), 5) + " + " + return round(num.re(), 5) + " + " + round(num.im(), 5) + "i"; } else { return "" + round(sum, 5); diff --git a/src/graphtea/extensions/reports/spectralreports/EccentricityMatrixOfGraph.java b/src/graphtea/extensions/reports/spectralreports/EccentricityMatrixOfGraph.java index ab7fbcd4..7c82416b 100755 --- a/src/graphtea/extensions/reports/spectralreports/EccentricityMatrixOfGraph.java +++ b/src/graphtea/extensions/reports/spectralreports/EccentricityMatrixOfGraph.java @@ -49,7 +49,7 @@ private ArrayList getEigenValuesAndVectors(Matrix matrix) double[] iv = ed.getImagEigenvalues(); for (int i = 0; i < rv.length; i++) if (iv[i] != 0) - result.add("" + AlgorithmUtils.round(rv[i], 5) + " + " + AlgorithmUtils.round(iv[i], 5) + "i"); + result.add(AlgorithmUtils.round(rv[i], 5) + " + " + AlgorithmUtils.round(iv[i], 5) + "i"); else result.add("" + AlgorithmUtils.round(rv[i], 5)); result.add("Eigen Vectors:\n"); diff --git a/src/graphtea/extensions/reports/spectralreports/EigenValues.java b/src/graphtea/extensions/reports/spectralreports/EigenValues.java index 4049c181..affc9232 100755 --- a/src/graphtea/extensions/reports/spectralreports/EigenValues.java +++ b/src/graphtea/extensions/reports/spectralreports/EigenValues.java @@ -59,7 +59,7 @@ public ArrayList calculate(GraphModel g) { Complex.pow(new Complex(power,0)); num.plus(tmp); } - res.add("" + AlgorithmUtils.round(num.re(), 10) + " + " + res.add(AlgorithmUtils.round(num.re(), 10) + " + " + AlgorithmUtils.round(num.im(), 10) + "i"); } else { res.add("" + AlgorithmUtils.round(sum, 10)); @@ -67,7 +67,7 @@ public ArrayList calculate(GraphModel g) { res.add("Eigen Values"); for (int i = 0; i < rv.length; i++) { if (iv[i] != 0) - res.add("" + AlgorithmUtils.round(rv[i], 10) + " + " + AlgorithmUtils.round(iv[i], 10) + "i"); + res.add(AlgorithmUtils.round(rv[i], 10) + " + " + AlgorithmUtils.round(iv[i], 10) + "i"); else res.add("" + AlgorithmUtils.round(rv[i], 10)); } diff --git a/src/graphtea/extensions/reports/spectralreports/KirchhoffIndex.java b/src/graphtea/extensions/reports/spectralreports/KirchhoffIndex.java index 25f1fb27..a5c5dab8 100755 --- a/src/graphtea/extensions/reports/spectralreports/KirchhoffIndex.java +++ b/src/graphtea/extensions/reports/spectralreports/KirchhoffIndex.java @@ -64,7 +64,7 @@ public String calculate(GraphModel g) { // System.out.println(tmp); // num.plus(tmp); // } - return "" + round(num.re(), 5) + " + " + return round(num.re(), 5) + " + " + round(num.im(), 5) + "i"; } else { return "" + round(sum, 5); diff --git a/src/graphtea/extensions/reports/spectralreports/LaplacianEnergy.java b/src/graphtea/extensions/reports/spectralreports/LaplacianEnergy.java index 5283661f..44efed0b 100755 --- a/src/graphtea/extensions/reports/spectralreports/LaplacianEnergy.java +++ b/src/graphtea/extensions/reports/spectralreports/LaplacianEnergy.java @@ -44,17 +44,16 @@ public String calculate(GraphModel g) { if (sum_i != 0) { //here is completely false System.out.println("imaginary part is available. So this function does not work."); - sum_i=0; Complex num = new Complex(0,0); for(int i=0;i < iv.length;i++) { Complex tmp = new Complex(rv[i], iv[i]); System.out.println(tmp); - tmp.pow(new Complex(power,0)); + Complex.pow(new Complex(power,0)); System.out.println(power); System.out.println(tmp); num.plus(tmp); } - return "" + AlgorithmUtils.round(num.re(), 5) + " + " + return AlgorithmUtils.round(num.re(), 5) + " + " + AlgorithmUtils.round(num.im(), 5) + "i"; } else { return "" + AlgorithmUtils.round(sum, 5); diff --git a/src/graphtea/extensions/reports/spectralreports/LaplacianEnergyLike.java b/src/graphtea/extensions/reports/spectralreports/LaplacianEnergyLike.java index 42d59e2c..98a29c27 100755 --- a/src/graphtea/extensions/reports/spectralreports/LaplacianEnergyLike.java +++ b/src/graphtea/extensions/reports/spectralreports/LaplacianEnergyLike.java @@ -51,7 +51,7 @@ public String calculate(GraphModel g) { // System.out.println(tmp); // num.plus(tmp); // } - return "" + AlgorithmUtils.round(num.re(), 5) + " + " + return AlgorithmUtils.round(num.re(), 5) + " + " + AlgorithmUtils.round(num.im(), 5) + "i"; } else { return "" + AlgorithmUtils.round(sum, 5); diff --git a/src/graphtea/extensions/reports/spectralreports/LaplacianOfGraph.java b/src/graphtea/extensions/reports/spectralreports/LaplacianOfGraph.java index 6e23aa2f..e65170ec 100755 --- a/src/graphtea/extensions/reports/spectralreports/LaplacianOfGraph.java +++ b/src/graphtea/extensions/reports/spectralreports/LaplacianOfGraph.java @@ -45,7 +45,7 @@ private Matrix getLaplacian(Matrix A) sum = 0 ; for(int j=0; j getEigenValuesAndVectors(Matrix matrix) double[] iv = ed.getImagEigenvalues(); for (int i = 0; i < rv.length; i++) if (iv[i] != 0) - result.add("" + AlgorithmUtils.round(rv[i], 10) + " + " + AlgorithmUtils.round(iv[i], 10) + "i"); + result.add(AlgorithmUtils.round(rv[i], 10) + " + " + AlgorithmUtils.round(iv[i], 10) + "i"); else result.add("" + AlgorithmUtils.round(rv[i], 10)); result.add("Eigen Vectors:\n"); diff --git a/src/graphtea/extensions/reports/spectralreports/SignlessLaplacianEnergy.java b/src/graphtea/extensions/reports/spectralreports/SignlessLaplacianEnergy.java index 3a9bf8c3..af8dfea3 100755 --- a/src/graphtea/extensions/reports/spectralreports/SignlessLaplacianEnergy.java +++ b/src/graphtea/extensions/reports/spectralreports/SignlessLaplacianEnergy.java @@ -55,7 +55,7 @@ public String calculate(GraphModel g) { // System.out.println(tmp); // num.plus(tmp); // } - return "" + AlgorithmUtils.round(num.re(), 5) + " + " + return AlgorithmUtils.round(num.re(), 5) + " + " + AlgorithmUtils.round(num.im(), 5) + "i"; } else { return "" + AlgorithmUtils.round(sum, 5); @@ -77,7 +77,7 @@ public String getName() { * 2016, * Pages 2664-2671, * ISSN 0012-365X, - * https://doi.org/10.1016/j.disc.2016.04.022. + * .... * @return description */ public String getDescription() { diff --git a/src/graphtea/extensions/reports/spectralreports/SignlessLaplacianOfGraph.java b/src/graphtea/extensions/reports/spectralreports/SignlessLaplacianOfGraph.java index 3208a048..b5a8f0a4 100755 --- a/src/graphtea/extensions/reports/spectralreports/SignlessLaplacianOfGraph.java +++ b/src/graphtea/extensions/reports/spectralreports/SignlessLaplacianOfGraph.java @@ -45,7 +45,7 @@ private Matrix getSignlessLaplacian(Matrix A) sum = 0 ; for(int j=0; j getEigenValuesAndVectors(Matrix matrix) double[] iv = ed.getImagEigenvalues(); for (int i = 0; i < rv.length; i++) if (iv[i] != 0) - result.add("" + AlgorithmUtils.round(rv[i], 5) + " + " + AlgorithmUtils.round(iv[i], 5) + "i"); + result.add(AlgorithmUtils.round(rv[i], 5) + " + " + AlgorithmUtils.round(iv[i], 5) + "i"); else result.add("" + AlgorithmUtils.round(rv[i], 5)); result.add("Eigen Vectors:\n"); diff --git a/src/graphtea/extensions/reports/spectralreports/SpectraofAvgTransmissionMatrix.java b/src/graphtea/extensions/reports/spectralreports/SpectraofAvgTransmissionMatrix.java index c251aa6e..3e594d25 100755 --- a/src/graphtea/extensions/reports/spectralreports/SpectraofAvgTransmissionMatrix.java +++ b/src/graphtea/extensions/reports/spectralreports/SpectraofAvgTransmissionMatrix.java @@ -34,7 +34,7 @@ public ArrayList calculate(GraphModel g) { double[] iv = ed.getImagEigenvalues(); for (int i = 0; i < rv.length; i++) if (iv[i] != 0) - res.add("" + AlgorithmUtils.round(rv[i], 5) + " + " + AlgorithmUtils.round(iv[i], 5) + "i"); + res.add(AlgorithmUtils.round(rv[i], 5) + " + " + AlgorithmUtils.round(iv[i], 5) + "i"); else res.add("" + AlgorithmUtils.round(rv[i], 5)); res.add("Eigen Vectors:\n"); diff --git a/src/graphtea/extensions/reports/spectralreports/maxflowmincut/MaxFlow.java b/src/graphtea/extensions/reports/spectralreports/maxflowmincut/MaxFlow.java index a39275d3..0782635b 100755 --- a/src/graphtea/extensions/reports/spectralreports/maxflowmincut/MaxFlow.java +++ b/src/graphtea/extensions/reports/spectralreports/maxflowmincut/MaxFlow.java @@ -30,7 +30,7 @@ public int perform() int res=0; for(int i=0; i titles = new Vector<>(); - titles.add(" m "); - // titles.add(" Max Planar "); - titles.add(" n "); - // titles.add(" Min "); - // titles.add(" Lanzhou "); - titles.add(" R "); - titles.add(" GA "); - titles.add(" AG "); - titles.add(" SDD "); - // titles.add(" R-min "); - // titles.add(" HM2 "); - // titles.add(" EM2 "); - // titles.add(" Hyper "); - // titles.add(" M2-M1 "); - // titles.add(" milo "); - // titles.add(" Inverse Sum Indeg "); - // titles.add(" SDD "); - // titles.add(" R.H.S "); - // titles.add(" max "); - // titles.add(" min "); - // titles.add(" Hyper "); - // titles.add("Th 7 "); - // titles.add("check"); - // titles.add("Correct"); - // titles.add(" matching "); - // titles.add(" GA/x "); - // titles.add(" Wp "); - // titles.add(" chrome "); - // titles.add(" chrome "); - // titles.add(" Lz "); - // titles.add(" Lz-Bar "); - - // titles.add(" R.H.S "); - // titles.add("Diameter"); - // titles.add("Clique Number"); - - titles.add(" V. Degrees "); - - ret.setTitles(titles); + RenderTable ret = getVectors(); double maxDeg = 0; double maxDeg2 = 0; @@ -273,6 +233,51 @@ public RenderTable calculate(GraphModel g) { return ret; } + private static RenderTable getVectors() { + RenderTable ret = new RenderTable(); + Vector titles = new Vector<>(); + titles.add(" m "); + // titles.add(" Max Planar "); + titles.add(" n "); + // titles.add(" Min "); + // titles.add(" Lanzhou "); + titles.add(" R "); + titles.add(" GA "); + titles.add(" AG "); + titles.add(" SDD "); + // titles.add(" R-min "); + // titles.add(" HM2 "); + // titles.add(" EM2 "); + // titles.add(" Hyper "); + // titles.add(" M2-M1 "); + // titles.add(" milo "); + // titles.add(" Inverse Sum Indeg "); + // titles.add(" SDD "); + // titles.add(" R.H.S "); + // titles.add(" max "); + // titles.add(" min "); + // titles.add(" Hyper "); + // titles.add("Th 7 "); + // titles.add("check"); + // titles.add("Correct"); + // titles.add(" matching "); + // titles.add(" GA/x "); + // titles.add(" Wp "); + // titles.add(" chrome "); + // titles.add(" chrome "); + // titles.add(" Lz "); + // titles.add(" Lz-Bar "); + + // titles.add(" R.H.S "); + // titles.add("Diameter"); + // titles.add("Clique Number"); + + titles.add(" V. Degrees "); + + ret.setTitles(titles); + return ret; + } + @Override public String getCategory() { return "Verification-Degree"; diff --git a/src/graphtea/extensions/reports/topological/ComparingE1E2.java b/src/graphtea/extensions/reports/topological/ComparingE1E2.java index b525db6a..f4cec18f 100755 --- a/src/graphtea/extensions/reports/topological/ComparingE1E2.java +++ b/src/graphtea/extensions/reports/topological/ComparingE1E2.java @@ -34,49 +34,7 @@ public String getDescription() { public RenderTable calculate(GraphModel g) { ZagrebIndexFunctions zif = new ZagrebIndexFunctions(g); - RenderTable ret = new RenderTable(); - Vector titles = new Vector<>(); - titles.add(" m "); - titles.add(" n "); - // titles.add(" ECI "); - // titles.add(" E1 "); - // titles.add(" E2 "); - // titles.add(" EDS "); - // titles.add(" EDS-ECI"); - titles.add(" EDS-E1"); - titles.add(" EDS-E2"); - // titles.add(" ECI/EDS "); - // titles.add(" EAI "); - //titles.add(" i(G) "); - //titles.add(" i(G-Bar) "); - // titles.add(" i(G)+i(G-Bar) "); - // titles.add(" EDS-E1 "); - // titles.add(" E1/EDS "); - // titles.add(" EDS-E2 "); -// titles.add(" E2/EDS "); - //titles.add(" G-comp "); - // titles.add(" E1/n "); - // titles.add(" E2/m "); - // titles.add(" CE-comp "); - // titles.add(" EC-comp "); - // titles.add(" E1 "); - // titles.add(" E2 "); - // titles.add( " Thm 1.6 "); -// titles.add( " Thm 1.6 "); - - // titles.add(" E1-R.H.S "); - // titles.add(" E2-R.H.S "); - // titles.add(" E_1-Bar / n "); - // titles.add(" E_2-Bar / m-bar "); - // titles.add(" Eccen "); - // titles.add(" Diameter "); - // titles.add(" DiamComp "); - // titles.add(" alpha "); - // titles.add("Chromatic number"); - // titles.add("Alpha"); - // titles.add("MinDeg"); - // titles.add("Max Clique Size"); - ret.setTitles(titles); + RenderTable ret = getVectors(); double maxDeg = 0; double maxDeg2 = 0; @@ -278,6 +236,53 @@ public RenderTable calculate(GraphModel g) { return ret; } + private static RenderTable getVectors() { + RenderTable ret = new RenderTable(); + Vector titles = new Vector<>(); + titles.add(" m "); + titles.add(" n "); + // titles.add(" ECI "); + // titles.add(" E1 "); + // titles.add(" E2 "); + // titles.add(" EDS "); + // titles.add(" EDS-ECI"); + titles.add(" EDS-E1"); + titles.add(" EDS-E2"); + // titles.add(" ECI/EDS "); + // titles.add(" EAI "); + //titles.add(" i(G) "); + //titles.add(" i(G-Bar) "); + // titles.add(" i(G)+i(G-Bar) "); + // titles.add(" EDS-E1 "); + // titles.add(" E1/EDS "); + // titles.add(" EDS-E2 "); +// titles.add(" E2/EDS "); + //titles.add(" G-comp "); + // titles.add(" E1/n "); + // titles.add(" E2/m "); + // titles.add(" CE-comp "); + // titles.add(" EC-comp "); + // titles.add(" E1 "); + // titles.add(" E2 "); + // titles.add( " Thm 1.6 "); +// titles.add( " Thm 1.6 "); + + // titles.add(" E1-R.H.S "); + // titles.add(" E2-R.H.S "); + // titles.add(" E_1-Bar / n "); + // titles.add(" E_2-Bar / m-bar "); + // titles.add(" Eccen "); + // titles.add(" Diameter "); + // titles.add(" DiamComp "); + // titles.add(" alpha "); + // titles.add("Chromatic number"); + // titles.add("Alpha"); + // titles.add("MinDeg"); + // titles.add("Max Clique Size"); + ret.setTitles(titles); + return ret; + } + @Override public String getCategory() { return "Verification-Checking"; diff --git a/src/graphtea/extensions/reports/topological/DegreeDistance.java b/src/graphtea/extensions/reports/topological/DegreeDistance.java index f3194a44..422a68d2 100755 --- a/src/graphtea/extensions/reports/topological/DegreeDistance.java +++ b/src/graphtea/extensions/reports/topological/DegreeDistance.java @@ -38,7 +38,7 @@ public Integer calculate(GraphModel g) { int degreeOfU = g.getDegree(g.getVertex(u)); int degreeOfV = g.getDegree(g.getVertex(v)); - sum += (degreeOfU + degreeOfV) * UVdist; + sum += (int) ((degreeOfU + degreeOfV) * UVdist); } } } diff --git a/src/graphtea/extensions/reports/topological/EccentricWienerIndex.java b/src/graphtea/extensions/reports/topological/EccentricWienerIndex.java index e1e14c97..25a4c44e 100755 --- a/src/graphtea/extensions/reports/topological/EccentricWienerIndex.java +++ b/src/graphtea/extensions/reports/topological/EccentricWienerIndex.java @@ -43,7 +43,7 @@ public Integer calculate(GraphModel g) { double eu = Eccentricity.eccentricity(g,u,dist); double ev = Eccentricity.eccentricity(g,v,dist); double epsilon = dist[v][u] == Math.min(eu,ev) ? dist[v][u] : 0; - sum += epsilon; + sum += (int) epsilon; } } return sum; diff --git a/src/graphtea/extensions/reports/topological/GutmanIndex.java b/src/graphtea/extensions/reports/topological/GutmanIndex.java index c08bd8e5..c0b55d29 100755 --- a/src/graphtea/extensions/reports/topological/GutmanIndex.java +++ b/src/graphtea/extensions/reports/topological/GutmanIndex.java @@ -37,7 +37,7 @@ public Integer calculate(GraphModel g) { int degreeOfU = g.getDegree(g.getVertex(u)); int degreeOfV = g.getDegree(g.getVertex(v)); - sum += (degreeOfU * degreeOfV) * UVdist; + sum += (int) ((degreeOfU * degreeOfV) * UVdist); } } } diff --git a/src/graphtea/extensions/reports/topological/IncrementalVariableZagrebIndex.java b/src/graphtea/extensions/reports/topological/IncrementalVariableZagrebIndex.java index 96e84605..db648c83 100755 --- a/src/graphtea/extensions/reports/topological/IncrementalVariableZagrebIndex.java +++ b/src/graphtea/extensions/reports/topological/IncrementalVariableZagrebIndex.java @@ -24,13 +24,13 @@ public String getName() { return "Incremental Variable Zagreb Indices"; } - @Parameter(name = "Starting Value of Alpha", description = "") + @Parameter(name = "Starting Value of Alpha", description = "Starting Value of Alpha") public Double start_alpha = -10.0; - @Parameter(name = "End Value of Alpha", description = "") + @Parameter(name = "End Value of Alpha", description = "End Value of Alpha") public Double end_alpha = 10.0; - @Parameter(name = "Incremental Value", description = "") + @Parameter(name = "Incremental Value", description = "Incremental Value") public Double inc = 0.1; public String getDescription() { diff --git a/src/graphtea/extensions/reports/topological/MWienerIndex.java b/src/graphtea/extensions/reports/topological/MWienerIndex.java index b19f64a9..2e6b5b82 100755 --- a/src/graphtea/extensions/reports/topological/MWienerIndex.java +++ b/src/graphtea/extensions/reports/topological/MWienerIndex.java @@ -33,7 +33,7 @@ public Integer calculate(GraphModel g) { if(spt[v][u] < g.numOfVertices() + 1) { double dist = spt[u][v]; if(dist > max) { - sum *= dist; + sum *= (int) dist; } } } diff --git a/src/graphtea/extensions/reports/topological/VeIndex.java b/src/graphtea/extensions/reports/topological/VeIndex.java index 2849167d..39e3a387 100755 --- a/src/graphtea/extensions/reports/topological/VeIndex.java +++ b/src/graphtea/extensions/reports/topological/VeIndex.java @@ -1,23 +1,15 @@ package graphtea.extensions.reports.topological; import graphtea.extensions.AlgorithmUtils; -import graphtea.extensions.generators.CompleteGraphGenerator; -import graphtea.extensions.reports.ChromaticNumber; -import graphtea.extensions.reports.RandomMatching; -import graphtea.extensions.reports.basicreports.Diameter; import graphtea.extensions.reports.basicreports.NumOfVerticesWithDegK; import graphtea.extensions.reports.basicreports.NumOfTriangles; -import graphtea.extensions.reports.clique.MaxCliqueSize; import graphtea.graph.graph.Edge; import graphtea.graph.graph.GraphModel; import graphtea.graph.graph.RenderTable; import graphtea.graph.graph.Vertex; import graphtea.platform.lang.CommandAttitude; -import graphtea.plugins.main.ui.TableRenderer; import graphtea.plugins.reports.extension.GraphReportExtension; -import javax.swing.*; -import java.awt.*; import java.util.ArrayList; import java.util.Collections; import java.util.List; diff --git a/src/graphtea/extensions/reports/topological/WeightedWienerIndex.java b/src/graphtea/extensions/reports/topological/WeightedWienerIndex.java index d2014c11..52ec589f 100755 --- a/src/graphtea/extensions/reports/topological/WeightedWienerIndex.java +++ b/src/graphtea/extensions/reports/topological/WeightedWienerIndex.java @@ -35,7 +35,7 @@ public Object calculate(GraphModel g) { if(dist > max) { int degreeOfU = g.getDegree(g.getVertex(u)); int degreeOfV = g.getDegree(g.getVertex(v)); - sum += (degreeOfU + degreeOfV)*dist; + sum += (int) ((degreeOfU + degreeOfV)*dist); } } } diff --git a/src/graphtea/extensions/reports/topological/WienerIndex.java b/src/graphtea/extensions/reports/topological/WienerIndex.java index 4408df17..fff1db3b 100755 --- a/src/graphtea/extensions/reports/topological/WienerIndex.java +++ b/src/graphtea/extensions/reports/topological/WienerIndex.java @@ -44,7 +44,7 @@ public Integer calculate(GraphModel g) { if(dist[v][u] < g.numOfVertices()) { double distance = dist[u][v]; if(distance > max) { - sum += distance; + sum += (int) distance; } } } diff --git a/src/graphtea/extensions/reports/topological/WienerPolarity.java b/src/graphtea/extensions/reports/topological/WienerPolarity.java index 93dbd412..fd350efc 100755 --- a/src/graphtea/extensions/reports/topological/WienerPolarity.java +++ b/src/graphtea/extensions/reports/topological/WienerPolarity.java @@ -35,7 +35,7 @@ public Integer calculate(GraphModel g) { if(spt[v][u] < g.numOfVertices() + 1) { double dist = spt[u][v]; if(dist > max) { - sum += dist; + sum += (int) dist; } } } diff --git a/src/graphtea/graph/graph/AbstractGraphRenderer.java b/src/graphtea/graph/graph/AbstractGraphRenderer.java index 40be6d5f..efcc48a2 100755 --- a/src/graphtea/graph/graph/AbstractGraphRenderer.java +++ b/src/graphtea/graph/graph/AbstractGraphRenderer.java @@ -55,7 +55,7 @@ public void addPostPaintHandler(PaintHandler ph) { } /** - * adds ph to Pre Paint Handlers which means that ph.paint will be called before each rendering of graph + * adds ph to Pre Paint Handlers, which means that ph. Paint will be called before each rendering of the graph * * @param ph The paint handler */ @@ -64,7 +64,7 @@ public void addPrePaintHandler(PaintHandler ph) { } /** - * removes ph from both pre and post paint handlers and then repaints the graph + * removes ph from both pre- and post-paint handlers and then repaints the graph * * @param ph The paint handler */ @@ -114,6 +114,7 @@ final public void paint(Graphics mainG, Boolean drawExtras) { lastWidth = w; lastHeight = h; } + assert bi != null; Graphics bufferedG = bi.getGraphics(); doRender(bufferedG, w, h, mainG, drawExtras); diff --git a/src/graphtea/graph/graph/GraphColoring.java b/src/graphtea/graph/graph/GraphColoring.java index 2c61b292..275a0578 100755 --- a/src/graphtea/graph/graph/GraphColoring.java +++ b/src/graphtea/graph/graph/GraphColoring.java @@ -31,23 +31,23 @@ public GraphColoring() { @Override public String toString() { - String txt = ""; - if (label != null && !label.equals("")) { - txt = txt + label + ": \n"; + StringBuilder txt = new StringBuilder(); + if (label != null && !label.isEmpty()) { + txt.append(label).append(": \n"); } if (vertexColors != null && !vertexColors.isEmpty()) { - txt = txt + "Vertex colors: "; + txt.append("Vertex colors: "); for (Map.Entry p : vertexColors.entrySet()) { - txt = txt + p.getKey().getLabel() + ":" + p.getValue() + " , "; + txt.append(p.getKey().getLabel()).append(":").append(p.getValue()).append(" , "); } } if (edgeColors != null && !edgeColors.isEmpty()) { - txt = txt + "\nEdge colors: "; + txt.append("\nEdge colors: "); for (Map.Entry p : edgeColors.entrySet()) { - txt = txt + p.getKey().getLabel() + ":" + p.getValue() + " , "; + txt.append(p.getKey().getLabel()).append(":").append(p.getValue()).append(" , "); } } - return txt; + return txt.toString(); } public void applyColoring() { diff --git a/src/graphtea/graph/graph/SubGraph.java b/src/graphtea/graph/graph/SubGraph.java index b8c0706c..988a940d 100755 --- a/src/graphtea/graph/graph/SubGraph.java +++ b/src/graphtea/graph/graph/SubGraph.java @@ -65,25 +65,25 @@ public void add(SubGraph sg) { @Override public String toString() { - String txt = ""; - if (label != null && !label.equals("")) { - txt += label + ": \n"; + StringBuilder txt = new StringBuilder(); + if (label != null && !label.isEmpty()) { + txt.append(label).append(": \n"); } if (vertices != null && !vertices.isEmpty()) { - txt = txt + "V: {"; + txt.append("V: {"); for (Vertex v : vertices) { - txt = txt + v.getLabel() + ", "; + txt.append(v.getLabel()).append(", "); } - txt = txt.substring(0, txt.length() - 2) + "}"; + txt = new StringBuilder(txt.substring(0, txt.length() - 2) + "}"); } if (edges != null && !edges.isEmpty()) { - txt += "\nE: {"; + txt.append("\nE: {"); for (Edge e : edges) { - txt = txt + e + ", "; + txt.append(e).append(", "); } - txt = txt.substring(0, txt.length() - 2) + "}"; + txt = new StringBuilder(txt.substring(0, txt.length() - 2) + "}"); } - return txt; + return txt.toString(); } /** diff --git a/src/graphtea/graph/ui/GHTMLPageComponent.java b/src/graphtea/graph/ui/GHTMLPageComponent.java index d82ef402..fefde3ad 100755 --- a/src/graphtea/graph/ui/GHTMLPageComponent.java +++ b/src/graphtea/graph/ui/GHTMLPageComponent.java @@ -27,7 +27,7 @@ * It is also possible to add other modes, for example when the * link address is: "command?handler=BSH" it is possible to run the command, * for this a HyperlinkHandler should be registered. - * One simple handler is also added, if the link address is "http://www.google.com/search?q=Graph&handler=external", google(your url) + * One simple handler is also added, if the link address is "...", google(your url) * will be opened in an external viewer like FireFox * another added handler is the "yoururl.com,yourtitle?handler=dialog" which opens your url in a new dialog! which * the dialog title is yourtitle diff --git a/src/graphtea/graph/ui/GTabbedGraphPane.java b/src/graphtea/graph/ui/GTabbedGraphPane.java index 487c9f70..c2e2d869 100755 --- a/src/graphtea/graph/ui/GTabbedGraphPane.java +++ b/src/graphtea/graph/ui/GTabbedGraphPane.java @@ -96,7 +96,7 @@ public void attributeUpdated(String name, Object oldVal, Object newVal) { private void updateTitle(String newVal, JComponent c) { for (int i = 0; i < jtp.getTabCount(); i++) { if (jtp.getComponentAt(i) == c) { - jtp.setTitleAt(i, newVal + ""); + jtp.setTitleAt(i, newVal); if (jtp.getTabComponentAt(i) instanceof ButtonTabComponent) { ButtonTabComponent buttonTabComponent = (ButtonTabComponent) jtp.getTabComponentAt(i); JLabel l = buttonTabComponent.label; diff --git a/src/graphtea/graph/ui/GTextFileRendererComponent.java b/src/graphtea/graph/ui/GTextFileRendererComponent.java index 3d45ed96..a5e489b8 100755 --- a/src/graphtea/graph/ui/GTextFileRendererComponent.java +++ b/src/graphtea/graph/ui/GTextFileRendererComponent.java @@ -19,12 +19,12 @@ public GTextFileRendererComponent(File f) { try { JTextArea jta = new JTextArea(); Scanner sc = new Scanner(f); - String s = ""; + StringBuilder s = new StringBuilder(); JViewport jvp = new JViewport(); while (sc.hasNextLine()) - s += sc.nextLine() + "\n"; - jta.setText(s); + s.append(sc.nextLine()).append("\n"); + jta.setText(s.toString()); jta.setBackground(new Color(200, 200, 255)); jta.setEditable(false); jta.setFont(new Font("Sans Roman", 0, 14)); diff --git a/src/graphtea/library/MatrixGraph.java b/src/graphtea/library/MatrixGraph.java index e39e7aca..c94d6b6f 100755 --- a/src/graphtea/library/MatrixGraph.java +++ b/src/graphtea/library/MatrixGraph.java @@ -29,7 +29,7 @@ /** * Adjacency Matrix Graph. - * For information about Adjacency Matrix refer to http://en.wikipedia.org/wiki/Adjacency_matrix + * For information about Adjacency Matrix refer to ... * * @author Hooman Mohajeri Moghaddam, added weighted version of weightOfEdge method * @author Omid Aladini diff --git a/src/graphtea/library/util/Ellipsoid.java b/src/graphtea/library/util/Ellipsoid.java index 6bb1ab7d..14f7991e 100755 --- a/src/graphtea/library/util/Ellipsoid.java +++ b/src/graphtea/library/util/Ellipsoid.java @@ -39,7 +39,7 @@ private void init(String n, double a, double f) throws Msg { _name = n; _a = a; _f = f; - if (null == n || n.equals("")) + if (null == n || n.isEmpty()) throw new Msg(r, "name must not be empty"); if (Math.abs(a - 6365.E3) > 5.E3) throw new Msg(r, String.format("invalid semimajor axis a= %.3f m", a)); diff --git a/src/graphtea/library/util/Msg.java b/src/graphtea/library/util/Msg.java index 2802f205..5799784c 100755 --- a/src/graphtea/library/util/Msg.java +++ b/src/graphtea/library/util/Msg.java @@ -14,9 +14,9 @@ public class Msg extends Exception { */ public Msg(String routine, String txt) { _routine = "(routine)"; - if(null != routine && !routine.equals("")) _routine = routine; + if(null != routine && !routine.isEmpty()) _routine = routine; _errortxt = "(errortext)"; - if(null != txt && !txt.equals("")) _errortxt = txt; + if(null != txt && !txt.isEmpty()) _errortxt = txt; } /** diff --git a/src/graphtea/platform/core/BlackBoard.java b/src/graphtea/platform/core/BlackBoard.java index f6122b69..d5f856a5 100755 --- a/src/graphtea/platform/core/BlackBoard.java +++ b/src/graphtea/platform/core/BlackBoard.java @@ -173,7 +173,7 @@ private int firingCount(String name) { } //todo: agar vasat e fire kardan iek thread e dige set kard oon name ro chekar baiad kard? - private class Couple { + private static class Couple { public A a; public B b; diff --git a/src/graphtea/platform/extension/BasicExtension.java b/src/graphtea/platform/extension/BasicExtension.java index b45fc4c9..3bfb0a70 100755 --- a/src/graphtea/platform/extension/BasicExtension.java +++ b/src/graphtea/platform/extension/BasicExtension.java @@ -12,7 +12,7 @@ * * If an extension only implements this interface it will be loaded with its constructor * getting the blackboard or with its default constructor. - * + *

* This extension is useful for doing initialization on application loading, or background * functionalities without any UI components. * diff --git a/src/graphtea/platform/extension/ExtensionClassLoader.java b/src/graphtea/platform/extension/ExtensionClassLoader.java index 211d397f..b2110db8 100755 --- a/src/graphtea/platform/extension/ExtensionClassLoader.java +++ b/src/graphtea/platform/extension/ExtensionClassLoader.java @@ -125,7 +125,7 @@ public static void copyInputStream(InputStream in, OutputStream out) /** - * this part of code has get from: http://www.devx.com/getHelpOn/10MinuteSolution/20447 + * this part of code has get from: ... * @param zipFileName The given zipped file name */ public static void unZip(String zipFileName, String destDir) { diff --git a/src/graphtea/platform/extension/ExtensionLoader.java b/src/graphtea/platform/extension/ExtensionLoader.java index 251b8b4e..c8c534df 100755 --- a/src/graphtea/platform/extension/ExtensionLoader.java +++ b/src/graphtea/platform/extension/ExtensionLoader.java @@ -60,9 +60,9 @@ public static void registerUnknownExtensionLoader(UnknownExtensionLoader e) { /** * gets e as an extension and tries to create Its relating AbstractAction * using registered ExtensionHandlers - * - * This should be the only place to handle extensions otherwise we are in problem, - * because here we keep list of handled extensions for further uses. everything else will + *

+ * This should be the only place to handle extensions otherwise we are in a problem, + * because here we keep a list of handled extensions for further uses. everything else will * not be in this list. */ public static AbstractAction handleExtension(BlackBoard b, Extension e) { diff --git a/src/graphtea/platform/lang/FromStringProvider.java b/src/graphtea/platform/lang/FromStringProvider.java index 5be4fa14..a55a68c7 100755 --- a/src/graphtea/platform/lang/FromStringProvider.java +++ b/src/graphtea/platform/lang/FromStringProvider.java @@ -8,7 +8,7 @@ /** * provides a "From String" for a given String, which means to create an object * from it's toString string. - * + *

* This is GraphTea's standard way of loading objects from strings. */ public interface FromStringProvider { diff --git a/src/graphtea/platform/lang/SetValidator.java b/src/graphtea/platform/lang/SetValidator.java index c3043768..542a84dc 100755 --- a/src/graphtea/platform/lang/SetValidator.java +++ b/src/graphtea/platform/lang/SetValidator.java @@ -36,14 +36,14 @@ public Object[] getValidValues() { } public String toString() { - String ret = ""; + StringBuilder ret = new StringBuilder(); if (vals.isEmpty()) return " #$%# "; Object[] valar = vals.toArray(); - ret = ret + valar[0].getClass().getName() + " #$%# " + valar[0]; + ret.append(valar[0].getClass().getName()).append(" #$%# ").append(valar[0]); for (int i = 1; i < valar.length; i++) { - ret = ret + " #$%# " + valar[i].getClass().getName() + " #$%# " + valar[i].toString(); + ret.append(" #$%# ").append(valar[i].getClass().getName()).append(" #$%# ").append(valar[i].toString()); } - return ret; + return ret.toString(); } } diff --git a/src/graphtea/platform/plugin/Plugger.java b/src/graphtea/platform/plugin/Plugger.java index cc98b6b5..c4ff1249 100755 --- a/src/graphtea/platform/plugin/Plugger.java +++ b/src/graphtea/platform/plugin/Plugger.java @@ -124,7 +124,7 @@ public void plug() { ExceptionHandler.catchException(e); } classLoader = new URLClassLoader(urls); - System.out.println("" + i + " jar file(s) loaded."); + System.out.println(i + " jar file(s) loaded."); System.out.println("------------------------------------------------------------"); dfs(first); } else diff --git a/src/graphtea/plugins/commandline/commands/GraphCommands.java b/src/graphtea/plugins/commandline/commands/GraphCommands.java index cbe94e40..40ff6a9f 100755 --- a/src/graphtea/plugins/commandline/commands/GraphCommands.java +++ b/src/graphtea/plugins/commandline/commands/GraphCommands.java @@ -61,17 +61,17 @@ public Matrix graph2Matrix() { , description = "the weighted matrix related to the graph (with MatLab matrix format)") public String weightMatrix() { GraphModel g = datas.getGraph(); - String ret = ""; + StringBuilder ret = new StringBuilder(); for (Vertex v : g) { for (Vertex w : g) { Edge e = g.getEdge(v, w); - ret += " " + (e == null ? "0" : e.getWeight()) + " ,"; + ret.append(" ").append(e == null ? "0" : e.getWeight()).append(" ,"); } - ret = ret.substring(0, ret.length() - 1); - ret += ";"; + ret = new StringBuilder(ret.substring(0, ret.length() - 1)); + ret.append(";"); } if (g.getVerticesCount() > 0) - ret = ret.substring(0, ret.length() - 1); + ret = new StringBuilder(ret.substring(0, ret.length() - 1)); return "[" + ret + "]"; } @@ -79,18 +79,18 @@ public String weightMatrix() { , description = "the weighted matrix related to the graph (with MatLab matrix format)") public String matlabMatrix() { GraphModel g = datas.getGraph(); - String ret = ""; + StringBuilder ret = new StringBuilder(); for (Vertex v : g) { for (Vertex w : g) { Edge e = g.getEdge(v, w); - ret += " " + (e == null ? "0" : "1") + " ,"; + ret.append(" ").append(e == null ? "0" : "1").append(" ,"); } - ret = ret.substring(0, ret.length() - 1); - ret += ";"; + ret = new StringBuilder(ret.substring(0, ret.length() - 1)); + ret.append(";"); } if (g.getVerticesCount() > 0) - ret = ret.substring(0, ret.length() - 1); + ret = new StringBuilder(ret.substring(0, ret.length() - 1)); return "[" + ret + "]"; } diff --git a/src/graphtea/plugins/commandline/commands/NativeCommands.java b/src/graphtea/plugins/commandline/commands/NativeCommands.java index 98c8f168..710d81cb 100755 --- a/src/graphtea/plugins/commandline/commands/NativeCommands.java +++ b/src/graphtea/plugins/commandline/commands/NativeCommands.java @@ -29,10 +29,10 @@ public NativeCommands(BlackBoard bb) { @CommandAttitude(name = "ghomomorph", abbreviation = "_ghom", description = "check homomorphism") public String ghomomorph(@Parameter(name = "first_graph")GraphModel g1, @Parameter(name = "second_graph")GraphModel g2) { - String graph1 = ""; - String graph2 = ""; - graph1 += g1.getVerticesCount() + "\n"; - graph2 += g2.getVerticesCount() + "\n"; + StringBuilder graph1 = new StringBuilder(); + StringBuilder graph2 = new StringBuilder(); + graph1.append(g1.getVerticesCount()).append("\n"); + graph2.append(g2.getVerticesCount()).append("\n"); Iterator it1 = g1.edgeIterator(); Iterator it2 = g2.edgeIterator(); @@ -48,7 +48,7 @@ public String ghomomorph(@Parameter(name = "first_graph")GraphModel g1, while (it1.hasNext()) { Edge e = it1.next(); - graph1 += map.get(e.source.getId()) + " " + map.get(e.target.getId()) + "\n"; + graph1.append(map.get(e.source.getId())).append(" ").append(map.get(e.target.getId())).append("\n"); } map = new HashMap<>(); @@ -60,19 +60,18 @@ public String ghomomorph(@Parameter(name = "first_graph")GraphModel g1, while (it2.hasNext()) { Edge e = it2.next(); - graph2 += map.get(e.source.getId()) + " " + map.get(e.target.getId()) + "\n"; + graph2.append(map.get(e.source.getId())).append(" ").append(map.get(e.target.getId())).append("\n"); } - String s = homomorph(graph1, graph2); + String s = homomorph(graph1.toString(), graph2.toString()); double time = Double.parseDouble(s.substring(0, s.indexOf("\n"))); s = s.substring(s.indexOf("\n") + 1); if (s.equals("false")) return "time : " + time + ".\nNo homomorphism exists."; - String result = ""; + StringBuilder result = new StringBuilder(); StringTokenizer stk2 = new StringTokenizer(s); while (stk2.hasMoreElements()) { String temp = (String) stk2.nextElement(); - result = result + nmap.get(Integer.parseInt(temp.substring(0, temp.indexOf("-")))) + "->" - + nmap.get(Integer.parseInt(temp.substring(temp.indexOf(">") + 1))) + "\n"; + result.append(nmap.get(Integer.parseInt(temp.substring(0, temp.indexOf("-"))))).append("->").append(nmap.get(Integer.parseInt(temp.substring(temp.indexOf(">") + 1)))).append("\n"); } return "time : " + time + ".\nFounded Homomorphism is:\n" + result; diff --git a/src/graphtea/plugins/commandline/extensionloader/BSHExtensionLoader.java b/src/graphtea/plugins/commandline/extensionloader/BSHExtensionLoader.java index f784b9af..7a90dad4 100755 --- a/src/graphtea/plugins/commandline/extensionloader/BSHExtensionLoader.java +++ b/src/graphtea/plugins/commandline/extensionloader/BSHExtensionLoader.java @@ -28,7 +28,7 @@ public BSHExtensionLoader(Shell shell) { public Extension ExtensionLoader(String extFileName) { // this.extFileName = extFileName; - String eval = ""; + StringBuilder eval = new StringBuilder(); Scanner s = null; int bracketCount = 0; boolean lineComment = false; @@ -56,14 +56,14 @@ public Extension ExtensionLoader(String extFileName) { line = line.substring(12); // removing public class StringTokenizer st = new StringTokenizer(line, " ,"); while (!st.nextToken().equals("implements")) ; - eval += "ex = new " + st.nextToken() + " ()"; + eval.append("ex = new ").append(st.nextToken()).append(" ()"); while (st.hasMoreTokens()) { - eval += " " + st.nextToken(); + eval.append(" ").append(st.nextToken()); } - eval += "\n"; + eval.append("\n"); // eval = eval.replaceFirst("{","(){"); } else - eval += line + "\n"; + eval.append(line).append("\n"); } if (line.contains("*/")) { @@ -74,28 +74,28 @@ public Extension ExtensionLoader(String extFileName) { } else if (line.startsWith("public class")) { line = line.substring(12); // removing public class StringTokenizer st = new StringTokenizer(line, " "); - eval += "ex = new " + st.nextToken() + " ()"; + eval.append("ex = new ").append(st.nextToken()).append(" ()"); while (st.hasMoreTokens()) { - eval += " " + st.nextToken(); + eval.append(" ").append(st.nextToken()); } - eval += "\n"; + eval.append("\n"); // eval = eval.replaceFirst("{","(){"); } else - eval += line + "\n"; + eval.append(line).append("\n"); } } while (s.hasNextLine()); // eval+=";"; - String other = ""; - s = new Scanner(eval); - String assignment = ""; + StringBuilder other = new StringBuilder(); + s = new Scanner(eval.toString()); + StringBuilder assignment = new StringBuilder(); boolean isAssignment = false; int i = 0; while (s.hasNextLine()) { String l = s.nextLine(); if ((l.contains("ex = new") && bracketCount == 0) || (isAssignment)) { - if (!l.equals("")) - assignment += l + "\n"; + if (!l.isEmpty()) + assignment.append(l).append("\n"); if (!isAssignment) { i = bracketCount + countBrackets(l); isAssignment = true; @@ -104,8 +104,8 @@ public Extension ExtensionLoader(String extFileName) { if (i > bracketCount) isAssignment = false; } else { - if (!l.equals("")) - other += l + "\n"; + if (!l.isEmpty()) + other.append(l).append("\n"); bracketCount += countBrackets(l); } @@ -117,7 +117,7 @@ public Extension ExtensionLoader(String extFileName) { // System.err.println("*******\n" + assignment + "\n*******"); // System.out.println("eval ******* \n " + eval); - shell.evaluate(other); + shell.evaluate(other.toString()); shell.evaluate(assignment + ";"); shell.evaluate("import graphtea.ui.extension.*;"); return (Extension) shell.evaluate("return (Extension)ex;"); diff --git a/src/graphtea/plugins/commandline/parsers/InwardCommandParser.java b/src/graphtea/plugins/commandline/parsers/InwardCommandParser.java index a449e2e9..effd657b 100755 --- a/src/graphtea/plugins/commandline/parsers/InwardCommandParser.java +++ b/src/graphtea/plugins/commandline/parsers/InwardCommandParser.java @@ -55,7 +55,7 @@ public void help() { } catch (EvalError evalError) { evalError.printStackTrace(); } - String h = ""; + StringBuilder h = new StringBuilder(); Vector hh = new Vector<>(); for (String s : commands.keySet()) { @@ -71,10 +71,10 @@ public void help() { for (String s : hh) - h += s; + h.append(s); try { - ((ShellConsole) interpreter.get("console")).println(h, Color.blue); + ((ShellConsole) interpreter.get("console")).println(h.toString(), Color.blue); } catch (EvalError evalError) { evalError.printStackTrace(); } @@ -154,27 +154,7 @@ public void addCommands(Object o) { abbrs.put(cm.abbreviation(), cm.name()); methodObjects.put(m, o); - String evaluation = cm.name() + "("; - - String temp = ""; - if (m.getParameterTypes().length != 0) - temp = "Object[] o = new Object[" + m.getParameterTypes().length + "];"; - - int i = 0; - for (Class c : m.getParameterTypes()) { - i++; - evaluation += c.getSimpleName() + " x" + i + " ,"; - temp += "o[" + (i - 1) + "] = x" + i + ";"; - } - - evaluation = (m.getParameterTypes().length == 0 ? - evaluation : evaluation.substring(0, evaluation.length() - 1)) - + ")"; - - if (m.getParameterTypes().length == 0) - evaluation += "{" + temp + "me.parseShell(\"" + cm.name() + "\"" + ",null,current_interpreter);}"; - else - evaluation += "{" + temp + "me.parseShell(\"" + cm.name() + "\"" + ",o,current_interpreter);}"; + StringBuilder evaluation = getStringBuilder(m, cm); evaluations += evaluation + "\n"; } } @@ -185,6 +165,31 @@ public void addCommands(Object o) { } } + private static StringBuilder getStringBuilder(Method m, CommandAttitude cm) { + StringBuilder evaluation = new StringBuilder(cm.name() + "("); + + StringBuilder temp = new StringBuilder(); + if (m.getParameterTypes().length != 0) + temp = new StringBuilder("Object[] o = new Object[" + m.getParameterTypes().length + "];"); + + int i = 0; + for (Class c : m.getParameterTypes()) { + i++; + evaluation.append(c.getSimpleName()).append(" x").append(i).append(" ,"); + temp.append("o[").append(i - 1).append("] = x").append(i).append(";"); + } + + evaluation = new StringBuilder((m.getParameterTypes().length == 0 ? + evaluation.toString() : evaluation.substring(0, evaluation.length() - 1)) + + ")"); + + if (m.getParameterTypes().length == 0) + evaluation.append("{").append(temp).append("me.parseShell(\"").append(cm.name()).append("\"").append(",null,current_interpreter);}"); + else + evaluation.append("{").append(temp).append("me.parseShell(\"").append(cm.name()).append("\"").append(",o,current_interpreter);}"); + return evaluation; + } + public Object parseShell(String command, Object[] ps, Interpreter in) throws ShellCommandException { Method m = commands.get(command); Object o = null; diff --git a/src/graphtea/plugins/commandline/util/codecompletionutils/CodeCompletionUtils.java b/src/graphtea/plugins/commandline/util/codecompletionutils/CodeCompletionUtils.java index dbe0b1ed..2cf3c7a8 100755 --- a/src/graphtea/plugins/commandline/util/codecompletionutils/CodeCompletionUtils.java +++ b/src/graphtea/plugins/commandline/util/codecompletionutils/CodeCompletionUtils.java @@ -82,22 +82,22 @@ public static Vector complete(String part } for (Method m : ms) { - String result = ""; - result += part; + StringBuilder result = new StringBuilder(); + result.append(part); if (m.getName().equals(part.substring(part.lastIndexOf(".") + 1, part.length() - 1))) { for (Class c : m.getParameterTypes()) - result += (c.getSimpleName() + ","); - if (!result.equals(part)) - result = result.substring(0, result.length() - 1) + ");"; - else result += ");"; - ret.add(result); + result.append(c.getSimpleName()).append(","); + if (!result.toString().equals(part)) + result = new StringBuilder(result.substring(0, result.length() - 1) + ");"); + else result.append(");"); + ret.add(result.toString()); } } } else { if (commands.containsKey(part.substring(0, part.length() - 1))) { for (String t : commands.keySet()) { - String result = ""; - result += part; + StringBuilder result = new StringBuilder(); + result.append(part); if (t.equals(part.substring(0, part.length() - 1))) { Method method = commands.get(t); Annotation[][] pA = method.getParameterAnnotations(); @@ -108,24 +108,24 @@ public static Vector complete(String part Parameter pn = (Parameter) a; String type = method.getParameterTypes()[index].getSimpleName(); - result += (pn.name() + "(" + type + "), "); + result.append(pn.name()).append("(").append(type).append("), "); } } index++; } - if (!result.equals(part)) { - result = result.substring(0, result.length() - 1); - result = result.substring(0, result.length() - 1) + ");"; - } else result += ");"; - ret.add(result); + if (!result.toString().equals(part)) { + result = new StringBuilder(result.substring(0, result.length() - 1)); + result = new StringBuilder(result.substring(0, result.length() - 1) + ");"); + } else result.append(");"); + ret.add(result.toString()); } } } else { Vector ret1 = new Vector<>(); for (String t : ext_commands.keySet()) { - String result = part; + StringBuilder result = new StringBuilder(part); if (ext_commands.get(t) == null) { if (t.startsWith(part)) @@ -137,15 +137,15 @@ public static Vector complete(String part Parameter p = f.getAnnotation(Parameter.class); if (p != null) { String type = f.getType().getSimpleName(); - result += (p.name() + "(" + type + "), "); + result.append(p.name()).append("(").append(type).append("), "); } } - if (!result.equals(part)) { - result = result.substring(0, result.length() - 1); - result = result.substring(0, result.length() - 1) + ");"; - } else result += ");"; - ret1.add(result); + if (!result.toString().equals(part)) { + result = new StringBuilder(result.substring(0, result.length() - 1)); + result = new StringBuilder(result.substring(0, result.length() - 1) + ");"); + } else result.append(");"); + ret1.add(result.toString()); } } ret.addAll(ret1); diff --git a/src/graphtea/plugins/main/Init.java b/src/graphtea/plugins/main/Init.java index 71be61df..f48c3e67 100755 --- a/src/graphtea/plugins/main/Init.java +++ b/src/graphtea/plugins/main/Init.java @@ -84,16 +84,16 @@ public void init(BlackBoard blackboard) { } public static String getLatestExceptionStackStrace(BlackBoard blackboard) { - String s = ""; + StringBuilder s = new StringBuilder(); ExceptionOccuredData exceptionData = blackboard.getData(ExceptionOccuredData.EVENT_KEY); if (exceptionData != null) { StackTraceElement[] ee = exceptionData.e.getStackTrace(); - s = exceptionData.e.toString() + "\n"; + s = new StringBuilder(exceptionData.e.toString() + "\n"); for (StackTraceElement element : ee) { - s += "\tat " + element.toString() + "\n"; + s.append("\tat ").append(element.toString()).append("\n"); } } - return s; + return s.toString(); } public static String getExternalIP(){ diff --git a/src/graphtea/plugins/main/ccp/Paste.java b/src/graphtea/plugins/main/ccp/Paste.java index 205c76aa..50cd0126 100755 --- a/src/graphtea/plugins/main/ccp/Paste.java +++ b/src/graphtea/plugins/main/ccp/Paste.java @@ -150,9 +150,7 @@ void _onDrop(GraphEvent data) { // ClearSelection.clearSelected(g.blackboard); //selects the inserted edges & vertices SubGraph sd = new SubGraph(); - for (Vertex v : toBeSelectedVertices) { - sd.vertices.add(v); - } + sd.vertices.addAll(toBeSelectedVertices); for (Edge e : toBeSelectedEdges) { sd.edges.add(e); } diff --git a/src/graphtea/plugins/main/core/actions/GraphPropertyEditor.java b/src/graphtea/plugins/main/core/actions/GraphPropertyEditor.java index eab97750..cddd1cdd 100755 --- a/src/graphtea/plugins/main/core/actions/GraphPropertyEditor.java +++ b/src/graphtea/plugins/main/core/actions/GraphPropertyEditor.java @@ -157,7 +157,7 @@ public void performAction(String eventName, Object value) { prosheet = (GPropertyEditor) UIUtils.getComponent(blackboard, "property editor"); if (getTarget() != null) - if (eventName == Select.EVENT_KEY) { + if (eventName.equals(Select.EVENT_KEY)) { if (!spm.isSelectionEmpty()) { updatePropertyEditor_selected(); // viewer = selectView; @@ -184,7 +184,7 @@ public void performAction(String eventName, Object value) { // } // } // } - if (eventName == GraphSelectData.EVENT_KEY) { + if (eventName.equals(GraphSelectData.EVENT_KEY)) { setTarget(new GraphNotifiableAttrSet(lastGraph())); viewer = graphView; } diff --git a/src/graphtea/plugins/main/core/actions/LastSelectedStatusAction.java b/src/graphtea/plugins/main/core/actions/LastSelectedStatusAction.java index 6e52c625..2d61e9a0 100755 --- a/src/graphtea/plugins/main/core/actions/LastSelectedStatusAction.java +++ b/src/graphtea/plugins/main/core/actions/LastSelectedStatusAction.java @@ -60,13 +60,13 @@ public void mouseClicked(MouseEvent e) { public void performAction(String eventName, Object value) { l = label(); handleMouseListener(); - if (eventName == VertexSelectData.EVENT_KEY) { + if (eventName.equals(VertexSelectData.EVENT_KEY)) { VertexSelectData last = blackboard.getData(VertexSelectData.EVENT_KEY); Vertex v = last.v; l.setText("Vertex :: " + (v.getLabel())); this.last = v; } - if (eventName == EdgeSelectData.EVENT_KEY) { + if (eventName.equals(EdgeSelectData.EVENT_KEY)) { Edge e = ((EdgeSelectData) blackboard.getData(EdgeSelectData.EVENT_KEY)).edge; l.setText("Edge :: " + (e.source.getLabel()) + "-->" + (e.target.getLabel())); diff --git a/src/graphtea/plugins/main/saveload/matrix/LoadMatrix.java b/src/graphtea/plugins/main/saveload/matrix/LoadMatrix.java index cc0edcef..4a1ae2d7 100755 --- a/src/graphtea/plugins/main/saveload/matrix/LoadMatrix.java +++ b/src/graphtea/plugins/main/saveload/matrix/LoadMatrix.java @@ -57,9 +57,10 @@ public static GraphModel loadMatrix(File selectedFile) throws IOException { FileReader in = new FileReader(selectedFile); BufferedReader br = new BufferedReader(in); - String s1, s = ""; - while ((s1 = br.readLine()) != null) s += s1 + "\n"; - Matrix.Matrix2Graph(Matrix.String2Matrix(s), g); + String s1; + StringBuilder s = new StringBuilder(); + while ((s1 = br.readLine()) != null) s.append(s1).append("\n"); + Matrix.Matrix2Graph(Matrix.String2Matrix(s.toString()), g); return g; } @@ -67,9 +68,10 @@ public static GraphModel loadMatrix(File selectedFile, boolean isDirected) throw GraphModel g = new GraphModel(isDirected); FileReader in = new FileReader(selectedFile); BufferedReader br = new BufferedReader(in); - String s1, s = ""; - while ((s1 = br.readLine()) != null) s += s1 + "\n"; - Matrix.Matrix2Graph(Matrix.String2Matrix(s), g); + String s1; + StringBuilder s = new StringBuilder(); + while ((s1 = br.readLine()) != null) s.append(s1).append("\n"); + Matrix.Matrix2Graph(Matrix.String2Matrix(s.toString()), g); return g; } @@ -77,18 +79,18 @@ public static Vector loadMatrixes(File selectedFile, boolean isDirec Vector gs = new Vector<>(); Scanner sc =new Scanner(selectedFile); sc.nextLine(); - String g=""; + StringBuilder g= new StringBuilder(); while (sc.hasNextLine()) { String l = sc.nextLine(); - if(!l.equals("")){ - g+=l+"\n"; + if(!l.isEmpty()){ + g.append(l).append("\n"); } else { - if(!g.equals("")) { + if(!g.toString().isEmpty()) { GraphModel tmp = new GraphModel(isDirected); - Matrix.Matrix2Graph(Matrix.String2Matrix(g), tmp); + Matrix.Matrix2Graph(Matrix.String2Matrix(g.toString()), tmp); gs.add(tmp); - g = ""; + g = new StringBuilder(); } } } diff --git a/src/graphtea/plugins/main/saveload/matrix/Matrix.java b/src/graphtea/plugins/main/saveload/matrix/Matrix.java index 9ecddf47..80c211bf 100755 --- a/src/graphtea/plugins/main/saveload/matrix/Matrix.java +++ b/src/graphtea/plugins/main/saveload/matrix/Matrix.java @@ -104,21 +104,21 @@ public static String Matrix2HTML(Object[][] mat){ if (a == 0) return ""; int b = mat[0].length; - String ret = ""; + StringBuilder ret = new StringBuilder("
"); for (Object[] objects : mat) { - ret += ""; + ret.append(""); for (int j = 0; j < b; j++) { if (objects[j] != null) - ret += ""; + ret.append(""); else - ret += ""; + ret.append(""); // ret += (mat[i][j] ? "1" : "0"); // ret += " "; } - ret += "\n"; + ret.append("\n"); } - return ret; + return ret.toString(); } public static String Matrix2String(Object[][] mat) { @@ -126,19 +126,19 @@ public static String Matrix2String(Object[][] mat) { if (a == 0) return ""; int b = mat[0].length; - String ret = ""; + StringBuilder ret = new StringBuilder(); for (Object[] objects : mat) { for (int j = 0; j < b; j++) { if (objects[j] != null) - ret += ((Number) (objects[j])).intValue() + " "; + ret.append(((Number) (objects[j])).intValue()).append(" "); else - ret += "0 "; + ret.append("0 "); // ret += (mat[i][j] ? "1" : "0"); // ret += " "; } - ret += "\n"; + ret.append("\n"); } - return ret; + return ret.toString(); } public static int[][] String2Matrix(String s) { diff --git a/src/graphtea/plugins/main/select/RectangularSelect.java b/src/graphtea/plugins/main/select/RectangularSelect.java index d21690f9..a56a7c5a 100755 --- a/src/graphtea/plugins/main/select/RectangularSelect.java +++ b/src/graphtea/plugins/main/select/RectangularSelect.java @@ -69,8 +69,7 @@ void _onMouseMoved(GraphEvent data) { SubGraph selection = RectangularSelect.calculateSelected(g, graphRectRegionSelector.getCurrentRect().getBounds()); if (!deleteOlderSelections) { SubGraph sd = Select.getSelection(blackboard); - for (Vertex v : sd.vertices) - selection.vertices.add(v); + selection.vertices.addAll(sd.vertices); for (Edge e : sd.edges) selection.edges.add(e); } diff --git a/src/graphtea/plugins/main/select/ScaleInSelection.java b/src/graphtea/plugins/main/select/ScaleInSelection.java index 9c64bc28..22f0ef71 100755 --- a/src/graphtea/plugins/main/select/ScaleInSelection.java +++ b/src/graphtea/plugins/main/select/ScaleInSelection.java @@ -23,9 +23,4 @@ public String getDescription() { protected void setNewLocation(Vertex v, GPoint loc, double x, double y) { v.setLocation(new GPoint(loc.x + x * scale, loc.y + y * scale)); } - - @Override - public String getCategory() { - return "Basic Operations"; - } } diff --git a/src/graphtea/plugins/main/select/Select.java b/src/graphtea/plugins/main/select/Select.java index 47f85aa1..22172913 100755 --- a/src/graphtea/plugins/main/select/Select.java +++ b/src/graphtea/plugins/main/select/Select.java @@ -49,7 +49,7 @@ public void performAction(String eventName, Object value) { selectVertex(); } - if (eventName == EdgeSelectData.EVENT_KEY) + if (eventName.equals(EdgeSelectData.EVENT_KEY)) selectEdge(); } diff --git a/src/graphtea/plugins/main/select/SelectUpdater.java b/src/graphtea/plugins/main/select/SelectUpdater.java index 85479026..e86089e4 100755 --- a/src/graphtea/plugins/main/select/SelectUpdater.java +++ b/src/graphtea/plugins/main/select/SelectUpdater.java @@ -13,7 +13,7 @@ import java.util.Vector; /** - * this class is do the update of the graph after the selection changes, it sets the selection of vertices and edges, and + * this class is do the update of the graph after the selection changes, it sets the selection of vertices and edges and * repaints the graph if necessary * * @author Azin Azadi @@ -47,7 +47,7 @@ public void performAction(String eventName, Object value) { deselect(v); rm.add(v); } - last.vertices.removeAll(rm); + rm.forEach(last.vertices::remove); for (Edge e : sd.edges) if (!last.edges.contains(e)) { select(e); @@ -59,10 +59,7 @@ public void performAction(String eventName, Object value) { deselect(e); rme.add(e); } - last.edges.removeAll(rme); - //last=sd; - //last.vertices=(HashSet) sd.vertices.clone(); - //last.edges=(HashSet) sd.edges.clone(); + rme.forEach(last.edges::remove); } private void deselect(Edge e) { diff --git a/src/graphtea/plugins/main/ui/GShapeRenderer.java b/src/graphtea/plugins/main/ui/GShapeRenderer.java index dcd6a9e1..1cb0ea20 100755 --- a/src/graphtea/plugins/main/ui/GShapeRenderer.java +++ b/src/graphtea/plugins/main/ui/GShapeRenderer.java @@ -29,7 +29,7 @@ public Component getRendererComponent(final GShape value) { public void paint(Graphics g) { super.paint(g); int h = getHeight(); - g.drawString(value.name + "", h + 4, (h - 2) / 2 + 8); + g.drawString(value.name, h + 4, (h - 2) / 2 + 8); g.setColor(Color.lightGray); GShape.fillShape(value.name, g, h - 1, h - 1); g.setColor(Color.darkGray); diff --git a/src/graphtea/plugins/main/ui/GraphColoringRenderer.java b/src/graphtea/plugins/main/ui/GraphColoringRenderer.java index 2622b4d9..bf78827f 100755 --- a/src/graphtea/plugins/main/ui/GraphColoringRenderer.java +++ b/src/graphtea/plugins/main/ui/GraphColoringRenderer.java @@ -29,6 +29,25 @@ public Component getRendererComponent(GraphColoring coloring) { myColoring.vertexColors = new HashMap<>(coloring.vertexColors); myColoring.edgeColors = new HashMap<>(coloring.edgeColors); myColoring.label = coloring.label; + String txt = getHTMLFromColoring(myColoring); + + JLabel l = new JLabel(txt){ + @Override + public void setForeground(Color fg) { + super.setForeground(fg); + if (fg== GCellRenderer.SELECTED_COLOR) + showOnGraph(myColoring); + } + }; + l.addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) { + showOnGraph(myColoring); + } + }); + return l; + } + + private static String getHTMLFromColoring(GraphColoring myColoring) { String txt = ""; txt = ""; if (myColoring.label != null && !myColoring.label.equals("")) { @@ -47,21 +66,7 @@ public Component getRendererComponent(GraphColoring coloring) { } } txt = txt + ""; - - JLabel l = new JLabel(txt){ - @Override - public void setForeground(Color fg) { - super.setForeground(fg); - if (fg== GCellRenderer.SELECTED_COLOR) - showOnGraph(myColoring); - } - }; - l.addMouseListener(new MouseAdapter() { - public void mouseClicked(MouseEvent e) { - showOnGraph(myColoring); - } - }); - return l; + return txt; } private void showOnGraph(GraphColoring myColoring) { diff --git a/src/graphtea/plugins/main/ui/IndSetColoringRenderer.java b/src/graphtea/plugins/main/ui/IndSetColoringRenderer.java index a2ca57e6..45c992ad 100755 --- a/src/graphtea/plugins/main/ui/IndSetColoringRenderer.java +++ b/src/graphtea/plugins/main/ui/IndSetColoringRenderer.java @@ -22,35 +22,9 @@ * @author Azin Azadi */ public class IndSetColoringRenderer implements GBasicCellRenderer { -// public IndSetColoringRenderer() { -// super(); -// backupColoring(); - // } - public Component getRendererComponent(final IndSubGraphs res) { - String txt; - GraphData gd = new GraphData(Application.getBlackBoard()); - boolean hasAllVSet = true; - for(int i=0;i"; + public Component getRendererComponent(final IndSubGraphs res) { + String txt = getHTMLFromIndSetColoring(res); //System.out.println(txt); JLabel l = new JLabel(txt) { @Override @@ -70,6 +44,34 @@ public void mouseClicked(MouseEvent e) { return l; } + private static String getHTMLFromIndSetColoring(IndSubGraphs res) { + StringBuilder txt; + GraphData gd = new GraphData(Application.getBlackBoard()); + boolean hasAllVSet = true; + + for(int i=0;i"); + txt.append("V:{"); + if(hasAllVSet) txt.append(""); + for (int tmp : res) { + if (tmp == -1) txt.append("},{"); + else txt.append(tmp).append(","); + } + if(hasAllVSet) txt.append(""); + + txt.append("}
"); + + + txt.append(""); + return txt.toString(); + } + private void showOnGraph(IndSubGraphs res) { // resetColoring(); GraphData gd = new GraphData(Application.getBlackBoard()); @@ -99,8 +101,7 @@ public void backupColoring() { } public void resetColoring() { - GraphData gd = new GraphData(Application.getBlackBoard()); - for(Vertex v:vertexColors.keySet()) { + for(Vertex v: vertexColors.keySet()) { v.setColor(vertexColors.get(v)); } diff --git a/src/graphtea/plugins/main/ui/SubGraphRenderer.java b/src/graphtea/plugins/main/ui/SubGraphRenderer.java index 248f0679..329fe2df 100755 --- a/src/graphtea/plugins/main/ui/SubGraphRenderer.java +++ b/src/graphtea/plugins/main/ui/SubGraphRenderer.java @@ -30,27 +30,7 @@ public Component getRendererComponent(SubGraph sd) { mysd.vertices = new HashSet<>(sd.vertices); mysd.edges = new HashSet<>(sd.edges); mysd.label = sd.label; - String txt; - txt = ""; - if (mysd.label != null && !mysd.label.equals("")) { - txt += "" + mysd.label + ":
"; - } - - if (mysd.vertices != null && !mysd.vertices.isEmpty()) { - txt = txt + "V: {"; - for (Vertex v : mysd.vertices) { - txt = txt + v.getLabel() + ", "; - } - txt = txt.substring(0, txt.length() - 2) + "}"; - } - if (mysd.edges != null && !mysd.edges.isEmpty()) { - txt += "
E: {"; - for (Edge e : mysd.edges) { - txt = txt + e.source.getLabel() + "-"+ e.target.getLabel() + ", "; - } - txt = txt.substring(0, txt.length() - 2) + "}"; - } - txt = txt + ""; + String txt = getHTMLForSubGraph(mysd); JLabel l = new JLabel(txt) { @Override public void setForeground(Color fg) { @@ -69,6 +49,31 @@ public void mouseClicked(MouseEvent e) { return l; } + private static String getHTMLForSubGraph(SubGraph mysd) { + StringBuilder txt; + txt = new StringBuilder(""); + if (mysd.label != null && !mysd.label.isEmpty()) { + txt.append("").append(mysd.label).append(":
"); + } + + if (mysd.vertices != null && !mysd.vertices.isEmpty()) { + txt.append("V: {"); + for (Vertex v : mysd.vertices) { + txt.append(v.getLabel()).append(", "); + } + txt = new StringBuilder(txt.substring(0, txt.length() - 2) + "}"); + } + if (mysd.edges != null && !mysd.edges.isEmpty()) { + txt.append("
E: {"); + for (Edge e : mysd.edges) { + txt.append(e.source.getLabel()).append("-").append(e.target.getLabel()).append(", "); + } + txt = new StringBuilder(txt.substring(0, txt.length() - 2) + "}"); + } + txt.append(""); + return txt.toString(); + } + private void showOnGraph(SubGraph mysd) { GraphData gd = new GraphData(Application.getBlackBoard()); if (gd.getGraph() == null && mysd.graph == null) diff --git a/src/graphtea/plugins/visualization/localsfvis/animatorLSF.java b/src/graphtea/plugins/visualization/localsfvis/animatorLSF.java index bab93bbb..e078f870 100755 --- a/src/graphtea/plugins/visualization/localsfvis/animatorLSF.java +++ b/src/graphtea/plugins/visualization/localsfvis/animatorLSF.java @@ -32,7 +32,7 @@ public animatorLSF(BlackBoard blackboard, GraphModel g, AbstractGraphRenderer gv private GRect[] vRects; //represents the rectangle around each vertex private GPoint[] verPos; //fresh generated vertex positions! private GPoint[] velocity; - private GPoint[] prevVerPos; //refers to previous state of vertex positions, for finding vertices that moved by anything else + private GPoint[] prevVerPos; //refers to the previous state of vertex positions, for finding vertices that moved by anything else // private final double neighborRadius = 300; private double stres = 10; private double springK = 0.7; @@ -298,7 +298,9 @@ private void getVertices() { } int i = 0; for (Vertex vm : g) { + assert v != null; v[i] = vm; + assert verPos != null; verPos[i] = vm.getLocation(); velocity[i] = new GPoint(); vRects[i] = new GRect(vm.getBounds().getBounds().x,vm.getBounds().getBounds().y, @@ -369,8 +371,8 @@ private void refreshPositioning() { } int e = 5; - verPos[i].x += fx / e; - verPos[i].y += fy / e; + verPos[i].x += (double) fx / e; + verPos[i].y += (double) fy / e; // velocity[i].x += fx; // velocity[i].y += fy; // verPos[i].x += (fx + velocity[i].x)/E; diff --git a/src/graphtea/plugins/visualization/treevisualizations/HierarchicalTreeVisualization.java b/src/graphtea/plugins/visualization/treevisualizations/HierarchicalTreeVisualization.java index 56fad116..1c19511f 100755 --- a/src/graphtea/plugins/visualization/treevisualizations/HierarchicalTreeVisualization.java +++ b/src/graphtea/plugins/visualization/treevisualizations/HierarchicalTreeVisualization.java @@ -111,7 +111,6 @@ public Vector findNextLevelChildren(Vector currentLevelVertices) } } } - } else { } return newChildren; } diff --git a/src/graphtea/plugins/visualization/treevisualizations/SparseTreeVisualization.java b/src/graphtea/plugins/visualization/treevisualizations/SparseTreeVisualization.java index c449e7d3..9fe4cd22 100755 --- a/src/graphtea/plugins/visualization/treevisualizations/SparseTreeVisualization.java +++ b/src/graphtea/plugins/visualization/treevisualizations/SparseTreeVisualization.java @@ -116,9 +116,6 @@ public void locateAll(Vector currentLevelVertices, int width, int LevelH int nextLevelCount = nextLevel.size(); int horizontalDist = width / (currentLevelCount + nextLevelCount); - for (Vertex x : currentLevelVertices) { - - } for (Vertex v : currentLevelVertices) { if (nextLevelCount != 0) { GPoint newPoint = new GPoint(horizontalDist * (i + 1) + width / (nextLevelCount + currentLevelCount), LevelHeight); diff --git a/src/graphtea/samples/ui/texteditor/myplugin/UISample.java b/src/graphtea/samples/ui/texteditor/myplugin/UISample.java index 50d4dde4..ad9df0b0 100755 --- a/src/graphtea/samples/ui/texteditor/myplugin/UISample.java +++ b/src/graphtea/samples/ui/texteditor/myplugin/UISample.java @@ -18,7 +18,7 @@ /** * The main class of GraphTea notepad sample. *

- * see http://graphtea.sharif.ir/trac/wiki/XMLBasedUI todo: [tea] link to be updated + * see ... todo: [tea] link to be updated * @author Azin Azadi aazadi@gmail.com */ public class UISample { diff --git a/src/graphtea/samples/ui/texteditor/myplugin/actions/SaveAction.java b/src/graphtea/samples/ui/texteditor/myplugin/actions/SaveAction.java index 9fe1fe8e..8785c5a6 100755 --- a/src/graphtea/samples/ui/texteditor/myplugin/actions/SaveAction.java +++ b/src/graphtea/samples/ui/texteditor/myplugin/actions/SaveAction.java @@ -18,7 +18,7 @@ public class SaveAction implements UIActionExtension { public void actionPerformed(BlackBoard blackBoard) { String path = blackBoard.getData("last file"); - if (path == null || path.equals("")) { + if (path == null || path.isEmpty()) { JFileChooser jfc = new JFileChooser(); jfc.setFileSelectionMode(JFileChooser.FILES_ONLY); jfc.setMultiSelectionEnabled(false); diff --git a/src/graphtea/ui/AttributeSetView.java b/src/graphtea/ui/AttributeSetView.java index 21c4405e..52e49102 100755 --- a/src/graphtea/ui/AttributeSetView.java +++ b/src/graphtea/ui/AttributeSetView.java @@ -68,7 +68,7 @@ public void setDisplayName(String name, String displayName) { public String getDisplayName(String name) { String s = get(dname, name); - if (s.equals("")) + if (s.isEmpty()) return name; return s; } diff --git a/src/graphtea/ui/ParameterShower.java b/src/graphtea/ui/ParameterShower.java index d6890c9f..a981e90e 100755 --- a/src/graphtea/ui/ParameterShower.java +++ b/src/graphtea/ui/ParameterShower.java @@ -134,7 +134,7 @@ private void addField(PortableNotifiableAttributeSetImpl p, Field f, Object o, S } } else { p.put(f.getName(), f.get(o)); - if (!name.equals("")) + if (!name.isEmpty()) p.getView().setDisplayName(f.getName(), name); p.getView().setDescription(f.getName(), desc); } diff --git a/src/graphtea/ui/components/GButton.java b/src/graphtea/ui/components/GButton.java index c998ebf9..b62ae2db 100755 --- a/src/graphtea/ui/components/GButton.java +++ b/src/graphtea/ui/components/GButton.java @@ -59,7 +59,7 @@ public GButton(String label, String iconFileName, BlackBoard b, String action) { private ImageIcon loadIcon(String iconFileName) { ImageIcon icon = null; - if (iconFileName != null && !iconFileName.equals("")) { + if (iconFileName != null && !iconFileName.isEmpty()) { icon = new ImageIcon(iconFileName); if (icon.getIconWidth() < 1) { //solving the problem between GraphTea and GraphTeaDebugger diff --git a/src/graphtea/ui/components/gpropertyeditor/GPropertyEditor.java b/src/graphtea/ui/components/gpropertyeditor/GPropertyEditor.java index 36d2b751..4c030d38 100755 --- a/src/graphtea/ui/components/gpropertyeditor/GPropertyEditor.java +++ b/src/graphtea/ui/components/gpropertyeditor/GPropertyEditor.java @@ -31,8 +31,8 @@ import java.io.File; /** - * see http://graphtea.sharif.ir/trac/wiki/PropertyEditor for documentations. todo: [tea] link to be updated - * @author Azin Azadi + * see ... for documentations. todo: [tea] link to be updated + * @author Azin Azadi * @email : aazadi@gmail.com */ @@ -166,7 +166,7 @@ private void updateDescription() { if (scc != -1) { String name = target.getView().getNameAt(scc); String desc = target.getView().getDescription(name); - if (desc == null || desc.equals("")) { + if (desc == null || desc.isEmpty()) { desc = name; } desc += ": " + target.getView().getAttribute().get(name); diff --git a/src/graphtea/ui/extension/AbstractExtensionAction.java b/src/graphtea/ui/extension/AbstractExtensionAction.java index a68fa066..58b86ad6 100755 --- a/src/graphtea/ui/extension/AbstractExtensionAction.java +++ b/src/graphtea/ui/extension/AbstractExtensionAction.java @@ -36,9 +36,9 @@ import java.util.Vector; /** - * the base class for creating extension handlers + * the base class for creating extension handlers, * the implementing class will have a menu assigned to it automatically the name of the menu will be - * from the constructors parameter(sp) and the will also listen to UI.getUIEvent(sp.getName()) + * from the constructors parameter(sp), and they will also listen to UI.getUIEvent(sp.getName()) * * @author azin azadi */ @@ -73,7 +73,7 @@ public AbstractExtensionAction(BlackBoard bb, t sp) { String name = getMenuNamePrefix() + sp.getName(); actionId = name + sp.getDescription() + target.getClass().getName(); listen4Event(UIUtils.getUIEventKey(actionId)); - if (!name.equals("")) { + if (!name.isEmpty()) { menuItem = createMenuItem(name, actionId, bb); parentMenu = getParentMenu(); if (parentMenu.getText().equalsIgnoreCase("reports")) { @@ -180,7 +180,7 @@ protected final GMenuItem createMenuItem(String name, String actionId, BlackBoar public Dimension getPreferredSize() { Dimension preferredSize = super.getPreferredSize(); Dimension bps = extraButton.getPreferredSize(); - preferredSize.width += bps.getWidth() + 4; + preferredSize.width += (int) (bps.getWidth() + 4); preferredSize.height = (int) Math.max(preferredSize.height, bps.getHeight()) + 1; return preferredSize; } @@ -241,7 +241,7 @@ protected void createExtensionCommandsForCommandLine() { final t trgClass = target; final CommandAttitude comati = trgClass.getClass().getAnnotation(CommandAttitude.class); - String command = ""; + StringBuilder command = new StringBuilder(); String cname; String abrv; String desc; @@ -250,34 +250,27 @@ protected void createExtensionCommandsForCommandLine() { cname = comati.name(); abrv = comati.abbreviation(); desc = comati.description(); - if (desc == null || desc.equals("")) + if (desc == null || desc.isEmpty()) desc = target.getDescription(); } else { cname = target.getClass().getSimpleName(); abrv = ""; desc = target.getDescription(); } - command += cname + "("; - String help = ""; + command.append(cname).append("("); + StringBuilder help = new StringBuilder(); for (Field f : target.getClass().getFields()) { if (f.getAnnotation(Parameter.class) != null) { - command += f.getType().getName() - + " " - + f.getName() + ","; - help += "_" + target.getClass().getSimpleName() - + "." - + f.getName() - + " = " - + f.getName() - + ";\n"; + command.append(f.getType().getName()).append(" ").append(f.getName()).append(","); + help.append("_").append(target.getClass().getSimpleName()).append(".").append(f.getName()).append(" = ").append(f.getName()).append(";\n"); } } - if (command.endsWith(",")) - command = command.substring(0, command.length() - 1); - command += ")\n{"; + if (command.toString().endsWith(",")) + command = new StringBuilder(command.substring(0, command.length() - 1)); + command.append(")\n{"); // System.out.println(command); - ExtensionShellCommandProvider.addCommand(ths, trgClass, cname, abrv, command, desc, help); + ExtensionShellCommandProvider.addCommand(ths, trgClass, cname, abrv, command.toString(), desc, help.toString()); } diff --git a/src/graphtea/ui/xml/UIHandlerImpl.java b/src/graphtea/ui/xml/UIHandlerImpl.java index 04f3e810..2fe5ee5c 100755 --- a/src/graphtea/ui/xml/UIHandlerImpl.java +++ b/src/graphtea/ui/xml/UIHandlerImpl.java @@ -85,7 +85,7 @@ public void handle_tool(final Attributes meta) { if (resourceClass != null && icon != null) System.out.println("[handle_tool]" + icon + " : " + resourceClass.getResource(icon)); - if (icon == null || icon.equals("") || resourceClass == null || + if (icon == null || icon.isEmpty() || resourceClass == null || resourceClass.getResource(icon) == null) b = new GButton(label, icon, blackboard, action); else @@ -310,7 +310,7 @@ public void handle_action(Attributes meta) { } private void addAction(String id, graphtea.platform.core.AbstractAction x, String group) { - if ((id != null) && !id.equals("")) + if ((id != null) && !id.isEmpty()) actions.put(id, x); // if (group != null && !group.equals("")) { // //configuration age group vojood nadashte bashe khodesh ijadesh mikone. inja be ghole omid "error prone hast" @@ -323,7 +323,7 @@ private void addAction(String id, graphtea.platform.core.AbstractAction x, Strin public GSidebar sidebar; public void handle_sidebar(Attributes meta) { - String image = meta.getValue("image") + "";//to getting it not null + String image = meta.getValue("image");//to getting it not null String clazz = meta.getValue("class"); String id = meta.getValue("id"); String label = meta.getValue("label"); @@ -348,7 +348,7 @@ public void handle_body(Attributes meta) { //************** utilities +++++++++++++++++++++ AbstractAction loadAbstractAction(String abstractActionclazz) { - if (!(abstractActionclazz == null) && !(abstractActionclazz.equals(""))) { + if (!(abstractActionclazz == null) && !(abstractActionclazz.isEmpty())) { Class t = clazz2Class(abstractActionclazz); if (graphtea.platform.core.AbstractAction.class.isAssignableFrom(t)) { Object[] o = {blackboard}; @@ -369,7 +369,7 @@ AbstractAction loadAbstractAction(String abstractActionclazz) { //todo: it is possible to also get a component from xml by it's direct class name, like javax.swing.JLabel . but i decided not to do it for cleaner codes! i am not sure is it good or not? Component getComponent(String GComponentInterfaceClassName) { - if (!(GComponentInterfaceClassName == null) && !(GComponentInterfaceClassName.equals(""))) { + if (!(GComponentInterfaceClassName == null) && !(GComponentInterfaceClassName.isEmpty())) { Class t = clazz2Class(GComponentInterfaceClassName); Constructor c = null; Object[] o = {blackboard}; From 0656474f690f02c2924d81a23a916041f37a2752 Mon Sep 17 00:00:00 2001 From: Ali Rostami Date: Tue, 20 May 2025 22:12:09 +0200 Subject: [PATCH 5/7] refactoring --- src/graphtea/extensions/G6Format.java | 4 +- .../algorithms/EndomorphismAnimator.java | 1 - .../extensions/generators/FlowerGraph.java | 2 +- .../extensions/generators/HelmGraph.java | 2 +- .../extensions/generators/NNGenerator.java | 4 +- .../extensions/generators/StarGenerator.java | 2 +- .../extensions/generators/TreeGenerator.java | 2 +- src/graphtea/extensions/io/LatexWriter.java | 2 +- .../extensions/io/LoadSpecialGML.java | 10 +-- .../io/g6format/SaveGraph6Format.java | 2 +- .../extensions/reports/ColoringReport.java | 2 +- .../boundcheck/ConjectureChecking.java | 6 +- .../reports/energy/AllEnergies1.java | 55 ++++++------ .../reports/energy/ResolventEnergy.java | 1 - .../reports/topological/AGIndex.java | 87 +++++++++---------- .../reports/topological/ComparingE1E2.java | 2 +- .../reports/topological/EM2UpperBound.java | 2 +- .../extensions/reports/topological/Mere1.java | 2 +- .../extensions/reports/topological/PI.java | 2 +- .../reports/topological/Pheriperal.java | 2 +- .../reports/topological/Pheriperal1.java | 2 +- .../reports/topological/Pheriperal2.java | 2 +- .../topological/ZagrebIndexFunctions.java | 4 +- src/graphtea/graph/graph/FastRenderer.java | 8 +- src/graphtea/graph/old/ArrowHandler.java | 4 +- src/graphtea/graph/old/GShape.java | 32 +++---- .../graph/ui/GraphRectRegionSelect.java | 4 - .../library/event/VertexEdgeLabelEvent.java | 2 +- src/graphtea/library/util/Complex.java | 34 ++++---- .../platform/attribute/AtomAttribute.java | 2 +- .../plugins/commandline/ShellConsole.java | 4 - .../commandline/commands/VertexCommands.java | 1 - .../commandline/parsers/DefaultParser.java | 1 - .../parsers/InwardCommandParser.java | 49 +++++------ .../CodeCompletionUtils.java | 7 +- src/graphtea/plugins/main/ccp/Paste.java | 4 +- .../main/core/actions/BlackBoardWatcher.java | 2 +- .../extension/GraphWriterExtensionAction.java | 2 +- .../main/saveload/image/SaveImage.java | 2 +- .../saveload/xmlparser/GraphmlHandler.java | 36 ++++---- .../xmlparser/GraphmlHandlerImpl.java | 36 ++++---- .../saveload/xmlparser/GraphmlParser.java | 22 ++--- .../main/select/RectangularSelect.java | 1 - .../main/ui/GraphColoringRenderer.java | 20 ++--- .../CircularDispatchVisualization.java | 17 ++-- .../basics/VertexCycleLengthComparator.java | 8 +- .../hierarchical/BendedTrees.java | 6 +- .../treevisualizations/BackwardTrees.java | 2 +- .../CircularTreeVisualization.java | 2 +- .../HierarchicalTreeVisualization.java | 2 +- .../SparseTreeVisualization.java | 4 +- .../editors/GHashMapEditor.java | 39 --------- .../editors/inplace/GDimensionEditor.java | 13 ++- src/graphtea/ui/xml/UIHandler.java | 28 +++--- src/graphtea/ui/xml/UIParser.java | 28 +++--- 55 files changed, 256 insertions(+), 366 deletions(-) delete mode 100755 src/graphtea/ui/components/gpropertyeditor/editors/GHashMapEditor.java diff --git a/src/graphtea/extensions/G6Format.java b/src/graphtea/extensions/G6Format.java index e797deb5..4ba7dae8 100755 --- a/src/graphtea/extensions/G6Format.java +++ b/src/graphtea/extensions/G6Format.java @@ -189,9 +189,7 @@ private static int[] encodeR(String a) { private static String padR(String str) { int padwith = 6 - (str.length() % 6); - for (int i = 0; i < padwith; i++) { - str += "0"; - } + str = str + "0".repeat(padwith); return str; } diff --git a/src/graphtea/extensions/algorithms/EndomorphismAnimator.java b/src/graphtea/extensions/algorithms/EndomorphismAnimator.java index 532351c5..faa795a5 100755 --- a/src/graphtea/extensions/algorithms/EndomorphismAnimator.java +++ b/src/graphtea/extensions/algorithms/EndomorphismAnimator.java @@ -42,7 +42,6 @@ public void doAlgorithm() { boolean[] isThere = new boolean[mapSize]; int numOfThere = 0; - for(int i=0;i < mapSize;i++) isThere[i]=false; for(int j=0;j < 100;j++) { if(numOfThere == mapSize) break; step(j+"th step"); diff --git a/src/graphtea/extensions/generators/FlowerGraph.java b/src/graphtea/extensions/generators/FlowerGraph.java index 2f695df9..afbc07aa 100755 --- a/src/graphtea/extensions/generators/FlowerGraph.java +++ b/src/graphtea/extensions/generators/FlowerGraph.java @@ -68,7 +68,7 @@ public GPoint[] getVertexPositions() int w = 1000; double mw = ((double)w)/2.0, qw = ((double)w)/4.0; GPoint[] result = new GPoint[2*n+1]; - result[2*n] = new GPoint(w/2, w/2); + result[2*n] = new GPoint((double) w /2, (double) w /2); double ang = Math.PI*2.0/n; double offset = 0.0; if ((n % 2) == 0) diff --git a/src/graphtea/extensions/generators/HelmGraph.java b/src/graphtea/extensions/generators/HelmGraph.java index 5cf6a3ae..847a6c0d 100755 --- a/src/graphtea/extensions/generators/HelmGraph.java +++ b/src/graphtea/extensions/generators/HelmGraph.java @@ -72,7 +72,7 @@ public GPoint[] getVertexPositions() { int w = 1000; double mw = ((double) w) / 2.0, qw = ((double) w) / 4.0; GPoint[] result = new GPoint[2 * n + 1]; - result[2 * n] = new GPoint(w / 2, w / 2); + result[2 * n] = new GPoint((double) w / 2, (double) w / 2); double ang = Math.PI * 2.0 / n; double offset = 0.0; if ((n % 2) == 0) diff --git a/src/graphtea/extensions/generators/NNGenerator.java b/src/graphtea/extensions/generators/NNGenerator.java index 7b4ff684..2affdfeb 100755 --- a/src/graphtea/extensions/generators/NNGenerator.java +++ b/src/graphtea/extensions/generators/NNGenerator.java @@ -75,12 +75,12 @@ public GPoint[] getVertexPositions() { int w = 100; int h = 100; GPoint[] ret = new GPoint[hiddenSize * hidden + 2]; - ret[0] = new GPoint(5,h/2); + ret[0] = new GPoint(5, (double) h /2); GPoint[] np = PositionGenerators.line(15, h / 4, 0, h, hiddenSize); GPoint[] mp = PositionGenerators.line(25, h / 4, 0, h, hiddenSize); System.arraycopy(np, 0, ret, 1, hiddenSize); System.arraycopy(mp, 0, ret, hiddenSize + 1, hiddenSize); - ret[ret.length - 1] = new GPoint(35,h/2); + ret[ret.length - 1] = new GPoint(35, (double) h /2); return ret; } diff --git a/src/graphtea/extensions/generators/StarGenerator.java b/src/graphtea/extensions/generators/StarGenerator.java index 7850636a..4bc776d4 100755 --- a/src/graphtea/extensions/generators/StarGenerator.java +++ b/src/graphtea/extensions/generators/StarGenerator.java @@ -42,7 +42,7 @@ public GPoint[] getVertexPositions() { GPoint[] ret = new GPoint[n]; GPoint[] points = PositionGenerators.circle(5, 5, 10000, 10000, n - 1); System.arraycopy(points, 0, ret, 1, n - 1); - ret[0] = new GPoint(10000 / 2, 10000 / 2); + ret[0] = new GPoint((double) 10000 / 2, (double) 10000 / 2); return ret; } diff --git a/src/graphtea/extensions/generators/TreeGenerator.java b/src/graphtea/extensions/generators/TreeGenerator.java index 0b6f1e64..33266709 100755 --- a/src/graphtea/extensions/generators/TreeGenerator.java +++ b/src/graphtea/extensions/generators/TreeGenerator.java @@ -79,7 +79,7 @@ public Edge[] getEdges() { public GPoint[] getVertexPositionsBackward() { GPoint[] ret = new GPoint[n]; - ret[0] = new GPoint(20000 / 2, 20000 / 2); + ret[0] = new GPoint((double) 20000 / 2, (double) 20000 / 2); int last = 1; int ww = 20000; int hh = 20000; diff --git a/src/graphtea/extensions/io/LatexWriter.java b/src/graphtea/extensions/io/LatexWriter.java index bd43f6f9..2fa4f762 100755 --- a/src/graphtea/extensions/io/LatexWriter.java +++ b/src/graphtea/extensions/io/LatexWriter.java @@ -29,7 +29,7 @@ public String getExtension() { } - public void write(File file, GraphModel graph) throws GraphIOException { + public void write(File file, GraphModel graph) { FileWriter output; try { output = new FileWriter(file); diff --git a/src/graphtea/extensions/io/LoadSpecialGML.java b/src/graphtea/extensions/io/LoadSpecialGML.java index 3824163d..b563a984 100755 --- a/src/graphtea/extensions/io/LoadSpecialGML.java +++ b/src/graphtea/extensions/io/LoadSpecialGML.java @@ -86,12 +86,8 @@ public String getDescription() { return "GraphTea File Format"; } - public static void main(String[] args) { - try { - new LoadSpecialGML() - .read(new File("/home/rostam/kara/GD2018/got-graph.graphml")); - } catch (GraphIOException e) { - e.printStackTrace(); - } + public static void main(String[] args) throws GraphIOException { + new LoadSpecialGML() + .read(new File("/home/rostam/kara/GD2018/got-graph.graphml")); } } diff --git a/src/graphtea/extensions/io/g6format/SaveGraph6Format.java b/src/graphtea/extensions/io/g6format/SaveGraph6Format.java index d123aa2b..af94fa54 100755 --- a/src/graphtea/extensions/io/g6format/SaveGraph6Format.java +++ b/src/graphtea/extensions/io/g6format/SaveGraph6Format.java @@ -31,7 +31,7 @@ public String getExtension() { } @Override - public void write(File file, GraphModel graph) throws GraphIOException { + public void write(File file, GraphModel graph) { try { FileWriter fw = new FileWriter(file,isAppend); G6Format g6f = new G6Format(); diff --git a/src/graphtea/extensions/reports/ColoringReport.java b/src/graphtea/extensions/reports/ColoringReport.java index c7c9d067..67318eea 100755 --- a/src/graphtea/extensions/reports/ColoringReport.java +++ b/src/graphtea/extensions/reports/ColoringReport.java @@ -47,7 +47,7 @@ public boolean coloringFound(final int t) { found = true; GraphColoring coloring = new GraphColoring(); for (int i = 0; i < p.vertices.length; i++) { - coloring.vertexColors.put((Vertex) p.vertices[i], p.color[i]); + coloring.vertexColors.put(p.vertices[i], p.color[i]); } colorings.add(coloring); return !allColorings; diff --git a/src/graphtea/extensions/reports/boundcheck/ConjectureChecking.java b/src/graphtea/extensions/reports/boundcheck/ConjectureChecking.java index 78def747..e89c97ae 100755 --- a/src/graphtea/extensions/reports/boundcheck/ConjectureChecking.java +++ b/src/graphtea/extensions/reports/boundcheck/ConjectureChecking.java @@ -95,11 +95,7 @@ public Object calculate(GraphModel g) { SaveGraph6Format sgf = new SaveGraph6Format(); File f = new File(nameOfFile); for(GraphModel gg : gs) { - try { - sgf.write(f, gg); - } catch (GraphIOException e) { - e.printStackTrace(); - } + sgf.write(f, gg); } return "The bound check is disabled. " + "The graphs are generated and saved in the file " + nameOfFile; diff --git a/src/graphtea/extensions/reports/energy/AllEnergies1.java b/src/graphtea/extensions/reports/energy/AllEnergies1.java index ecc24eaa..e8fc24fa 100755 --- a/src/graphtea/extensions/reports/energy/AllEnergies1.java +++ b/src/graphtea/extensions/reports/energy/AllEnergies1.java @@ -40,7 +40,29 @@ public String getDescription() { public RenderTable calculate(GraphModel g) { ZagrebIndexFunctions zif = new ZagrebIndexFunctions(g); - RenderTable ret = getVectors(); + RenderTable ret = new RenderTable(); + Vector titles = new Vector<>(); + + titles.add("m "); + titles.add("n "); + titles.add("E "); + titles.add("SLE -LE"); + // titles.add("check "); + // titles.add("LE "); + // titles.add("SLE "); + // titles.add("LE-Bar "); + // titles.add("SLE-Bar "); + // titles.add("DE"); + // titles.add("DLE"); +// titles.add("DLSE"); + + titles.add("Bipartite"); + // titles.add(" Components "); + // titles.add(" Resolvent-Energy "); + // titles.add(" Diameter "); + // titles.add(" Matching "); + // titles.add("R.H.S"); + ret.setTitles(titles); double maxDeg = 0; double maxDeg2 = 0; @@ -71,7 +93,7 @@ public RenderTable calculate(GraphModel g) { double M21 = zif.getFirstZagreb(1); double M22 = zif.getSecondZagreb(2); double Mm11 = zif.getFirstZagreb(-2); - int comp = (int) new NumOfConnectedComponents().calculate(g); + int comp = new NumOfConnectedComponents().calculate(g); Matrix de = AlgorithmUtils.getDistanceAdjacencyMatrix(g); Matrix dle = AlgorithmUtils.getDistanceLaplacianMatrix(g); @@ -84,7 +106,7 @@ public RenderTable calculate(GraphModel g) { LaplacianEnergy le = new LaplacianEnergy(); SignlessLaplacianEnergy sle = new SignlessLaplacianEnergy(); - int diameter = (int) new Diameter().calculate(g); + int diameter = new Diameter().calculate(g); double LE = Double.parseDouble(le.calculate(g)); double SLE = Double.parseDouble(sle.calculate(g)); @@ -160,33 +182,6 @@ public RenderTable calculate(GraphModel g) { return ret; } - private static RenderTable getVectors() { - RenderTable ret = new RenderTable(); - Vector titles = new Vector<>(); - - titles.add("m "); - titles.add("n "); - titles.add("E "); - titles.add("SLE -LE"); - // titles.add("check "); - // titles.add("LE "); - // titles.add("SLE "); - // titles.add("LE-Bar "); - // titles.add("SLE-Bar "); - // titles.add("DE"); - // titles.add("DLE"); -// titles.add("DLSE"); - - titles.add("Bipartite"); - // titles.add(" Components "); - // titles.add(" Resolvent-Energy "); - // titles.add(" Diameter "); - // titles.add(" Matching "); - // titles.add("R.H.S"); - ret.setTitles(titles); - return ret; - } - @Override public String getCategory() { return "Verification- Energy"; diff --git a/src/graphtea/extensions/reports/energy/ResolventEnergy.java b/src/graphtea/extensions/reports/energy/ResolventEnergy.java index 8c298f07..5db8dcb5 100755 --- a/src/graphtea/extensions/reports/energy/ResolventEnergy.java +++ b/src/graphtea/extensions/reports/energy/ResolventEnergy.java @@ -77,7 +77,6 @@ public String getName() { * Pages 2664-2671, * ISSN 0012-365X, * .... - * @return */ public String getDescription() { return "Resolvent Energy"; diff --git a/src/graphtea/extensions/reports/topological/AGIndex.java b/src/graphtea/extensions/reports/topological/AGIndex.java index 88a63b13..f6706607 100755 --- a/src/graphtea/extensions/reports/topological/AGIndex.java +++ b/src/graphtea/extensions/reports/topological/AGIndex.java @@ -36,7 +36,47 @@ public String getDescription() { public RenderTable calculate(GraphModel g) { ZagrebIndexFunctions zif = new ZagrebIndexFunctions(g); ZagrebIndexFunctions zifL = new ZagrebIndexFunctions(AlgorithmUtils.createLineGraph(g)); - RenderTable ret = getVectors(); + RenderTable ret = new RenderTable(); + Vector titles = new Vector<>(); + titles.add(" m "); + // titles.add(" Max Planar "); + titles.add(" n "); + // titles.add(" Min "); + // titles.add(" Lanzhou "); + titles.add(" R "); + titles.add(" GA "); + titles.add(" AG "); + titles.add(" SDD "); + // titles.add(" R-min "); + // titles.add(" HM2 "); + // titles.add(" EM2 "); + // titles.add(" Hyper "); + // titles.add(" M2-M1 "); + // titles.add(" milo "); + // titles.add(" Inverse Sum Indeg "); + // titles.add(" SDD "); + // titles.add(" R.H.S "); + // titles.add(" max "); + // titles.add(" min "); + // titles.add(" Hyper "); + // titles.add("Th 7 "); + // titles.add("check"); + // titles.add("Correct"); + // titles.add(" matching "); + // titles.add(" GA/x "); + // titles.add(" Wp "); + // titles.add(" chrome "); + // titles.add(" chrome "); + // titles.add(" Lz "); + // titles.add(" Lz-Bar "); + + // titles.add(" R.H.S "); + // titles.add("Diameter"); + // titles.add("Clique Number"); + + titles.add(" V. Degrees "); + + ret.setTitles(titles); double maxDeg = 0; double maxDeg2 = 0; @@ -233,51 +273,6 @@ public RenderTable calculate(GraphModel g) { return ret; } - private static RenderTable getVectors() { - RenderTable ret = new RenderTable(); - Vector titles = new Vector<>(); - titles.add(" m "); - // titles.add(" Max Planar "); - titles.add(" n "); - // titles.add(" Min "); - // titles.add(" Lanzhou "); - titles.add(" R "); - titles.add(" GA "); - titles.add(" AG "); - titles.add(" SDD "); - // titles.add(" R-min "); - // titles.add(" HM2 "); - // titles.add(" EM2 "); - // titles.add(" Hyper "); - // titles.add(" M2-M1 "); - // titles.add(" milo "); - // titles.add(" Inverse Sum Indeg "); - // titles.add(" SDD "); - // titles.add(" R.H.S "); - // titles.add(" max "); - // titles.add(" min "); - // titles.add(" Hyper "); - // titles.add("Th 7 "); - // titles.add("check"); - // titles.add("Correct"); - // titles.add(" matching "); - // titles.add(" GA/x "); - // titles.add(" Wp "); - // titles.add(" chrome "); - // titles.add(" chrome "); - // titles.add(" Lz "); - // titles.add(" Lz-Bar "); - - // titles.add(" R.H.S "); - // titles.add("Diameter"); - // titles.add("Clique Number"); - - titles.add(" V. Degrees "); - - ret.setTitles(titles); - return ret; - } - @Override public String getCategory() { return "Verification-Degree"; diff --git a/src/graphtea/extensions/reports/topological/ComparingE1E2.java b/src/graphtea/extensions/reports/topological/ComparingE1E2.java index f4cec18f..fa4544ec 100755 --- a/src/graphtea/extensions/reports/topological/ComparingE1E2.java +++ b/src/graphtea/extensions/reports/topological/ComparingE1E2.java @@ -75,7 +75,7 @@ public RenderTable calculate(GraphModel g) { double SDD=zif.getSDDIndex(); double GA=zif.getGAindex(); double ISI=zif.getInverseSumIndegIndex(); - int girth = (int) new GirthSize().calculate(g); + int girth = new GirthSize().calculate(g); int diameter = (int) new Diameter().calculate(g); int diacomp = (int) new Diameter().calculate(AlgorithmUtils.createComplementGraph(g)); double independenceNumber = (int)((new MaxOfIndSets()).calculate(g)); diff --git a/src/graphtea/extensions/reports/topological/EM2UpperBound.java b/src/graphtea/extensions/reports/topological/EM2UpperBound.java index 46877483..127a69fb 100755 --- a/src/graphtea/extensions/reports/topological/EM2UpperBound.java +++ b/src/graphtea/extensions/reports/topological/EM2UpperBound.java @@ -158,7 +158,7 @@ public RenderTable calculate(GraphModel g) { //Zhou2 - v.add(((M21/2)-m)*Math.pow(Math.sqrt(M21-(2*m)+(1/4))-(1/2),2)); + v.add(((M21/2)-m)*Math.pow(Math.sqrt(M21-(2*m)+((double) 1 /4))-((double) 1 /2),2)); //Zhou3 v.add(Math.pow(M21-(2*m),2)*(maxDeg-1)/(2*maxDeg)); diff --git a/src/graphtea/extensions/reports/topological/Mere1.java b/src/graphtea/extensions/reports/topological/Mere1.java index 9204c3ed..d0efb0ae 100755 --- a/src/graphtea/extensions/reports/topological/Mere1.java +++ b/src/graphtea/extensions/reports/topological/Mere1.java @@ -371,7 +371,7 @@ public RenderTable calculate(GraphModel g) { double harary = (double) Harary.calculate(g); - double ss = (double) 2*1.0/(diameter*(diameter+1)*1.0); + double ss = (double) 2 /(diameter*(diameter+1)*1.0); //double ss1 = (double) 2*1.0/((diameter*diameter)+(diameter)-2)*1.0); diff --git a/src/graphtea/extensions/reports/topological/PI.java b/src/graphtea/extensions/reports/topological/PI.java index debcb94d..2426ceaf 100755 --- a/src/graphtea/extensions/reports/topological/PI.java +++ b/src/graphtea/extensions/reports/topological/PI.java @@ -347,7 +347,7 @@ public RenderTable calculate(GraphModel g) { int wiener = (int) wi.calculate(g); - double ss = (double) 2*1.0/(diameter*(diameter+1)*1.0); + double ss = (double) 2 /(diameter*(diameter+1)*1.0); //double ss1 = (double) 2*1.0/((diameter*diameter)+(diameter)-2)*1.0); diff --git a/src/graphtea/extensions/reports/topological/Pheriperal.java b/src/graphtea/extensions/reports/topological/Pheriperal.java index b1ca8f54..6d4a0242 100755 --- a/src/graphtea/extensions/reports/topological/Pheriperal.java +++ b/src/graphtea/extensions/reports/topological/Pheriperal.java @@ -383,7 +383,7 @@ public RenderTable calculate(GraphModel g) { double harary = (double) Harary.calculate(g); - double ss = (double) 2*1.0/(diameter*(diameter+1)*1.0); + double ss = (double) 2 /(diameter*(diameter+1)*1.0); //double ss1 = (double) 2*1.0/((diameter*diameter)+(diameter)-2)*1.0); diff --git a/src/graphtea/extensions/reports/topological/Pheriperal1.java b/src/graphtea/extensions/reports/topological/Pheriperal1.java index 950c38be..720f1ce6 100755 --- a/src/graphtea/extensions/reports/topological/Pheriperal1.java +++ b/src/graphtea/extensions/reports/topological/Pheriperal1.java @@ -382,7 +382,7 @@ public RenderTable calculate(GraphModel g) { double harary = (double) Harary.calculate(g); - double ss = (double) 2*1.0/(diameter*(diameter+1)*1.0); + double ss = (double) 2 /(diameter*(diameter+1)*1.0); //double ss1 = (double) 2*1.0/((diameter*diameter)+(diameter)-2)*1.0); diff --git a/src/graphtea/extensions/reports/topological/Pheriperal2.java b/src/graphtea/extensions/reports/topological/Pheriperal2.java index 0e01009f..bdc9a127 100755 --- a/src/graphtea/extensions/reports/topological/Pheriperal2.java +++ b/src/graphtea/extensions/reports/topological/Pheriperal2.java @@ -382,7 +382,7 @@ public RenderTable calculate(GraphModel g) { double harary = (double) Harary.calculate(g); - double ss = (double) 2*1.0/(diameter*(diameter+1)*1.0); + double ss = (double) 2 /(diameter*(diameter+1)*1.0); //double ss1 = (double) 2*1.0/((diameter*diameter)+(diameter)-2)*1.0); diff --git a/src/graphtea/extensions/reports/topological/ZagrebIndexFunctions.java b/src/graphtea/extensions/reports/topological/ZagrebIndexFunctions.java index 5210f80b..f0cfa0c4 100755 --- a/src/graphtea/extensions/reports/topological/ZagrebIndexFunctions.java +++ b/src/graphtea/extensions/reports/topological/ZagrebIndexFunctions.java @@ -57,7 +57,7 @@ public double getInverseSumIndegIndex() { for (Edge e : g2.getEdges()) { int v1 = g.getDegree(g.getVertex(e.source.getId())); int v2 = g.getDegree(g.getVertex(e.target.getId())); - InverseSumIndeg += ( (v1 * v2)/(v1 + v2)); + InverseSumIndeg += ( (double) (v1 * v2) /(v1 + v2)); } return InverseSumIndeg; @@ -146,7 +146,7 @@ public double getAGIndex() { public double getPBIndex() { double ret = 0; for(Edge e : g.getEdges()) { - ret += ((Math.sqrt(g.getDegree(e.source)*1.0)) + (Math.sqrt(g.getDegree(e.target))*1.0))* + ret += ((Math.sqrt(g.getDegree(e.source)*1.0)) + (Math.sqrt(g.getDegree(e.target))))* (1.0/Math.sqrt(g.getDegree(e.source)*g.getDegree(e.target)*1.0))*(1.0/(Math.sqrt(g.getDegree(e.source) + g.getDegree(e.target) - 2))) ; } return ret; diff --git a/src/graphtea/graph/graph/FastRenderer.java b/src/graphtea/graph/graph/FastRenderer.java index dbdb9e31..3137dea3 100755 --- a/src/graphtea/graph/graph/FastRenderer.java +++ b/src/graphtea/graph/graph/FastRenderer.java @@ -268,8 +268,8 @@ public void fastpaintGraph(Graphics g, Boolean drawExtras) { double t = Math.atan2(vertexRadius * Math.sin(angle), vertexRadius * Math.cos(angle)); GPoint loc = e.target.getLocation(); - int x2 = (int) (loc.x + (vertexRadius / 2) * Math.cos(t)); - int y2 = (int) (loc.y + (vertexRadius / 2) * Math.sin(t)); + int x2 = (int) (loc.x + ((double) vertexRadius / 2) * Math.cos(t)); + int y2 = (int) (loc.y + ((double) vertexRadius / 2) * Math.sin(t)); gg.translate(x2 * zoomFactor, y2 * zoomFactor); gg.rotate(angle + Math.PI); @@ -317,7 +317,7 @@ public void fastpaintGraph(Graphics g, Boolean drawExtras) { int dl = (s.length() + 1 / 2) * 4; gg.setColor(c.darker().darker()); GPoint ll = v.getLabelLocation(); - gg.drawString(s, (int) ((l.x - dl + ll.x) * zoomFactor), (int) ((l.y + vertexRadius / 2 + ll.y) * zoomFactor)); + gg.drawString(s, (int) ((l.x - dl + ll.x) * zoomFactor), (int) ((l.y + (double) vertexRadius / 2 + ll.y) * zoomFactor)); } } gg.setColor(Color.DARK_GRAY); @@ -376,7 +376,7 @@ public void paint(Graphics2D g, Edge model, GraphModel graph, Boolean drawExtras g.drawLine(x1z, y1z, x2z, y2z); } else { //the control point of the curve is put another place so that the curve hits the real control point. - QuadCurve2D.Double curve = new QuadCurve2D.Double(x1z, y1z, (4 * ctrlPntViewX - x1z - x2z) / 2, (4 * ctrlPntViewY - y1z - y2z) / 2, x2z, y2z); + QuadCurve2D.Double curve = new QuadCurve2D.Double(x1z, y1z, (double) (4 * ctrlPntViewX - x1z - x2z) / 2, (double) (4 * ctrlPntViewY - y1z - y2z) / 2, x2z, y2z); g.draw(curve); } diff --git a/src/graphtea/graph/old/ArrowHandler.java b/src/graphtea/graph/old/ArrowHandler.java index 14bfe7cf..87f9effa 100755 --- a/src/graphtea/graph/old/ArrowHandler.java +++ b/src/graphtea/graph/old/ArrowHandler.java @@ -64,8 +64,8 @@ public static void paint(Graphics _g, GraphModel gr, Edge e, double zoomFactor) int h = (int) v2ShapeSize.getY(); double t = Math.atan2(w * Math.sin(angle), h * Math.cos(angle)); GPoint loc = e.target.getLocation(); - int x2 = (int) ((zoomFactor * loc.x) + ((w / 2) * Math.cos(t))); - int y2 = (int) ((zoomFactor * loc.y) + ((h / 2) * Math.sin(t))); + int x2 = (int) ((zoomFactor * loc.x) + (((double) w / 2) * Math.cos(t))); + int y2 = (int) ((zoomFactor * loc.y) + (((double) h / 2) * Math.sin(t))); // g.drawLine((int)loc.x-30, (int)loc.y-30, (int)loc.x+30, (int)loc.y+30); g.translate(x2 + 1, y2 + 1); g.rotate(angle + Math.PI); diff --git a/src/graphtea/graph/old/GShape.java b/src/graphtea/graph/old/GShape.java index f33bdbe9..5332fe8e 100755 --- a/src/graphtea/graph/old/GShape.java +++ b/src/graphtea/graph/old/GShape.java @@ -372,13 +372,13 @@ private static int[][] provideRegularPolygonPoints(int h, int w, int n) { for (int i = 0; i != n; i++) { if (n % 2 == 0) { - xPoints[i] = (int) (((h - 1) / 2) * Math.cos((i) * Math.PI * 2 / n) + (h - 1) / 2); - yPoints[i] = (int) (((h - 1) / 2) * Math.sin((i) * Math.PI * 2 / n) + (h - 1) / 2); + xPoints[i] = (int) (((double) (h - 1) / 2) * Math.cos((i) * Math.PI * 2 / n) + (double) (h - 1) / 2); + yPoints[i] = (int) (((double) (h - 1) / 2) * Math.sin((i) * Math.PI * 2 / n) + (double) (h - 1) / 2); } else { - xPoints[i] = (int) (((h - 1) / 2) * Math.cos((i) * (Math.PI * 2) / n + Math.PI / 2) + (h - 1) / 2); - yPoints[i] = (int) (((h - 1) / 2) * Math.sin((i) * (Math.PI * 2) / n + Math.PI / 2) + (h - 1) / 2); + xPoints[i] = (int) (((double) (h - 1) / 2) * Math.cos((i) * (Math.PI * 2) / n + Math.PI / 2) + (double) (h - 1) / 2); + yPoints[i] = (int) (((double) (h - 1) / 2) * Math.sin((i) * (Math.PI * 2) / n + Math.PI / 2) + (double) (h - 1) / 2); } } @@ -395,15 +395,15 @@ private static int[][] provideStarPoints(int h, int w, int n) { // h = h < w ? h : w; for (int i = 0; i != n; i++) { if (n % 2 == 0) { - xInnerPoints[i] = (int) (((w - 1) / 5) * Math.cos((i) * (Math.PI * 2) / n + (n - 1) * Math.PI / n) + (w - 1) / 2); - xOuterPoints[i] = (int) (((w - 1) / 2) * Math.cos((i) * (Math.PI * 2) / n) + (w - 1) / 2); - yInnerPoints[i] = (int) (((h - 1) / 5) * Math.sin((i) * (Math.PI * 2) / n + (n - 1) * Math.PI / n) + (h - 1) / 2); - yOuterPoints[i] = (int) (((h - 1) / 2) * Math.sin((i) * (Math.PI * 2) / n) + (h - 1) / 2); + xInnerPoints[i] = (int) (((double) (w - 1) / 5) * Math.cos((i) * (Math.PI * 2) / n + (n - 1) * Math.PI / n) + (double) (w - 1) / 2); + xOuterPoints[i] = (int) (((double) (w - 1) / 2) * Math.cos((i) * (Math.PI * 2) / n) + (double) (w - 1) / 2); + yInnerPoints[i] = (int) (((double) (h - 1) / 5) * Math.sin((i) * (Math.PI * 2) / n + (n - 1) * Math.PI / n) + (double) (h - 1) / 2); + yOuterPoints[i] = (int) (((double) (h - 1) / 2) * Math.sin((i) * (Math.PI * 2) / n) + (double) (h - 1) / 2); } else { - xInnerPoints[i] = (int) (((w - 1) / 5) * Math.cos((i) * (Math.PI * 2) / n + Math.PI / 2) + (w - 1) / 2); - xOuterPoints[i] = (int) (((w - 1) / 2) * Math.cos((i) * (Math.PI * 2) / n - Math.PI / 2) + (w - 1) / 2); - yInnerPoints[i] = (int) (((h - 1) / 5) * Math.sin((i) * (Math.PI * 2) / n + Math.PI / 2) + (h - 1) / 2); - yOuterPoints[i] = (int) (((h - 1) / 2) * Math.sin((i) * (Math.PI * 2) / n - Math.PI / 2) + (h - 1) / 2); + xInnerPoints[i] = (int) (((double) (w - 1) / 5) * Math.cos((i) * (Math.PI * 2) / n + Math.PI / 2) + (double) (w - 1) / 2); + xOuterPoints[i] = (int) (((double) (w - 1) / 2) * Math.cos((i) * (Math.PI * 2) / n - Math.PI / 2) + (double) (w - 1) / 2); + yInnerPoints[i] = (int) (((double) (h - 1) / 5) * Math.sin((i) * (Math.PI * 2) / n + Math.PI / 2) + (double) (h - 1) / 2); + yOuterPoints[i] = (int) (((double) (h - 1) / 2) * Math.sin((i) * (Math.PI * 2) / n - Math.PI / 2) + (double) (h - 1) / 2); } } @@ -432,10 +432,10 @@ private static int[][] provideNiceStarPoints(int h, int w, int n) { // h = h < w ? h : w; for (int i = 0; i != n; i++) { // if (n % 2 == 0) { - xInnerPoints[i] = (int) (((w - 1) / 5) * Math.cos((i) * (Math.PI * 2) / n) + (w - 1) / 2); - xOuterPoints[i] = (int) (((w - 1) / 2) * Math.cos((i) * (Math.PI * 2) / n) + (w - 1) / 2); - yInnerPoints[i] = (int) (((h - 1) / 5) * Math.sin((i) * (Math.PI * 2) / n) + (h - 1) / 2); - yOuterPoints[i] = (int) (((h - 1) / 2) * Math.sin((i) * (Math.PI * 2) / n) + (h - 1) / 2); + xInnerPoints[i] = (int) (((double) (w - 1) / 5) * Math.cos((i) * (Math.PI * 2) / n) + (double) (w - 1) / 2); + xOuterPoints[i] = (int) (((double) (w - 1) / 2) * Math.cos((i) * (Math.PI * 2) / n) + (double) (w - 1) / 2); + yInnerPoints[i] = (int) (((double) (h - 1) / 5) * Math.sin((i) * (Math.PI * 2) / n) + (double) (h - 1) / 2); + yOuterPoints[i] = (int) (((double) (h - 1) / 2) * Math.sin((i) * (Math.PI * 2) / n) + (double) (h - 1) / 2); // } else { // xInnerPoints[i] = (int) (((h - 1) / 5) * Math.cos((i) * (Math.PI * 2) / n ) + (h - 1) / 2); // xOuterPoints[i] = (int) (((h - 1) / 2) * Math.cos((i) * (Math.PI * 2) / n ) + (h - 1) / 2); diff --git a/src/graphtea/graph/ui/GraphRectRegionSelect.java b/src/graphtea/graph/ui/GraphRectRegionSelect.java index 1a63670e..8bdc24ef 100755 --- a/src/graphtea/graph/ui/GraphRectRegionSelect.java +++ b/src/graphtea/graph/ui/GraphRectRegionSelect.java @@ -128,8 +128,4 @@ public void paint(Graphics g, Object destinationComponent, Boolean drawExtras) { Rectangle _rect = GraphUtils.createViewRectangle(gv.getGraph(), rect); g.drawRoundRect(_rect.x, _rect.y, _rect.width, _rect.height, 5, 5); } - - public boolean isEnable() { - return true; - } } diff --git a/src/graphtea/library/event/VertexEdgeLabelEvent.java b/src/graphtea/library/event/VertexEdgeLabelEvent.java index 6e386c24..f8c76e8f 100755 --- a/src/graphtea/library/event/VertexEdgeLabelEvent.java +++ b/src/graphtea/library/event/VertexEdgeLabelEvent.java @@ -13,7 +13,7 @@ * * @author azin azadi */ -public class VertexEdgeLabelEvent implements Event { +public class VertexEdgeLabelEvent> implements Event { public String label; public VertexType v; public EdgeType e; diff --git a/src/graphtea/library/util/Complex.java b/src/graphtea/library/util/Complex.java index f3244548..c6fdb73e 100755 --- a/src/graphtea/library/util/Complex.java +++ b/src/graphtea/library/util/Complex.java @@ -80,8 +80,8 @@ public Complex conj() { } /** @return true, if imaginary part of complex number is (numerically) zero.*/ - public boolean isReal() { - return 1.E-12 > Math.abs(im()); + public boolean isNotReal() { + return !(1.E-12 > Math.abs(im())); } /** @return magnitude of complex number. @@ -91,23 +91,19 @@ public double mag () { } public double doubleValue() { - if(!isReal()) return 0.0; - // better: throw new Msg("Complex.doubleValue","must be pure real"); + if(isNotReal()) return 0.0; return re(); } public float floatValue() { - if(!isReal()) return 0.0f; - // throw new Msg("Complex.doubleValue","must be pure real"); + if(isNotReal()) return 0.0f; return (float)re(); } public long longValue() { - if(!isReal()) return 0; - // throw new Msg("Complex.doubleValue","must be pure real"); + if(isNotReal()) return 0; return (long)re(); } public int intValue() { - if(!isReal()) return 0; - // throw new Msg("Complex.doubleValue","must be pure real"); + if(isNotReal()) return 0; return (int)re(); } @@ -123,8 +119,8 @@ public Angle arg () { return result; } /** - * Provides sum of this and right hand side. - * @param z right hand side + * Provides a sum of this and right hand side. + * @param z right-hand side * @return sum of this and z */ public Complex plus (Complex z) { @@ -134,8 +130,8 @@ public Complex plus(double x) { return new Complex(re()+x,im()); } /** - * Provides difference of this and right hand side. - * @param z right hand side + * Provides difference of this and right-hand side. + * @param z right-hand side * @return difference of this and z */ public Complex minus (Complex z) { @@ -145,16 +141,16 @@ public Complex minus(double x) { return new Complex(re()-x,im()); } /** - * Provides product of this and complex right hand side. - * @param z right hand side + * Provides product of this and complex right-hand side. + * @param z right-hand side * @return product of this and z */ public Complex times (Complex z) { return new Complex(u*z.re() - v*z.im(),u*z.im() + v*z.re()); } /** - * Provides product of this and float right hand side. - * @param x right hand side + * Provides product of this and float right-hand side. + * @param x right-hand side * @return product of this and z */ public Complex times(double x) { @@ -162,7 +158,7 @@ public Complex times(double x) { } /** * Computes fraction between this und rhs. - * @param z complex right hand side + * @param z complex right-hand side * @return fraction of this and z * @throws Msg if mag(z) == 0 */ diff --git a/src/graphtea/platform/attribute/AtomAttribute.java b/src/graphtea/platform/attribute/AtomAttribute.java index a8dccb20..5a77e743 100755 --- a/src/graphtea/platform/attribute/AtomAttribute.java +++ b/src/graphtea/platform/attribute/AtomAttribute.java @@ -9,7 +9,7 @@ import java.io.Serializable; /** - * the place holder for a single validable attribute + * the placeholder for a single avoidable attribute * * @author Azin Azadi */ diff --git a/src/graphtea/plugins/commandline/ShellConsole.java b/src/graphtea/plugins/commandline/ShellConsole.java index 520b696c..3bf79081 100755 --- a/src/graphtea/plugins/commandline/ShellConsole.java +++ b/src/graphtea/plugins/commandline/ShellConsole.java @@ -536,10 +536,6 @@ public void print(final Object o) { }); } - public Color getResultColor() { - return Color.blue; - } - /** * Prints "\\n" (i.e. newline) */ diff --git a/src/graphtea/plugins/commandline/commands/VertexCommands.java b/src/graphtea/plugins/commandline/commands/VertexCommands.java index a4c91692..17e267bd 100755 --- a/src/graphtea/plugins/commandline/commands/VertexCommands.java +++ b/src/graphtea/plugins/commandline/commands/VertexCommands.java @@ -52,7 +52,6 @@ public Iterator getVertexIterator() { , description = "shows the vertex is selected or not") public Boolean isSelected(@Parameter(name = "vertex label:")String label) { Vertex v = getVertexByLabel(label); -// //Init.run.ext_console.println(v.isSelected(), Init.run.ext_console.getResultColor()); return v.isSelected(); } diff --git a/src/graphtea/plugins/commandline/parsers/DefaultParser.java b/src/graphtea/plugins/commandline/parsers/DefaultParser.java index b446c59e..1c404827 100755 --- a/src/graphtea/plugins/commandline/parsers/DefaultParser.java +++ b/src/graphtea/plugins/commandline/parsers/DefaultParser.java @@ -25,7 +25,6 @@ public DefaultParser(Shell shell) { this.shell = shell; } - public String getName() { return "default parser"; } diff --git a/src/graphtea/plugins/commandline/parsers/InwardCommandParser.java b/src/graphtea/plugins/commandline/parsers/InwardCommandParser.java index effd657b..02ff3b4e 100755 --- a/src/graphtea/plugins/commandline/parsers/InwardCommandParser.java +++ b/src/graphtea/plugins/commandline/parsers/InwardCommandParser.java @@ -154,7 +154,27 @@ public void addCommands(Object o) { abbrs.put(cm.abbreviation(), cm.name()); methodObjects.put(m, o); - StringBuilder evaluation = getStringBuilder(m, cm); + StringBuilder evaluation = new StringBuilder(cm.name() + "("); + + StringBuilder temp = new StringBuilder(); + if (m.getParameterTypes().length != 0) + temp = new StringBuilder("Object[] o = new Object[" + m.getParameterTypes().length + "];"); + + int i = 0; + for (Class c : m.getParameterTypes()) { + i++; + evaluation.append(c.getSimpleName()).append(" x").append(i).append(" ,"); + temp.append("o[").append(i - 1).append("] = x").append(i).append(";"); + } + + evaluation = new StringBuilder((m.getParameterTypes().length == 0 ? + evaluation.toString() : evaluation.substring(0, evaluation.length() - 1)) + + ")"); + + if (m.getParameterTypes().length == 0) + evaluation.append("{").append(temp).append("me.parseShell(\"").append(cm.name()).append("\"").append(",null,current_interpreter);}"); + else + evaluation.append("{").append(temp).append("me.parseShell(\"").append(cm.name()).append("\"").append(",o,current_interpreter);}"); evaluations += evaluation + "\n"; } } @@ -165,32 +185,7 @@ public void addCommands(Object o) { } } - private static StringBuilder getStringBuilder(Method m, CommandAttitude cm) { - StringBuilder evaluation = new StringBuilder(cm.name() + "("); - - StringBuilder temp = new StringBuilder(); - if (m.getParameterTypes().length != 0) - temp = new StringBuilder("Object[] o = new Object[" + m.getParameterTypes().length + "];"); - - int i = 0; - for (Class c : m.getParameterTypes()) { - i++; - evaluation.append(c.getSimpleName()).append(" x").append(i).append(" ,"); - temp.append("o[").append(i - 1).append("] = x").append(i).append(";"); - } - - evaluation = new StringBuilder((m.getParameterTypes().length == 0 ? - evaluation.toString() : evaluation.substring(0, evaluation.length() - 1)) - + ")"); - - if (m.getParameterTypes().length == 0) - evaluation.append("{").append(temp).append("me.parseShell(\"").append(cm.name()).append("\"").append(",null,current_interpreter);}"); - else - evaluation.append("{").append(temp).append("me.parseShell(\"").append(cm.name()).append("\"").append(",o,current_interpreter);}"); - return evaluation; - } - - public Object parseShell(String command, Object[] ps, Interpreter in) throws ShellCommandException { + public Object parseShell(String command, Object[] ps, Interpreter in) { Method m = commands.get(command); Object o = null; if (m != null) { diff --git a/src/graphtea/plugins/commandline/util/codecompletionutils/CodeCompletionUtils.java b/src/graphtea/plugins/commandline/util/codecompletionutils/CodeCompletionUtils.java index 2cf3c7a8..673b470a 100755 --- a/src/graphtea/plugins/commandline/util/codecompletionutils/CodeCompletionUtils.java +++ b/src/graphtea/plugins/commandline/util/codecompletionutils/CodeCompletionUtils.java @@ -47,10 +47,9 @@ public static Vector complete(String part, Interpreter interpreter) { try { Class c = interpreter.get(part.substring(0, part.lastIndexOf("."))).getClass(); String t = part.substring(part.indexOf(".") + 1); - if (c.getMethods() != null) - for (Method m : c.getMethods()) - if (m.getName().startsWith(t)) - ret.add(part.substring(0, part.lastIndexOf(".")) + "." + m.getName()); + for (Method m : c.getMethods()) + if (m.getName().startsWith(t)) + ret.add(part.substring(0, part.lastIndexOf(".")) + "." + m.getName()); } catch (Exception e) { //evalError.printStackTrace(); } diff --git a/src/graphtea/plugins/main/ccp/Paste.java b/src/graphtea/plugins/main/ccp/Paste.java index 50cd0126..5495389b 100755 --- a/src/graphtea/plugins/main/ccp/Paste.java +++ b/src/graphtea/plugins/main/ccp/Paste.java @@ -151,9 +151,7 @@ void _onDrop(GraphEvent data) { //selects the inserted edges & vertices SubGraph sd = new SubGraph(); sd.vertices.addAll(toBeSelectedVertices); - for (Edge e : toBeSelectedEdges) { - sd.edges.add(e); - } + sd.edges.addAll(toBeSelectedEdges); Select.setSelection(blackboard, sd); // if the prev. operation was cut, the clipboard should be cleand diff --git a/src/graphtea/plugins/main/core/actions/BlackBoardWatcher.java b/src/graphtea/plugins/main/core/actions/BlackBoardWatcher.java index ce0bacd3..d4420963 100755 --- a/src/graphtea/plugins/main/core/actions/BlackBoardWatcher.java +++ b/src/graphtea/plugins/main/core/actions/BlackBoardWatcher.java @@ -101,7 +101,7 @@ protected void fireListeners(String key, Object newValue) { public t getData(String name) { addEdge(getCallingMethod(), name, false, false); - return (t) super.getData(name); + return super.getData(name); } private Vertex getLogVertex(String name) { diff --git a/src/graphtea/plugins/main/saveload/core/extension/GraphWriterExtensionAction.java b/src/graphtea/plugins/main/saveload/core/extension/GraphWriterExtensionAction.java index 44d641de..06e1b2bb 100755 --- a/src/graphtea/plugins/main/saveload/core/extension/GraphWriterExtensionAction.java +++ b/src/graphtea/plugins/main/saveload/core/extension/GraphWriterExtensionAction.java @@ -56,7 +56,7 @@ public void performExtension() { IOException ee; GraphIOException gioe; - private void exportGraph() throws IOException { + private void exportGraph() { g = blackboard.getData(GraphAttrSet.name); JFileChooser fileChooser = new JFileChooser(); ExampleFileFilter fileFilter = new ExampleFileFilter(ge.getExtension(), ge.getName()); diff --git a/src/graphtea/plugins/main/saveload/image/SaveImage.java b/src/graphtea/plugins/main/saveload/image/SaveImage.java index c2cd0545..edd5e402 100755 --- a/src/graphtea/plugins/main/saveload/image/SaveImage.java +++ b/src/graphtea/plugins/main/saveload/image/SaveImage.java @@ -42,7 +42,7 @@ public String getExtension() { return extension; } - public void write(File file, GraphModel graph) throws GraphIOException { + public void write(File file, GraphModel graph) { saveImage(graph, file, extension); } diff --git a/src/graphtea/plugins/main/saveload/xmlparser/GraphmlHandler.java b/src/graphtea/plugins/main/saveload/xmlparser/GraphmlHandler.java index 963b947b..b03aa49a 100755 --- a/src/graphtea/plugins/main/saveload/xmlparser/GraphmlHandler.java +++ b/src/graphtea/plugins/main/saveload/xmlparser/GraphmlHandler.java @@ -15,26 +15,26 @@ public interface GraphmlHandler { * @param data value or null * @param meta attributes */ - void handle_key(final java.lang.String data, final Attributes meta) throws SAXException; + void handle_key(final java.lang.String data, final Attributes meta); /** * A container element start event handling method. * * @param meta attributes */ - void start_edge(final Attributes meta) throws SAXException; + void start_edge(final Attributes meta); /** * A container element end event handling method. */ - void end_edge() throws SAXException; + void end_edge(); /** * An empty element event handling method. * * @param meta value or null */ - void handle_locator(final Attributes meta) throws SAXException; + void handle_locator(final Attributes meta); /** * A data element event handling method. @@ -42,79 +42,79 @@ public interface GraphmlHandler { * @param data value or null * @param meta attributes */ - void handle_data(final java.lang.String data, final Attributes meta) throws SAXException; + void handle_data(final java.lang.String data, final Attributes meta); /** * A container element start event handling method. * * @param meta attributes */ - void start_node(final Attributes meta) throws SAXException; + void start_node(final Attributes meta); /** * A container element end event handling method. */ - void end_node() throws SAXException; + void end_node(); /** * A container element start event handling method. * * @param meta attributes */ - void start_graph(final Attributes meta) throws SAXException; + void start_graph(final Attributes meta); /** * A container element end event handling method. */ - void end_graph() throws SAXException; + void end_graph(); /** * A container element start event handling method. * * @param meta attributes */ - void start_endpoint(final Attributes meta) throws SAXException; + void start_endpoint(final Attributes meta); /** * A container element end event handling method. */ - void end_endpoint() throws SAXException; + void end_endpoint(); /** * A container element start event handling method. * * @param meta attributes */ - void start_graphml(final Attributes meta) throws SAXException; + void start_graphml(final Attributes meta); /** * A container element end event handling method. */ - void end_graphml() throws SAXException; + void end_graphml(); /** * A container element start event handling method. * * @param meta attributes */ - void start_hyperedge(final Attributes meta) throws SAXException; + void start_hyperedge(final Attributes meta); /** * A container element end event handling method. */ - void end_hyperedge() throws SAXException; + void end_hyperedge(); /** * A container element start event handling method. * * @param meta attributes */ - void start_port(final Attributes meta) throws SAXException; + void start_port(final Attributes meta); /** * A container element end event handling method. */ - void end_port() throws SAXException; + void end_port(); /** * A data element event handling method. @@ -122,5 +122,5 @@ public interface GraphmlHandler { * @param data value or null * @param meta attributes */ - void handle_desc(final java.lang.String data, final Attributes meta) throws SAXException; + void handle_desc(final java.lang.String data, final Attributes meta); } diff --git a/src/graphtea/plugins/main/saveload/xmlparser/GraphmlHandlerImpl.java b/src/graphtea/plugins/main/saveload/xmlparser/GraphmlHandlerImpl.java index f23c24f0..3a8dd6f9 100755 --- a/src/graphtea/plugins/main/saveload/xmlparser/GraphmlHandlerImpl.java +++ b/src/graphtea/plugins/main/saveload/xmlparser/GraphmlHandlerImpl.java @@ -59,7 +59,7 @@ public GraphModel getGraph() { public static HashMap graphMLVertexKeys = new HashMap<>(); public static HashMap graphMLEdgeKeys = new HashMap<>(); - public void handle_key(final java.lang.String data, final Attributes meta) throws SAXException { + public void handle_key(final java.lang.String data, final Attributes meta) { String s = meta.getValue("for"); String id = meta.getValue("id"); String attrname = meta.getValue("attr.name"); @@ -74,7 +74,7 @@ public void handle_key(final java.lang.String data, final Attributes meta) throw if (DEBUG) System.err.println("handle_key: " + data + "," + id + "," + s); } - public void start_edge(final Attributes meta) throws SAXException { + public void start_edge(final Attributes meta) { Vertex v1 = vByID.get(meta.getValue("source")); Vertex v2 = vByID.get(meta.getValue("target")); @@ -88,17 +88,17 @@ public void start_edge(final Attributes meta) throws SAXException { if (DEBUG) System.err.println("start_edge: " + meta); } - public void end_edge() throws SAXException { + public void end_edge() { if (DEBUG) System.err.println("end_edge()"); } - public void handle_locator(final Attributes meta) throws SAXException { + public void handle_locator(final Attributes meta) { if (DEBUG) System.err.println("handle_locator: " + meta); } - public void handle_data(final java.lang.String data, final Attributes meta) throws SAXException { + public void handle_data(final java.lang.String data, final Attributes meta) { String s1 = meta.getValue("key"); if (s1.charAt(0) == 'g') { String ss = graphMLGraphKeys.get(s1.substring(2)); @@ -115,7 +115,7 @@ public void handle_data(final java.lang.String data, final Attributes meta) thro if (DEBUG) System.err.println("handle_data: " + data + "," + s1); } - public void start_node(final Attributes meta) throws SAXException { + public void start_node(final Attributes meta) { String id = meta.getValue("id"); Vertex v = new Vertex(); vByID.put(id, v); @@ -127,13 +127,13 @@ public void start_node(final Attributes meta) throws SAXException { if (DEBUG) System.err.println("start_node: " + meta); } - public void end_node() throws SAXException { + public void end_node() { g.insertVertex(curv); if (DEBUG) System.err.println("end_node()"); } - public void start_graph(final Attributes meta) throws SAXException { + public void start_graph(final Attributes meta) { if (g == null) { //todo g = new GraphModel(meta.getValue("edgedefault").equals("directed")); @@ -143,52 +143,52 @@ public void start_graph(final Attributes meta) throws SAXException { if (DEBUG) System.err.println("start_graph: " + meta); } - public void end_graph() throws SAXException { + public void end_graph() { if (DEBUG) System.err.println("end_graph()"); } - public void start_endpoint(final Attributes meta) throws SAXException { + public void start_endpoint(final Attributes meta) { if (DEBUG) System.err.println("start_endpoint: " + meta); } - public void end_endpoint() throws SAXException { + public void end_endpoint() { if (DEBUG) System.err.println("end_endpoint()"); } - public void start_graphml(final Attributes meta) throws SAXException { + public void start_graphml(final Attributes meta) { if (DEBUG) System.err.println("start_graphml: " + meta); } - public void end_graphml() throws SAXException { + public void end_graphml() { if (DEBUG) System.err.println("end_graphml()"); } - public void start_hyperedge(final Attributes meta) throws SAXException { + public void start_hyperedge(final Attributes meta) { if (DEBUG) System.err.println("start_hyperedge: " + meta); } - public void end_hyperedge() throws SAXException { + public void end_hyperedge() { if (DEBUG) System.err.println("end_hyperedge()"); } - public void start_port(final Attributes meta) throws SAXException { + public void start_port(final Attributes meta) { if (DEBUG) System.err.println("start_port: " + meta); } - public void end_port() throws SAXException { + public void end_port() { if (DEBUG) System.err.println("end_port()"); } - public void handle_desc(final java.lang.String data, final Attributes meta) throws SAXException { + public void handle_desc(final java.lang.String data, final Attributes meta) { if (DEBUG) System.err.println("handle_desc: " + data); } diff --git a/src/graphtea/plugins/main/saveload/xmlparser/GraphmlParser.java b/src/graphtea/plugins/main/saveload/xmlparser/GraphmlParser.java index 1dcc96d6..dcde22df 100755 --- a/src/graphtea/plugins/main/saveload/xmlparser/GraphmlParser.java +++ b/src/graphtea/plugins/main/saveload/xmlparser/GraphmlParser.java @@ -51,13 +51,13 @@ public final void setDocumentLocator(Locator locator) { /** * This SAX interface method is implemented by the parser. */ - public final void startDocument() throws SAXException { + public final void startDocument() { } /** * This SAX interface method is implemented by the parser. */ - public final void endDocument() throws SAXException { + public final void endDocument() { } /** @@ -113,7 +113,7 @@ public final void endElement(java.lang.String ns, java.lang.String name, java.la /** * This SAX interface method is implemented by the parser. */ - public final void characters(char[] chars, int start, int len) throws SAXException { + public final void characters(char[] chars, int start, int len) { buffer.append(chars, start, len); } @@ -121,31 +121,31 @@ public final void characters(char[] chars, int start, int len) throws SAXExcepti /** * This SAX interface method is implemented by the parser. */ - public final void ignorableWhitespace(char[] chars, int start, int len) throws SAXException { + public final void ignorableWhitespace(char[] chars, int start, int len) { } /** * This SAX interface method is implemented by the parser. */ - public final void processingInstruction(java.lang.String target, java.lang.String data) throws SAXException { + public final void processingInstruction(java.lang.String target, java.lang.String data) { } /** * This SAX interface method is implemented by the parser. */ - public final void startPrefixMapping(final java.lang.String prefix, final java.lang.String uri) throws SAXException { + public final void startPrefixMapping(final java.lang.String prefix, final java.lang.String uri) { } /** * This SAX interface method is implemented by the parser. */ - public final void endPrefixMapping(final java.lang.String prefix) throws SAXException { + public final void endPrefixMapping(final java.lang.String prefix) { } /** * This SAX interface method is implemented by the parser. */ - public final void skippedEntity(java.lang.String name) throws SAXException { + public final void skippedEntity(java.lang.String name) { } private void dispatch(final boolean fireOnlyIfMixed) throws SAXException { @@ -176,10 +176,6 @@ private void dispatch(final boolean fireOnlyIfMixed) throws SAXException { * @param input InputSource to be parsed. * @throws java.io.IOException on I/O error. * @throws SAXException propagated exception thrown by a DocumentHandler. - * @throws javax.xml.parsers.ParserConfigurationException - * a parser satisfying requested configuration can not be created. - * @throws javax.xml.parsers.FactoryConfigurationRrror - * if the implementation can not be instantiated. */ public void parse(final InputSource input) throws SAXException, javax.xml.parsers.ParserConfigurationException, java.io.IOException { @@ -261,7 +257,7 @@ public void fatalError(SAXParseException ex) throws SAXException { throw ex; } - public void warning(SAXParseException ex) throws SAXException { + public void warning(SAXParseException ex) { // ignore } }; diff --git a/src/graphtea/plugins/main/select/RectangularSelect.java b/src/graphtea/plugins/main/select/RectangularSelect.java index a56a7c5a..bfb3d2c5 100755 --- a/src/graphtea/plugins/main/select/RectangularSelect.java +++ b/src/graphtea/plugins/main/select/RectangularSelect.java @@ -77,7 +77,6 @@ void _onMouseMoved(GraphEvent data) { } void _onDrop(GraphEvent data) { -// if (isEnable()) graphRectRegionSelector.startSelectingRegion(); } diff --git a/src/graphtea/plugins/main/ui/GraphColoringRenderer.java b/src/graphtea/plugins/main/ui/GraphColoringRenderer.java index bf78827f..f7b2f4e2 100755 --- a/src/graphtea/plugins/main/ui/GraphColoringRenderer.java +++ b/src/graphtea/plugins/main/ui/GraphColoringRenderer.java @@ -48,25 +48,25 @@ public void mouseClicked(MouseEvent e) { } private static String getHTMLFromColoring(GraphColoring myColoring) { - String txt = ""; - txt = ""; - if (myColoring.label != null && !myColoring.label.equals("")) { - txt = txt + "" + myColoring.label + ": "; + StringBuilder txt = new StringBuilder(); + txt = new StringBuilder(""); + if (myColoring.label != null && !myColoring.label.isEmpty()) { + txt.append("").append(myColoring.label).append(": "); } if (myColoring.vertexColors != null && !myColoring.vertexColors.isEmpty()) { - txt = txt + "Vertex colors: "; + txt.append("Vertex colors: "); for (Map.Entry p : myColoring.vertexColors.entrySet()) { - txt = txt + p.getKey().getLabel() + ":" + p.getValue() + " , "; + txt.append(p.getKey().getLabel()).append(":").append(p.getValue()).append(" , "); } } if (myColoring.edgeColors != null && !myColoring.edgeColors.isEmpty()) { - txt = txt + "
Edge colors: "; + txt.append("
Edge colors: "); for (Map.Entry p : myColoring.edgeColors.entrySet()) { - txt = txt + p.getKey().getLabel() + ":" + p.getValue() + " , "; + txt.append(p.getKey().getLabel()).append(":").append(p.getValue()).append(" , "); } } - txt = txt + ""; - return txt; + txt.append(""); + return txt.toString(); } private void showOnGraph(GraphColoring myColoring) { diff --git a/src/graphtea/plugins/visualization/circular/CircularDispatchVisualization.java b/src/graphtea/plugins/visualization/circular/CircularDispatchVisualization.java index 8eed3f27..5b2a7d55 100755 --- a/src/graphtea/plugins/visualization/circular/CircularDispatchVisualization.java +++ b/src/graphtea/plugins/visualization/circular/CircularDispatchVisualization.java @@ -15,10 +15,8 @@ import graphtea.plugins.visualization.corebasics.extension.VisualizationExtension; import graphtea.ui.UIUtils; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Vector; +import java.util.*; +import java.util.stream.Collectors; /** * @author Rouzbeh Ebrahimi @@ -53,9 +51,10 @@ private Cycle FindMainCycle(GraphModel g) { vertexCycleLength.put(v, i); } } + Object[] verticeArray = vertexCycleLength.keySet().toArray(); - Arrays.sort(verticeArray, new VertexCycleLengthComparator()); - Vertex maxLengthCycle = (Vertex) verticeArray[0]; + List l = vertexCycleLength.keySet().parallelStream().sorted(new VertexCycleLengthComparator()).collect(Collectors.toList()); + Vertex maxLengthCycle = l.get(0); return new Cycle(); } @@ -116,8 +115,6 @@ private void findCycle(Vector currentLevel, int minLength, int color) { if (!nextLevel.isEmpty()) { findCycle(nextLevel, minLength, color + 1); - } else { - return; } } @@ -183,7 +180,7 @@ public void locateAll(Vector currentLevelVertices, int width, int radius int currentLevelCount = currentLevelVertices.size(); Vector nextLevel = findNextLevelChildren(currentLevelVertices); int nextLevelCount = nextLevel.size(); - double degree = 360 / currentLevelCount; + double degree = (double) 360 / currentLevelCount; int j = 0; if (currentLevelCount == 1 && currentLevelVertices.elementAt(0).equals(root)) { GPoint newPoint = new GPoint(350, 350); @@ -203,8 +200,6 @@ public void locateAll(Vector currentLevelVertices, int width, int radius if (!nextLevel.isEmpty()) { visitedVertices.addAll(nextLevel); locateAll(nextLevel, width, radius + radius * 3 / 8); - } else { - return; } } diff --git a/src/graphtea/plugins/visualization/corebasics/basics/VertexCycleLengthComparator.java b/src/graphtea/plugins/visualization/corebasics/basics/VertexCycleLengthComparator.java index 25edd003..1b1a2974 100755 --- a/src/graphtea/plugins/visualization/corebasics/basics/VertexCycleLengthComparator.java +++ b/src/graphtea/plugins/visualization/corebasics/basics/VertexCycleLengthComparator.java @@ -11,22 +11,18 @@ /** * @author Rouzbeh Ebrahimi */ -public class VertexCycleLengthComparator implements Comparator { +public class VertexCycleLengthComparator implements Comparator { public VertexCycleLengthComparator() { } - public int compare(Object o1, Object o2) { - Vertex v1 = (Vertex) o1; - Vertex v2 = (Vertex) o2; + public int compare(Vertex v1, Vertex v2) { int v1i1 = ((PathProperties) v1.getProp().obj).getFirstColor(); int v1i2 = ((PathProperties) v1.getProp().obj).getSecondColor(); Integer v1i = v1i1 + v1i2; Integer v2i1 = ((PathProperties) v2.getProp().obj).getFirstColor(); Integer v2i2 = ((PathProperties) v2.getProp().obj).getSecondColor(); Integer v2i = v2i1 + v2i2; - return v1i.compareTo(v2i); - } } diff --git a/src/graphtea/plugins/visualization/hierarchical/BendedTrees.java b/src/graphtea/plugins/visualization/hierarchical/BendedTrees.java index f989b49b..2a9764da 100755 --- a/src/graphtea/plugins/visualization/hierarchical/BendedTrees.java +++ b/src/graphtea/plugins/visualization/hierarchical/BendedTrees.java @@ -143,11 +143,11 @@ public void locateAllVertices(Vector currentLevelVertices, int width, in for (Vertex v : currentLevelVertices) { if (nextLevelCount != 0) { - GPoint newPoint = new GPoint(horizontalDist * (i + 1) + width / (nextLevelCount + currentLevelCount), currentLevelHeight); + GPoint newPoint = new GPoint(horizontalDist * (i + 1) + (double) width / (nextLevelCount + currentLevelCount), currentLevelHeight); vertexPlaces.put(v, newPoint); i += g.getInDegree(v); } else { - GPoint newPoint = new GPoint(horizontalDist * (i) + width / (currentLevelCount), currentLevelHeight); + GPoint newPoint = new GPoint(horizontalDist * (i) + (double) width / (currentLevelCount), currentLevelHeight); vertexPlaces.put(v, newPoint); i++; } @@ -156,8 +156,6 @@ public void locateAllVertices(Vector currentLevelVertices, int width, in if (!nextLevel.isEmpty()) { visitedVertices.addAll(nextLevel); locateAllVertices(nextLevel, width, currentLevelHeight + 30); - } else { - return; } } } diff --git a/src/graphtea/plugins/visualization/treevisualizations/BackwardTrees.java b/src/graphtea/plugins/visualization/treevisualizations/BackwardTrees.java index f4ea3670..c529afcf 100755 --- a/src/graphtea/plugins/visualization/treevisualizations/BackwardTrees.java +++ b/src/graphtea/plugins/visualization/treevisualizations/BackwardTrees.java @@ -117,7 +117,7 @@ public void locateAll(Vector currentLevelVertices, int width, int curren int j = 0; double phase; - phase = 360 / (degree); + phase = (double) (double) 360 / (degree); GPoint[] circle = PositionGenerators.convert(PositionGenerators.circle((int) v.getLocation().getX(), (int) v.getLocation().getY(), radius, radius, degree)); int t = 0; diff --git a/src/graphtea/plugins/visualization/treevisualizations/CircularTreeVisualization.java b/src/graphtea/plugins/visualization/treevisualizations/CircularTreeVisualization.java index 6699720f..03d56409 100755 --- a/src/graphtea/plugins/visualization/treevisualizations/CircularTreeVisualization.java +++ b/src/graphtea/plugins/visualization/treevisualizations/CircularTreeVisualization.java @@ -181,7 +181,7 @@ public void locateAll(Vector currentLevelVertices, int width, int radius int currentLevelCount = currentLevelVertices.size(); Vector nextLevel = findNextLevelChildren(currentLevelVertices); int nextLevelCount = nextLevel.size(); - double degree = 360 / currentLevelCount; + double degree = (double) 360 / currentLevelCount; int j = 0; if (currentLevelCount == 1 && currentLevelVertices.elementAt(0).equals(root)) { GPoint newPoint = new GPoint(350, 350); diff --git a/src/graphtea/plugins/visualization/treevisualizations/HierarchicalTreeVisualization.java b/src/graphtea/plugins/visualization/treevisualizations/HierarchicalTreeVisualization.java index 1c19511f..8a566c98 100755 --- a/src/graphtea/plugins/visualization/treevisualizations/HierarchicalTreeVisualization.java +++ b/src/graphtea/plugins/visualization/treevisualizations/HierarchicalTreeVisualization.java @@ -122,7 +122,7 @@ public void locateAll(Vector currentLevelVertices, int width, int curren Vector nextLevel = findNextLevelChildren(currentLevelVertices); for (Vertex v : currentLevelVertices) { - GPoint newPoint = new GPoint(horizontalDist * i + width / (currentLevelCount + 1), currentLevelHeight); + GPoint newPoint = new GPoint(horizontalDist * i + (double) width / (currentLevelCount + 1), currentLevelHeight); vertexPlaces.put(v, newPoint); i++; } diff --git a/src/graphtea/plugins/visualization/treevisualizations/SparseTreeVisualization.java b/src/graphtea/plugins/visualization/treevisualizations/SparseTreeVisualization.java index 9fe4cd22..6daa2bf9 100755 --- a/src/graphtea/plugins/visualization/treevisualizations/SparseTreeVisualization.java +++ b/src/graphtea/plugins/visualization/treevisualizations/SparseTreeVisualization.java @@ -118,11 +118,11 @@ public void locateAll(Vector currentLevelVertices, int width, int LevelH for (Vertex v : currentLevelVertices) { if (nextLevelCount != 0) { - GPoint newPoint = new GPoint(horizontalDist * (i + 1) + width / (nextLevelCount + currentLevelCount), LevelHeight); + GPoint newPoint = new GPoint(horizontalDist * (i + 1) + (double) width / (nextLevelCount + currentLevelCount), LevelHeight); vertexPlaces.put(v, newPoint); i += graph.getOutDegree(v); } else { - GPoint newPoint = new GPoint(horizontalDist * (i) + width / (currentLevelCount), LevelHeight); + GPoint newPoint = new GPoint(horizontalDist * (i) + (double) width / (currentLevelCount), LevelHeight); vertexPlaces.put(v, newPoint); i++; } diff --git a/src/graphtea/ui/components/gpropertyeditor/editors/GHashMapEditor.java b/src/graphtea/ui/components/gpropertyeditor/editors/GHashMapEditor.java deleted file mode 100755 index 0e5d908a..00000000 --- a/src/graphtea/ui/components/gpropertyeditor/editors/GHashMapEditor.java +++ /dev/null @@ -1,39 +0,0 @@ -// GraphTea Project: http://github.com/graphtheorysoftware/GraphTea -// Copyright (C) 2012 Graph Theory Software Foundation: http://GraphTheorySoftware.com -// Copyright (C) 2008 Mathematical Science Department of Sharif University of Technology -// Distributed under the terms of the GNU General Public License (GPL): http://www.gnu.org/licenses/ -package graphtea.ui.components.gpropertyeditor.editors; - -import graphtea.ui.PortableNotifiableAttributeSetImpl; -import graphtea.ui.components.gpropertyeditor.GPropertyEditor; - -import javax.swing.*; -import java.util.HashMap; - -/** - * @author azin azadi - */ -//todo: complete it! -public class GHashMapEditor extends GDialogEditor { - GPropertyEditor ged = new GPropertyEditor(); - - public JComponent getComponent(HashMap initialValue) { - return null; - } - - public HashMap getEditorValue() { - return null; - } - - public void setEditorValue(HashMap value) { - - } - - private PortableNotifiableAttributeSetImpl hashmap2NotifiableAttributeSetx(HashMap h) { - PortableNotifiableAttributeSetImpl a = new PortableNotifiableAttributeSetImpl(); - for (Object o : h.keySet()) { -// a.putAtr(o, h.get(o)); - } - return null; - } -} diff --git a/src/graphtea/ui/components/gpropertyeditor/editors/inplace/GDimensionEditor.java b/src/graphtea/ui/components/gpropertyeditor/editors/inplace/GDimensionEditor.java index 8c78fcb1..34c012d1 100755 --- a/src/graphtea/ui/components/gpropertyeditor/editors/inplace/GDimensionEditor.java +++ b/src/graphtea/ui/components/gpropertyeditor/editors/inplace/GDimensionEditor.java @@ -20,15 +20,12 @@ public Component getEditorComponent(Object value) { public Object getEditorValue() { String s = super.getEditorValue() + ""; - if (s != null) { - try { - return new Dimension(Integer.parseInt(s.substring(0, s.indexOf('*'))), - Integer.parseInt(s.substring(s.indexOf('*') + 1))); - } catch (Exception e) { - return this.initVal; - } + try { + return new Dimension(Integer.parseInt(s.substring(0, s.indexOf('*'))), + Integer.parseInt(s.substring(s.indexOf('*') + 1))); + } catch (Exception e) { + return this.initVal; } - return null; } } diff --git a/src/graphtea/ui/xml/UIHandler.java b/src/graphtea/ui/xml/UIHandler.java index d438c8c5..2d872407 100755 --- a/src/graphtea/ui/xml/UIHandler.java +++ b/src/graphtea/ui/xml/UIHandler.java @@ -14,88 +14,88 @@ public interface UIHandler { * * @param meta value or null */ - void handle_sidebar(final Attributes meta) throws SAXException; + void handle_sidebar(final Attributes meta); /** * An empty element event handling method. * * @param meta value or null */ - void handle_action(final Attributes meta) throws SAXException; + void handle_action(final Attributes meta); /** * A container element start event handling method. * * @param meta attributes */ - void start_submenu(final Attributes meta) throws SAXException; + void start_submenu(final Attributes meta); /** * A container element end event handling method. */ - void end_submenu() throws SAXException; + void end_submenu(); /** * An empty element event handling method. * * @param meta value or null */ - void handle_bar(final Attributes meta) throws SAXException; + void handle_bar(final Attributes meta); /** * A container element start event handling method. * * @param meta attributes */ - void start_toolbar(final Attributes meta) throws SAXException; + void start_toolbar(final Attributes meta); /** * A container element end event handling method. */ - void end_toolbar() throws SAXException; + void end_toolbar(); /** * A container element start event handling method. * * @param meta attributes */ - void start_toolbars(final Attributes meta) throws SAXException; + void start_toolbars(final Attributes meta); /** * A container element end event handling method. */ - void end_toolbars() throws SAXException; + void end_toolbars(); /** * An empty element event handling method. * * @param meta value or null */ - void handle_tool(final Attributes meta) throws SAXException; + void handle_tool(final Attributes meta); /** * An empty element event handling method. * * @param meta value or null */ - void handle_menu(final Attributes meta) throws SAXException; + void handle_menu(final Attributes meta); /** * A container element start event handling method. * * @param meta attributes */ - void start_menues(final Attributes meta) throws SAXException; + void start_menues(final Attributes meta); /** * A container element end event handling method. */ - void end_menues() throws SAXException; + void end_menues(); /** * An empty element event handling method. * * @param meta value or null */ - void handle_body(final Attributes meta) throws SAXException; + void handle_body(final Attributes meta); } diff --git a/src/graphtea/ui/xml/UIParser.java b/src/graphtea/ui/xml/UIParser.java index 27d76e9b..664a9ebb 100755 --- a/src/graphtea/ui/xml/UIParser.java +++ b/src/graphtea/ui/xml/UIParser.java @@ -50,13 +50,13 @@ public final void setDocumentLocator(Locator locator) { /** * This SAX interface method is implemented by the parser. */ - public final void startDocument() throws SAXException { + public final void startDocument() { } /** * This SAX interface method is implemented by the parser. */ - public final void endDocument() throws SAXException { + public final void endDocument() { } /** @@ -110,7 +110,7 @@ public final void endElement(java.lang.String ns, java.lang.String name, java.la /** * This SAX interface method is implemented by the parser. */ - public final void characters(char[] chars, int start, int len) throws SAXException { + public final void characters(char[] chars, int start, int len) { buffer.append(chars, start, len); } @@ -118,34 +118,34 @@ public final void characters(char[] chars, int start, int len) throws SAXExcepti /** * This SAX interface method is implemented by the parser. */ - public final void ignorableWhitespace(char[] chars, int start, int len) throws SAXException { + public final void ignorableWhitespace(char[] chars, int start, int len) { } /** * This SAX interface method is implemented by the parser. */ - public final void processingInstruction(java.lang.String target, java.lang.String data) throws SAXException { + public final void processingInstruction(java.lang.String target, java.lang.String data) { } /** * This SAX interface method is implemented by the parser. */ - public final void startPrefixMapping(final java.lang.String prefix, final java.lang.String uri) throws SAXException { + public final void startPrefixMapping(final java.lang.String prefix, final java.lang.String uri) { } /** * This SAX interface method is implemented by the parser. */ - public final void endPrefixMapping(final java.lang.String prefix) throws SAXException { + public final void endPrefixMapping(final java.lang.String prefix) { } /** * This SAX interface method is implemented by the parser. */ - public final void skippedEntity(java.lang.String name) throws SAXException { + public final void skippedEntity(java.lang.String name) { } - private void dispatch(final boolean fireOnlyIfMixed) throws SAXException { + private void dispatch(final boolean fireOnlyIfMixed) { if (fireOnlyIfMixed && buffer.length() == 0) return; //skip it @@ -161,10 +161,6 @@ private void dispatch(final boolean fireOnlyIfMixed) throws SAXException { * @param input InputSource to be parsed. * @throws java.io.IOException on I/O error. * @throws SAXException propagated exception thrown by a DocumentHandler. - * @throws javax.xml.parsers.ParserConfigurationException - * a parser satisfining requested configuration can not be created. - * @throws javax.xml.parsers.FactoryConfigurationRrror - * if the implementation can not be instantiated. */ public void parse(final InputSource input) throws SAXException, javax.xml.parsers.ParserConfigurationException, java.io.IOException { @@ -177,10 +173,6 @@ public void parse(final InputSource input) throws SAXException, javax.xml.parser * @param url URL source to be parsed. * @throws java.io.IOException on I/O error. * @throws SAXException propagated exception thrown by a DocumentHandler. - * @throws javax.xml.parsers.ParserConfigurationException - * a parser satisfining requested configuration can not be created. - * @throws javax.xml.parsers.FactoryConfigurationRrror - * if the implementation can not be instantiated. */ public void parse(final java.net.URL url) throws SAXException, javax.xml.parsers.ParserConfigurationException, java.io.IOException { @@ -248,7 +240,7 @@ public void fatalError(SAXParseException ex) throws SAXException { throw ex; } - public void warning(SAXParseException ex) throws SAXException { + public void warning(SAXParseException ex) { // ignore } }; From 916821168e25ba53c4c7f42603e912853fab5f12 Mon Sep 17 00:00:00 2001 From: Ali Rostami Date: Wed, 21 May 2025 07:33:58 +0200 Subject: [PATCH 6/7] refactoring --- .../extensions/reports/topological/DegreeDistance.java | 2 -- src/graphtea/graph/graph/AbstractGraphRenderer.java | 2 +- .../treevisualizations/CircularTreeVisualization.java | 2 -- .../treevisualizations/HierarchicalTreeVisualization.java | 6 +----- .../treevisualizations/SparseTreeVisualization.java | 2 -- src/graphtea/ui/extension/AbstractExtensionAction.java | 4 ++-- 6 files changed, 4 insertions(+), 14 deletions(-) diff --git a/src/graphtea/extensions/reports/topological/DegreeDistance.java b/src/graphtea/extensions/reports/topological/DegreeDistance.java index 422a68d2..692e8022 100755 --- a/src/graphtea/extensions/reports/topological/DegreeDistance.java +++ b/src/graphtea/extensions/reports/topological/DegreeDistance.java @@ -11,10 +11,8 @@ /** * @author azin azadi - */ - @CommandAttitude(name = "degree_distance", abbreviation = "_ddistance") public class DegreeDistance implements GraphReportExtension { public String getName() { diff --git a/src/graphtea/graph/graph/AbstractGraphRenderer.java b/src/graphtea/graph/graph/AbstractGraphRenderer.java index efcc48a2..f4f2f98d 100755 --- a/src/graphtea/graph/graph/AbstractGraphRenderer.java +++ b/src/graphtea/graph/graph/AbstractGraphRenderer.java @@ -55,7 +55,7 @@ public void addPostPaintHandler(PaintHandler ph) { } /** - * adds ph to Pre Paint Handlers, which means that ph. Paint will be called before each rendering of the graph + * Adds ph to PrePaint Handlers, which means that ph. Paint will be called before each rendering of the graph * * @param ph The paint handler */ diff --git a/src/graphtea/plugins/visualization/treevisualizations/CircularTreeVisualization.java b/src/graphtea/plugins/visualization/treevisualizations/CircularTreeVisualization.java index 03d56409..8b2ae2b5 100755 --- a/src/graphtea/plugins/visualization/treevisualizations/CircularTreeVisualization.java +++ b/src/graphtea/plugins/visualization/treevisualizations/CircularTreeVisualization.java @@ -201,8 +201,6 @@ public void locateAll(Vector currentLevelVertices, int width, int radius if (!nextLevel.isEmpty()) { visitedVertices.addAll(nextLevel); locateAll(nextLevel, width, radius + radius * 3 / 8); - } else { - return; } } diff --git a/src/graphtea/plugins/visualization/treevisualizations/HierarchicalTreeVisualization.java b/src/graphtea/plugins/visualization/treevisualizations/HierarchicalTreeVisualization.java index 8a566c98..45ed86dc 100755 --- a/src/graphtea/plugins/visualization/treevisualizations/HierarchicalTreeVisualization.java +++ b/src/graphtea/plugins/visualization/treevisualizations/HierarchicalTreeVisualization.java @@ -68,9 +68,7 @@ private Vertex findHigherVertex(Vertex v1, Vertex v2) { private Vertex findAppropriateRoot(GraphModel g) { Vertex root = g.getAVertex(); - Iterator ei = g.iterator(); - while (ei.hasNext()) { - Vertex e = ei.next(); + for (Vertex e : g) { root = findHigherVertex(e, root); } return root; @@ -130,8 +128,6 @@ public void locateAll(Vector currentLevelVertices, int width, int curren if (!nextLevel.isEmpty()) { visitedVertices.addAll(nextLevel); locateAll(nextLevel, width, currentLevelHeight + eachLevelHeigh); - } else { - return; } } diff --git a/src/graphtea/plugins/visualization/treevisualizations/SparseTreeVisualization.java b/src/graphtea/plugins/visualization/treevisualizations/SparseTreeVisualization.java index 6daa2bf9..4b771014 100755 --- a/src/graphtea/plugins/visualization/treevisualizations/SparseTreeVisualization.java +++ b/src/graphtea/plugins/visualization/treevisualizations/SparseTreeVisualization.java @@ -131,8 +131,6 @@ public void locateAll(Vector currentLevelVertices, int width, int LevelH if (!nextLevel.isEmpty()) { visitedVertices.addAll(nextLevel); locateAll(nextLevel, width, LevelHeight + eachLevelHeigh); - } else { - return; } } diff --git a/src/graphtea/ui/extension/AbstractExtensionAction.java b/src/graphtea/ui/extension/AbstractExtensionAction.java index 58b86ad6..a065056d 100755 --- a/src/graphtea/ui/extension/AbstractExtensionAction.java +++ b/src/graphtea/ui/extension/AbstractExtensionAction.java @@ -203,7 +203,7 @@ public void mouseClicked(MouseEvent e) { } /** - * determines whether to insert an extra button at the right side of menu item, + * determines whether to insert an extra button on the right side of menu item, * normally this is true whenever the target extension implements Parameterizable (have some parameters) * on this mode on pressing the button a dialog for setting the parameters will be shown, and then * it will be executed, if the user clicks the menu item directly the extension will be @@ -219,7 +219,7 @@ public void mouseClicked(MouseEvent e) { * @see graphtea.plugins.algorithmanimator.extension.AlgorithmExtensionAction */ protected boolean isInsertExtraButtonToMenuItem() { - return false; //target instanceof Parameterizable; we don't want this button for now. just go with the simple interface + return false; //target instanceof Parameterizable; we don't want this button for now. go with the simple interface } /** From cbff0f2d799ca52a43fd82369d5b7e1862075a35 Mon Sep 17 00:00:00 2001 From: Ali Rostami Date: Wed, 21 May 2025 17:03:38 +0200 Subject: [PATCH 7/7] refactoring --- .../extensions/reports/MaxIndependentSetReport.java | 6 ------ src/graphtea/ui/extension/AbstractExtensionAction.java | 4 ++-- src/test/GeneratorsTest.java | 6 ++---- 3 files changed, 4 insertions(+), 12 deletions(-) diff --git a/src/graphtea/extensions/reports/MaxIndependentSetReport.java b/src/graphtea/extensions/reports/MaxIndependentSetReport.java index b3609d35..04e1ab6d 100755 --- a/src/graphtea/extensions/reports/MaxIndependentSetReport.java +++ b/src/graphtea/extensions/reports/MaxIndependentSetReport.java @@ -22,12 +22,6 @@ @CommandAttitude(name = "maximum_independent_set", abbreviation = "_mis") public class MaxIndependentSetReport implements GraphReportExtension> { -// @Parameter(name = "Lower Bound", description = "Lower Bound for the number of independent set members, This will make the search Interval smaller") -// public Integer lowerBound = 1; -// -// @Parameter(name = "All Independent Sets", description = "Create a list of all independent sets of graph using minimum number of members") -// public Boolean allColorings = false; -// public String getName() { return "Max Independent Set"; diff --git a/src/graphtea/ui/extension/AbstractExtensionAction.java b/src/graphtea/ui/extension/AbstractExtensionAction.java index a065056d..e0333b37 100755 --- a/src/graphtea/ui/extension/AbstractExtensionAction.java +++ b/src/graphtea/ui/extension/AbstractExtensionAction.java @@ -37,8 +37,8 @@ /** * the base class for creating extension handlers, - * the implementing class will have a menu assigned to it automatically the name of the menu will be - * from the constructors parameter(sp), and they will also listen to UI.getUIEvent(sp.getName()) + * the implementing class will have a menu assigned to it automatically, the name of the menu will be + * from the constructor parameter(sp), and they will also listen to UI.getUIEvent(sp.getName()) * * @author azin azadi */ diff --git a/src/test/GeneratorsTest.java b/src/test/GeneratorsTest.java index 6062f904..9288924b 100755 --- a/src/test/GeneratorsTest.java +++ b/src/test/GeneratorsTest.java @@ -324,8 +324,6 @@ public void testGeneralizedPetersonGenerator() { GeneralizedPetersonGenerator.k = 2; GeneralizedPetersonGenerator varGeneralizedPetersonGenerator = new GeneralizedPetersonGenerator(); GraphModel g = varGeneralizedPetersonGenerator.generateGraph(); - int n = GeneralizedPetersonGenerator.n; - int k = GeneralizedPetersonGenerator.k; int numOfVertices = g.numOfVertices(); int numOfEdges = g.getEdgesCount(); ArrayList maxAndMinDegree = new MaxAndMinDegree().calculate(g); @@ -446,7 +444,7 @@ public void testRegularGraphGenerator() { int girth = new GirthSize().calculate(g); int diameter = new Diameter().calculate(g); Assert.assertEquals(girth, deg + 1); -// Assert.assertEquals(diameter, n); ? do not know how to calculate + //Assert.assertEquals(diameter, n); Assert.assertEquals(numOfVertices, n); Assert.assertEquals(numOfEdges, ((long) n *deg)/2); Assert.assertEquals(maxDegree, deg); @@ -567,7 +565,7 @@ public void testKmnoGenerator() { } else if(n >= m && n >= o) { maxdeg = n + Math.max(m,o); mindeg = m + o; - } else if(o > n && o > m) { + } else { maxdeg = o + Math.max(n,m); mindeg = n + m; }

" + ((Number) (objects[j])).intValue() + "").append(((Number) (objects[j])).intValue()).append("00