diff --git a/.github/workflows/ant.yml b/.github/workflows/ant.yml index 15f6d726..58ee8d01 100755 --- a/.github/workflows/ant.yml +++ b/.github/workflows/ant.yml @@ -10,10 +10,10 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up JDK 11 + - name: Set up JDK 17 uses: actions/setup-java@v4 with: - java-version: '11' + java-version: '17' distribution: 'temurin' - name: Download JUnit 5 dependencies diff --git a/build.xml b/build.xml index cabf39b5..309a3bb1 100755 --- a/build.xml +++ b/build.xml @@ -48,7 +48,7 @@ + source="17" target="17" includeantruntime="false"> @@ -129,7 +129,7 @@ target: compile ================================= --> - + diff --git a/src/graphtea/extensions/AlgorithmUtils.java b/src/graphtea/extensions/AlgorithmUtils.java index 249d8417..97adfee0 100755 --- a/src/graphtea/extensions/AlgorithmUtils.java +++ b/src/graphtea/extensions/AlgorithmUtils.java @@ -50,9 +50,11 @@ public static void resetVertexMarks(GraphModel g) { public static boolean isConnected(GraphModel g) { ArrayList vs = new ArrayList<>(); int[] parent = new int[g.getVerticesCount()]; - for(int i=0;i < g.getVerticesCount();i++) parent[i] = -1; + for (int i = 0; i < g.getVerticesCount(); i++) { + parent[i] = -1; + } dfs(g, 0, vs, parent); - return Arrays.stream(vs.toArray()).distinct().toArray().length == g.getVerticesCount(); + return vs.stream().distinct().count() == g.getVerticesCount(); } /** @@ -428,17 +430,19 @@ 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"; - else - res += "" + AlgorithmUtils.round(rv[i],10); - if(i!=rv.length-1) { - res += ","; + if (iv[i] != 0) { + res.append(AlgorithmUtils.round(rv[i], 10)).append(" + ") + .append(AlgorithmUtils.round(iv[i], 10)).append("i"); + } else { + res.append(AlgorithmUtils.round(rv[i], 10)); + } + if (i != rv.length - 1) { + res.append(","); } } - return res; + return res.toString(); } /** @@ -485,6 +489,35 @@ public static double sumOfEigenValues(Matrix A) { return sum; } + /** + * Returns the all-pairs shortest-path distance matrix for {@code g} (unweighted). + * Convenience wrapper around {@link FloydWarshall} to avoid the two-liner boilerplate + * that appears throughout the codebase. + * + * @param g the graph + * @return distance matrix d where d[i][j] is the shortest path length from vertex i to vertex j + */ + public static int[][] getAllPairsDistances(GraphModel g) { + return new FloydWarshall().getAllPairsShortestPathWithoutWeight(g); + } + + /** + * Computes the spectral energy of a matrix: sum of |eigenvalue - shift| over all real eigenvalues. + * Use shift = 0 for plain energy (e.g. Distance Energy, Transmission Energy). + * + * @param A the matrix whose eigenvalues to sum + * @param shift subtracted from each eigenvalue before taking the absolute value + * @return spectral energy + */ + public static double spectralEnergy(Matrix A, double shift) { + double[] rv = A.eig().getRealEigenvalues(); + double sum = 0; + for (double v : rv) { + sum += Math.abs(v - shift); + } + return sum; + } + /** * Computes the eigen values * @@ -495,25 +528,27 @@ public static String getEigenValues(Matrix A) { EigenvalueDecomposition ed = A.eig(); double[] rv = ed.getRealEigenvalues(); double[] iv = ed.getImagEigenvalues(); - String res = ""; - List EigenValues = new ArrayList<>(); + StringBuilder res = new StringBuilder(); + List eigenValues = new ArrayList<>(); for (int i = 0; i < rv.length; i++) { - if (iv[i] != 0) - res +="" + AlgorithmUtils.round(rv[i],10) + " + " + AlgorithmUtils.round(iv[i],10) + "i"; - else - EigenValues.add(AlgorithmUtils.round(rv[i],10)); - } - if(EigenValues.size() > 0) { - res = ""; - EigenValues.sort((aDouble, t1) -> -aDouble.compareTo(t1)); - for (int i = 0; i < EigenValues.size(); i++) { - res += EigenValues.get(i); - if(i != EigenValues.size() - 1) { - res+=","; + if (iv[i] != 0) { + 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.isEmpty()) { + res = new StringBuilder(); + eigenValues.sort((a, b) -> -a.compareTo(b)); + for (int i = 0; i < eigenValues.size(); i++) { + res.append(eigenValues.get(i)); + if (i != eigenValues.size() - 1) { + res.append(","); } } } - return res; + return res.toString(); } // get kth minimum degree @@ -682,8 +717,7 @@ public static Matrix getMaxDegreeAdjacencyMatrix (GraphModel g) { * @return the maximum degree adjacency matrix */ public static Matrix getDistanceAdjacencyMatrix (GraphModel g) { - FloydWarshall fw = new FloydWarshall(); - int[][] dist = fw.getAllPairsShortestPathWithoutWeight(g); + int[][] dist = getAllPairsDistances(g); Matrix adj = g.getAdjacencyMatrix(); for(int i=0;i < adj.getColumnDimension();i++) { for(int j=0;j < adj.getRowDimension();j++) { @@ -808,9 +842,8 @@ public static GPoint normalize(GPoint vector) { } public static Matrix getDistanceLaplacianMatrix (GraphModel g) { - FloydWarshall fw = new FloydWarshall(); int sum; - int[][] dist = fw.getAllPairsShortestPathWithoutWeight(g); + int[][] dist = getAllPairsDistances(g); Matrix adj = g.getAdjacencyMatrix(); for(int i=0;i < adj.getColumnDimension();i++) { sum=0; @@ -825,9 +858,8 @@ public static Matrix getDistanceLaplacianMatrix (GraphModel g) { } public static Matrix getDistanceSignlessLaplacianMatrix (GraphModel g) { - FloydWarshall fw = new FloydWarshall(); double sum; - int [][] dist = fw.getAllPairsShortestPathWithoutWeight(g); + int[][] dist = getAllPairsDistances(g); Matrix adj = g.getAdjacencyMatrix(); for(int i=0;i < adj.getColumnDimension();i++) { sum=0; @@ -844,9 +876,8 @@ public static Matrix getDistanceSignlessLaplacianMatrix (GraphModel g) { } public static Matrix getDiagonalTransMatrix (GraphModel g) { - FloydWarshall fw = new FloydWarshall(); int sum; - int[][] dist = fw.getAllPairsShortestPathWithoutWeight(g); + int[][] dist = getAllPairsDistances(g); Matrix adj = g.getAdjacencyMatrix(); for(int i=0;i < adj.getColumnDimension();i++) { sum=0; @@ -861,9 +892,8 @@ public static Matrix getDiagonalTransMatrix (GraphModel g) { } public static Matrix getAverageTransMatrix (GraphModel g) { - FloydWarshall fw = new FloydWarshall(); - int sum; sum=0; - int[][] dist = fw.getAllPairsShortestPathWithoutWeight(g); + int sum = 0; + int[][] dist = getAllPairsDistances(g); Matrix adj = g.getAdjacencyMatrix(); for(int i=0;i < adj.getColumnDimension();i++) { for(int j=0;j < adj.getRowDimension();j++) { diff --git a/src/graphtea/extensions/actions/EdgeSemitotalGraph.java b/src/graphtea/extensions/actions/EdgeSemitotalGraph.java index d1ad88fe..e0af1ee3 100755 --- a/src/graphtea/extensions/actions/EdgeSemitotalGraph.java +++ b/src/graphtea/extensions/actions/EdgeSemitotalGraph.java @@ -5,107 +5,17 @@ package graphtea.extensions.actions; -import graphtea.graph.graph.Edge; -import graphtea.graph.graph.GPoint; -import graphtea.graph.graph.GraphModel; -import graphtea.graph.graph.Vertex; -import graphtea.platform.parameter.Parameter; -import graphtea.platform.parameter.Parametrizable; -import graphtea.plugins.main.GraphData; -import graphtea.plugins.main.extension.GraphActionExtension; - - /** - * Creates a line graph from the current graph and shows it in a new tab - * * @author Mohammad Ali Rostami * @author Azin Azadi */ -public class EdgeSemitotalGraph implements GraphActionExtension, Parametrizable { - @Parameter - public int k = 2; - - public void action(GraphData graphData) { - - GraphModel g1 = graphData.getGraph(); - GraphModel g2 = new GraphModel(false); - g2.setIsEdgesCurved(true); - - for(Vertex v : g1.getVertexArray()) { - Vertex tmp = new Vertex(); - tmp.setLocation(v.getLocation()); - g2.addVertex(tmp); - } - - for(Edge e : g1.getEdges()) { - GPoint v1 = e.source.getLocation(); - GPoint v2 = e.target.getLocation(); - double dis = v1.distance(v2); - GPoint v3 = GPoint.sub(v2, v1); - v3 = GPoint.div(v3, k+1); - - Vertex src = g2.getVertex(e.source.getId()); - for (int i = 0; i < k; i++) { - Vertex tmp = new Vertex(); - tmp.getProp().obj=e; - GPoint v4 = new GPoint(v3); - v4.multiply(i + 1); - v4.add(v1); - tmp.setLocation(v4); - g2.addVertex(tmp); - g2.addEdge(new Edge(src,tmp)); - src=tmp; - } - g2.addEdge(new Edge(src, g2.getVertex(e.target.getId()))); - } - - for(Vertex v1 : g2.getVertexArray()) { - for (Vertex v2 : g2.getVertexArray()) { - if(v1.getProp().obj!=null) { - if (v2.getProp().obj != null) { - Edge e1 = (Edge) v1.getProp().obj; - Edge e2 = (Edge) v2.getProp().obj; - if(edgeConnects(e1,e2)) { - Edge ee = new Edge(v1,v2); - GPoint vector = - GPoint.sub(v1.getLocation(),v2.getLocation()); - vector= GPoint.div(vector,vector.norm()); - GPoint ppVec = new GPoint(-vector.y,vector.x); - ppVec.multiply(30.0); - ee.setCurveControlPoint(ppVec); - g2.addEdge(ee); - } - } - } - } - } - - - graphData.core.showGraph(g2); - } - - public boolean edgeConnects(Edge e1,Edge e2) { - if(e1.source.getId() == e2.source.getId()) return true; - if(e1.target.getId() == e2.source.getId()) return true; - if(e1.source.getId() == e2.target.getId()) return true; - return e1.target.getId() == e2.target.getId(); - } - - public String getName() { - return "Edge Semitotal Graph"; - } - - public String getDescription() { - return "Edge Semitotal Graph"; - } +public class EdgeSemitotalGraph extends SubdividedGraphBase { + @Override protected boolean markSubdivisionVertices() { return true; } + @Override protected boolean addSubdivisionVertexEdges() { return true; } @Override - public String checkParameters() { - return null; - } + public String getName() { return "Edge Semitotal Graph"; } @Override - public String getCategory() { - return "Transformations"; - } + public String getDescription() { return "Edge Semitotal Graph"; } } diff --git a/src/graphtea/extensions/actions/SubdividedGraphBase.java b/src/graphtea/extensions/actions/SubdividedGraphBase.java new file mode 100644 index 00000000..286ff0fb --- /dev/null +++ b/src/graphtea/extensions/actions/SubdividedGraphBase.java @@ -0,0 +1,118 @@ +// 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/ + +package graphtea.extensions.actions; + +import graphtea.graph.graph.Edge; +import graphtea.graph.graph.GPoint; +import graphtea.graph.graph.GraphModel; +import graphtea.graph.graph.Vertex; +import graphtea.platform.parameter.Parameter; +import graphtea.platform.parameter.Parametrizable; +import graphtea.plugins.main.GraphData; +import graphtea.plugins.main.extension.GraphActionExtension; + +/** + * Shared template for TotalGraph, EdgeSemitotalGraph, and VertexSemitotalGraph. + * + *

All three subdivide each edge into k+1 segments. They differ in three + * independent boolean features controlled by subclass overrides: + *

    + *
  • {@link #markSubdivisionVertices()} — tag subdivision vertices with their edge
  • + *
  • {@link #addCurvedOriginalEdge()} — add a curved edge between original endpoints
  • + *
  • {@link #addSubdivisionVertexEdges()} — connect subdivision vertices of adjacent edges
  • + *
+ * + * @author Mohammad Ali Rostami + * @author Azin Azadi + */ +abstract class SubdividedGraphBase implements GraphActionExtension, Parametrizable { + @Parameter + public int k = 2; + + /** Whether to tag each subdivision vertex with its originating edge. */ + protected boolean markSubdivisionVertices() { return false; } + + /** Whether to add a curved edge between the original source and target. */ + protected boolean addCurvedOriginalEdge() { return false; } + + /** Whether to add edges between subdivision vertices of adjacent edges. */ + protected boolean addSubdivisionVertexEdges() { return false; } + + @Override + public void action(GraphData graphData) { + GraphModel g1 = graphData.getGraph(); + GraphModel g2 = new GraphModel(false); + g2.setIsEdgesCurved(true); + + for (Vertex v : g1.getVertexArray()) { + Vertex tmp = new Vertex(); + tmp.setLocation(v.getLocation()); + g2.addVertex(tmp); + } + + for (Edge e : g1.getEdges()) { + GPoint v1 = e.source.getLocation(); + GPoint v2 = e.target.getLocation(); + GPoint step = GPoint.div(GPoint.sub(v2, v1), k + 1); + + Vertex src = g2.getVertex(e.source.getId()); + for (int i = 0; i < k; i++) { + Vertex tmp = new Vertex(); + if (markSubdivisionVertices()) { + tmp.getProp().obj = e; + } + GPoint pos = new GPoint(step); + pos.multiply(i + 1); + pos.add(v1); + tmp.setLocation(pos); + g2.addVertex(tmp); + g2.addEdge(new Edge(src, tmp)); + src = tmp; + } + g2.addEdge(new Edge(src, g2.getVertex(e.target.getId()))); + + if (addCurvedOriginalEdge()) { + addCurvedEdge(g2, g2.getVertex(e.source.getId()), g2.getVertex(e.target.getId())); + } + } + + if (addSubdivisionVertexEdges()) { + for (Vertex v1 : g2.getVertexArray()) { + for (Vertex v2 : g2.getVertexArray()) { + if (v1.getProp().obj != null && v2.getProp().obj != null) { + Edge e1 = (Edge) v1.getProp().obj; + Edge e2 = (Edge) v2.getProp().obj; + if (edgeConnects(e1, e2)) { + addCurvedEdge(g2, v1, v2); + } + } + } + } + } + + graphData.core.showGraph(g2); + } + + private static void addCurvedEdge(GraphModel g, Vertex src, Vertex tgt) { + Edge ee = new Edge(src, tgt); + GPoint vector = GPoint.div(GPoint.sub(tgt.getLocation(), src.getLocation()), + GPoint.sub(tgt.getLocation(), src.getLocation()).norm()); + GPoint ppVec = new GPoint(-vector.y, vector.x); + ppVec.multiply(30.0); + ee.setCurveControlPoint(ppVec); + g.addEdge(ee); + } + + private static boolean edgeConnects(Edge e1, Edge e2) { + if (e1.source.getId() == e2.source.getId()) { return true; } + if (e1.target.getId() == e2.source.getId()) { return true; } + if (e1.source.getId() == e2.target.getId()) { return true; } + return e1.target.getId() == e2.target.getId(); + } + + @Override + public String getCategory() { return "Transformations"; } +} diff --git a/src/graphtea/extensions/actions/TotalGraph.java b/src/graphtea/extensions/actions/TotalGraph.java index 7de8154f..82c27d01 100755 --- a/src/graphtea/extensions/actions/TotalGraph.java +++ b/src/graphtea/extensions/actions/TotalGraph.java @@ -5,117 +5,18 @@ package graphtea.extensions.actions; -import graphtea.graph.graph.Edge; -import graphtea.graph.graph.GPoint; -import graphtea.graph.graph.GraphModel; -import graphtea.graph.graph.Vertex; -import graphtea.platform.parameter.Parameter; -import graphtea.platform.parameter.Parametrizable; -import graphtea.plugins.main.GraphData; -import graphtea.plugins.main.extension.GraphActionExtension; - - /** - * Creates a line graph from the current graph and shows it in a new tab - * * @author Mohammad Ali Rostami * @author Azin Azadi */ -public class TotalGraph implements GraphActionExtension, Parametrizable { - @Parameter - public int k = 2; - - public void action(GraphData graphData) { - - GraphModel g1 = graphData.getGraph(); - GraphModel g2 = new GraphModel(false); - g2.setIsEdgesCurved(true); - - for(Vertex v : g1.getVertexArray()) { - Vertex tmp = new Vertex(); - tmp.setLocation(v.getLocation()); - g2.addVertex(tmp); - } - - for(Edge e : g1.getEdges()) { - GPoint v1 = e.source.getLocation(); - GPoint v2 = e.target.getLocation(); - double dis = v1.distance(v2); - GPoint v3 = GPoint.sub(v2, v1); - v3 = GPoint.div(v3, k+1); - - Vertex src = g2.getVertex(e.source.getId()); - for (int i = 0; i < k; i++) { - Vertex tmp = new Vertex(); - tmp.getProp().obj=e; - GPoint v4 = new GPoint(v3); - v4.multiply(i + 1); - v4.add(v1); - tmp.setLocation(v4); - g2.addVertex(tmp); - g2.addEdge(new Edge(src,tmp)); - src=tmp; - } - g2.addEdge(new Edge(src, g2.getVertex(e.target.getId()))); - Edge ee = new Edge(g2.getVertex(e.source.getId()), - g2.getVertex(e.target.getId())); - GPoint vector = GPoint.sub(g2.getVertex(e.target.getId()).getLocation(), - g2.getVertex(e.source.getId()).getLocation()); - vector= GPoint.div(vector,vector.norm()); - GPoint ppVec = new GPoint(-vector.y,vector.x); - ppVec.multiply(30.0); - ee.setCurveControlPoint(ppVec); - g2.addEdge(ee); - - } - - for(Vertex v1 : g2.getVertexArray()) { - for (Vertex v2 : g2.getVertexArray()) { - if(v1.getProp().obj!=null) { - if (v2.getProp().obj != null) { - Edge e1 = (Edge) v1.getProp().obj; - Edge e2 = (Edge) v2.getProp().obj; - if(edgeConnects(e1,e2)) { - Edge ee = new Edge(v1,v2); - GPoint vector = - GPoint.sub(v1.getLocation(),v2.getLocation()); - vector= GPoint.div(vector,vector.norm()); - GPoint ppVec = new GPoint(-vector.y,vector.x); - ppVec.multiply(30.0); - ee.setCurveControlPoint(ppVec); - g2.addEdge(ee); - } - } - } - } - } - - - graphData.core.showGraph(g2); - } - - public boolean edgeConnects(Edge e1,Edge e2) { - if(e1.source.getId() == e2.source.getId()) return true; - if(e1.target.getId() == e2.source.getId()) return true; - if(e1.source.getId() == e2.target.getId()) return true; - return e1.target.getId() == e2.target.getId(); - } - - public String getName() { - return "Total Graph"; - } - - public String getDescription() { - return "Total Graph"; - } +public class TotalGraph extends SubdividedGraphBase { + @Override protected boolean markSubdivisionVertices() { return true; } + @Override protected boolean addCurvedOriginalEdge() { return true; } + @Override protected boolean addSubdivisionVertexEdges() { return true; } @Override - public String checkParameters() { - return null; - } + public String getName() { return "Total Graph"; } @Override - public String getCategory() { - return "Transformations"; - } + public String getDescription() { return "Total Graph"; } } diff --git a/src/graphtea/extensions/actions/VertexSemitotalGraph.java b/src/graphtea/extensions/actions/VertexSemitotalGraph.java index b399b3eb..a9ccd926 100755 --- a/src/graphtea/extensions/actions/VertexSemitotalGraph.java +++ b/src/graphtea/extensions/actions/VertexSemitotalGraph.java @@ -5,87 +5,16 @@ package graphtea.extensions.actions; -import graphtea.graph.graph.Edge; -import graphtea.graph.graph.GPoint; -import graphtea.graph.graph.GraphModel; -import graphtea.graph.graph.Vertex; -import graphtea.platform.parameter.Parameter; -import graphtea.platform.parameter.Parametrizable; -import graphtea.plugins.main.GraphData; -import graphtea.plugins.main.extension.GraphActionExtension; - - /** - * Creates a vertex semitotal graph from the current graph and shows it in a new tab - * * @author Mohammad Ali Rostami * @author Azin Azadi */ -public class VertexSemitotalGraph implements GraphActionExtension, Parametrizable { - @Parameter - public int k = 2; - - public void action(GraphData graphData) { - - GraphModel g1 = graphData.getGraph(); - GraphModel g2 = new GraphModel(false); - g2.setIsEdgesCurved(true); - - for(Vertex v : g1.getVertexArray()) { - Vertex tmp = new Vertex(); - tmp.setLocation(v.getLocation()); - g2.addVertex(tmp); - } - - for(Edge e : g1.getEdges()) { - GPoint v1 = e.source.getLocation(); - GPoint v2 = e.target.getLocation(); - double dis = v1.distance(v2); - GPoint v3 = GPoint.sub(v2, v1); - v3 = GPoint.div(v3, k+1); - - Vertex src = g2.getVertex(e.source.getId()); - for (int i = 0; i < k; i++) { - Vertex tmp = new Vertex(); - GPoint v4 = new GPoint(v3); - v4.multiply(i + 1); - v4.add(v1); - tmp.setLocation(v4); - g2.addVertex(tmp); - g2.addEdge(new Edge(src,tmp)); - src=tmp; - } - g2.addEdge(new Edge(src, g2.getVertex(e.target.getId()))); - Edge ee = new Edge(g2.getVertex(e.source.getId()), - g2.getVertex(e.target.getId())); - GPoint vector = GPoint.sub(g2.getVertex(e.target.getId()).getLocation(), - g2.getVertex(e.source.getId()).getLocation()); - vector= GPoint.div(vector,vector.norm()); - GPoint ppVec = new GPoint(-vector.y,vector.x); - ppVec.multiply(30.0); - ee.setCurveControlPoint(ppVec); - g2.addEdge(ee); - - } - - graphData.core.showGraph(g2); - } - - public String getName() { - return "Vertex Semitotal Graph"; - } - - public String getDescription() { - return "Vertex Semitotal Graph"; - } +public class VertexSemitotalGraph extends SubdividedGraphBase { + @Override protected boolean addCurvedOriginalEdge() { return true; } @Override - public String checkParameters() { - return null; - } + public String getName() { return "Vertex Semitotal Graph"; } @Override - public String getCategory() { - return "Transformations"; - } + public String getDescription() { return "Vertex Semitotal Graph"; } } diff --git a/src/graphtea/extensions/actions/product/CartesianProduct.java b/src/graphtea/extensions/actions/product/CartesianProduct.java index 38755f5e..946d268a 100755 --- a/src/graphtea/extensions/actions/product/CartesianProduct.java +++ b/src/graphtea/extensions/actions/product/CartesianProduct.java @@ -1,48 +1,15 @@ package graphtea.extensions.actions.product; -import graphtea.graph.graph.GraphModel; -import graphtea.graph.ui.GTabbedGraphPane; -import graphtea.platform.parameter.Parameter; -import graphtea.platform.parameter.Parametrizable; -import graphtea.plugins.main.GraphData; -import graphtea.plugins.main.extension.GraphActionExtension; - /** - * Created by rostam on 10.07.15. * @author M. Ali Rostami */ -public class CartesianProduct implements GraphActionExtension, Parametrizable { - @Parameter(name = "First Graph",description = "First Graph") - public String g0 = "G0"; - @Parameter(name = "Second Graph",description = "Second Graph") - public String g1 = "G1"; - - @Override - public String getName() { - return "Cartesian Product"; - } - - @Override - public String getDescription() { - return "Cartesian Product"; - } - +public class CartesianProduct extends GProductAction { @Override - public void action(GraphData graphData) { - GTabbedGraphPane gtp = graphData.getBlackboard().getData(GTabbedGraphPane.NAME); - GCartesianProduct prod = new GCartesianProduct(); - GraphModel g= prod.multiply(gtp.getGraphs().get(g0), gtp.getGraphs().get(g1)); - prod.setPositions(g); - graphData.core.showGraph(g); - } + public String getName() { return "Cartesian Product"; } @Override - public String checkParameters() { - return null; - } + public String getDescription() { return "Cartesian Product"; } @Override - public String getCategory() { - return "Products"; - } + protected GProduct createProduct() { return new GCartesianProduct(); } } diff --git a/src/graphtea/extensions/actions/product/GCartesianProduct.java b/src/graphtea/extensions/actions/product/GCartesianProduct.java index 82ced2fe..e4ccdbd0 100755 --- a/src/graphtea/extensions/actions/product/GCartesianProduct.java +++ b/src/graphtea/extensions/actions/product/GCartesianProduct.java @@ -1,28 +1,18 @@ package graphtea.extensions.actions.product; -import graphtea.graph.graph.GPoint; import graphtea.graph.graph.GraphModel; import graphtea.graph.graph.Vertex; -import graphtea.plugins.graphgenerator.core.PositionGenerators; public class GCartesianProduct extends GProduct { @Override public boolean compare(Vertex v1OfFirstG, Vertex v2OfFirstG, Vertex v1OfSecondG, Vertex v2OfSecondG) { - return (v1OfFirstG == v2OfFirstG - && g2.isEdge(v1OfSecondG, v2OfSecondG)) - || (v1OfSecondG == v2OfSecondG - && g1.isEdge(v1OfFirstG, v2OfFirstG)); + return (v1OfFirstG == v2OfFirstG && g2.isEdge(v1OfSecondG, v2OfSecondG)) + || (v1OfSecondG == v2OfSecondG && g1.isEdge(v1OfFirstG, v2OfFirstG)); } @Override public void setPositions(GraphModel g) { - int n = g.getVerticesCount(); - GPoint[] ps = PositionGenerators.circle(250, 300, 300, n); setProductLabel(g); - int count = 0; - for (Vertex v : g) { - v.setLocation(new GPoint(ps[count].x, ps[count].y)); - count++; - } + setCircularPositions(g, 250); } } diff --git a/src/graphtea/extensions/actions/product/GProduct.java b/src/graphtea/extensions/actions/product/GProduct.java index cc98d81e..2654c552 100755 --- a/src/graphtea/extensions/actions/product/GProduct.java +++ b/src/graphtea/extensions/actions/product/GProduct.java @@ -1,8 +1,10 @@ package graphtea.extensions.actions.product; +import graphtea.graph.graph.GPoint; import graphtea.graph.graph.GraphModel; import graphtea.graph.graph.Vertex; import graphtea.library.util.Pair; +import graphtea.plugins.graphgenerator.core.PositionGenerators; public abstract class GProduct { @@ -40,7 +42,20 @@ public final GraphModel multiply(GraphModel g1, GraphModel g2) { public abstract boolean compare(Vertex v1OfFirstG, Vertex v2OfFirstG, Vertex v1OfSecondG, Vertex v2OfSecondG); - public abstract void setPositions(GraphModel g); + protected void setCircularPositions(GraphModel g, int radius) { + int n = g.getVerticesCount(); + GPoint[] ps = PositionGenerators.circle(radius, 300, 300, n); + int count = 0; + for (Vertex v : g) { + v.setLocation(new GPoint(ps[count].x, ps[count].y)); + count++; + } + } + + public void setPositions(GraphModel g) { + setProductLabel(g); + setCircularPositions(g, 250); + } public void setProductLabel(GraphModel graphModel) { //for(Vertex v:graphModel) v.getSize().multiply(1.5); diff --git a/src/graphtea/extensions/actions/product/GProductAction.java b/src/graphtea/extensions/actions/product/GProductAction.java new file mode 100644 index 00000000..b3ab82f1 --- /dev/null +++ b/src/graphtea/extensions/actions/product/GProductAction.java @@ -0,0 +1,37 @@ +package graphtea.extensions.actions.product; + +import graphtea.graph.graph.GraphModel; +import graphtea.graph.ui.GTabbedGraphPane; +import graphtea.platform.parameter.Parameter; +import graphtea.platform.parameter.Parametrizable; +import graphtea.plugins.main.GraphData; +import graphtea.plugins.main.extension.GraphActionExtension; + +/** + * Abstract base for graph product action extensions. + * Subclasses supply the specific {@link GProduct} via {@link #createProduct()}. + * + * @author M. Ali Rostami + */ +abstract class GProductAction implements GraphActionExtension, Parametrizable { + @Parameter(name = "First Graph", description = "First Graph") + public String g0 = "G0"; + @Parameter(name = "Second Graph", description = "Second Graph") + public String g1 = "G1"; + + protected abstract GProduct createProduct(); + + @Override + public void action(GraphData graphData) { + GTabbedGraphPane gtp = graphData.getBlackboard().getData(GTabbedGraphPane.NAME); + GProduct prod = createProduct(); + GraphModel g = prod.multiply(gtp.getGraphs().get(g0), gtp.getGraphs().get(g1)); + prod.setPositions(g); + graphData.core.showGraph(g); + } + + @Override + public String getCategory() { + return "Products"; + } +} diff --git a/src/graphtea/extensions/actions/product/GStrongProduct.java b/src/graphtea/extensions/actions/product/GStrongProduct.java index 2c5e5618..e1ac400c 100755 --- a/src/graphtea/extensions/actions/product/GStrongProduct.java +++ b/src/graphtea/extensions/actions/product/GStrongProduct.java @@ -1,29 +1,19 @@ package graphtea.extensions.actions.product; -import graphtea.graph.graph.GPoint; import graphtea.graph.graph.GraphModel; import graphtea.graph.graph.Vertex; -import graphtea.plugins.graphgenerator.core.PositionGenerators; public class GStrongProduct extends GProduct { @Override public boolean compare(Vertex v1OfFirstG, Vertex v2OfFirstG, Vertex v1OfSecondG, Vertex v2OfSecondG) { - return (v1OfFirstG == v2OfFirstG - && g2.isEdge(v1OfSecondG, v2OfSecondG)) - || (v1OfSecondG == v2OfSecondG - && g1.isEdge(v1OfFirstG, v2OfFirstG)) || - (g1.isEdge(v1OfFirstG, v2OfFirstG) && g2.isEdge(v1OfSecondG, v2OfSecondG)); + return (v1OfFirstG == v2OfFirstG && g2.isEdge(v1OfSecondG, v2OfSecondG)) + || (v1OfSecondG == v2OfSecondG && g1.isEdge(v1OfFirstG, v2OfFirstG)) + || (g1.isEdge(v1OfFirstG, v2OfFirstG) && g2.isEdge(v1OfSecondG, v2OfSecondG)); } @Override public void setPositions(GraphModel g) { - int n = g.getVerticesCount(); - GPoint[] ps = PositionGenerators.circle(250, 300, 300, n); setProductLabel(g); - int count = 0; - for (Vertex v : g) { - v.setLocation(new GPoint(ps[count].x, ps[count].y)); - count++; - } + setCircularPositions(g, 250); } } diff --git a/src/graphtea/extensions/actions/product/GSymmDiff.java b/src/graphtea/extensions/actions/product/GSymmDiff.java index b1a01db7..1568eb77 100755 --- a/src/graphtea/extensions/actions/product/GSymmDiff.java +++ b/src/graphtea/extensions/actions/product/GSymmDiff.java @@ -1,27 +1,17 @@ package graphtea.extensions.actions.product; -import graphtea.graph.graph.GPoint; import graphtea.graph.graph.GraphModel; import graphtea.graph.graph.Vertex; -import graphtea.plugins.graphgenerator.core.PositionGenerators; public class GSymmDiff extends GProduct { @Override public boolean compare(Vertex v1OfFirstG, Vertex v2OfFirstG, Vertex v1OfSecondG, Vertex v2OfSecondG) { - return (g1.isEdge(v1OfFirstG, v2OfFirstG) - && !g2.isEdge(v1OfSecondG, v2OfSecondG)) || - (!g1.isEdge(v1OfFirstG, v2OfFirstG) - && g2.isEdge(v1OfSecondG, v2OfSecondG)); + return (g1.isEdge(v1OfFirstG, v2OfFirstG) && !g2.isEdge(v1OfSecondG, v2OfSecondG)) + || (!g1.isEdge(v1OfFirstG, v2OfFirstG) && g2.isEdge(v1OfSecondG, v2OfSecondG)); } @Override public void setPositions(GraphModel g) { - int n = g.getVerticesCount(); - GPoint[] ps = PositionGenerators.circle(200, 300, 300, n); - int count = 0; - for (Vertex v : g) { - v.setLocation(new GPoint(ps[count].x, ps[count].y)); - count++; - } + setCircularPositions(g, 200); } } diff --git a/src/graphtea/extensions/actions/product/GTensorProduct.java b/src/graphtea/extensions/actions/product/GTensorProduct.java index 579a08ee..805ab5d9 100755 --- a/src/graphtea/extensions/actions/product/GTensorProduct.java +++ b/src/graphtea/extensions/actions/product/GTensorProduct.java @@ -1,9 +1,7 @@ package graphtea.extensions.actions.product; -import graphtea.graph.graph.GPoint; import graphtea.graph.graph.GraphModel; import graphtea.graph.graph.Vertex; -import graphtea.plugins.graphgenerator.core.PositionGenerators; public class GTensorProduct extends GProduct { @Override @@ -13,14 +11,8 @@ public boolean compare(Vertex v1OfFirstG, Vertex v2OfFirstG, Vertex v1OfSecondG, @Override public void setPositions(GraphModel g) { - setProductLabel(g); g.setDirected(g1.isDirected()); - int n = g.getVerticesCount(); - GPoint[] ps = PositionGenerators.circle(250, 300, 300, n); - int count = 0; - for (Vertex v : g) { - v.setLocation(new GPoint(ps[count].x, ps[count].y)); - count++; - } + setProductLabel(g); + setCircularPositions(g, 250); } } diff --git a/src/graphtea/extensions/actions/product/StrongProduct.java b/src/graphtea/extensions/actions/product/StrongProduct.java index 167c27d5..d01e65f6 100755 --- a/src/graphtea/extensions/actions/product/StrongProduct.java +++ b/src/graphtea/extensions/actions/product/StrongProduct.java @@ -1,48 +1,15 @@ package graphtea.extensions.actions.product; -import graphtea.graph.graph.GraphModel; -import graphtea.graph.ui.GTabbedGraphPane; -import graphtea.platform.parameter.Parameter; -import graphtea.platform.parameter.Parametrizable; -import graphtea.plugins.main.GraphData; -import graphtea.plugins.main.extension.GraphActionExtension; - /** - * Created by rostam on 10.07.15. * @author M. Ali Rostami */ -public class StrongProduct implements GraphActionExtension, Parametrizable { - @Parameter(name = "First Graph",description = "First Graph") - public String g0 = "G0"; - @Parameter(name = "Second Graph",description = "Second Graph") - public String g1 = "G1"; - - @Override - public String getName() { - return "Strong Product"; - } - - @Override - public String getDescription() { - return "Strong Product"; - } - +public class StrongProduct extends GProductAction { @Override - public void action(GraphData graphData) { - GTabbedGraphPane gtp = graphData.getBlackboard().getData(GTabbedGraphPane.NAME); - GStrongProduct prod = new GStrongProduct(); - GraphModel g= prod.multiply(gtp.getGraphs().get(g0), gtp.getGraphs().get(g1)); - prod.setPositions(g); - graphData.core.showGraph(g); - } + public String getName() { return "Strong Product"; } @Override - public String checkParameters() { - return null; - } + public String getDescription() { return "Strong Product"; } @Override - public String getCategory() { - return "Products"; - } + protected GProduct createProduct() { return new GStrongProduct(); } } diff --git a/src/graphtea/extensions/actions/product/SymDiff.java b/src/graphtea/extensions/actions/product/SymDiff.java index ad8b353a..1ebea819 100755 --- a/src/graphtea/extensions/actions/product/SymDiff.java +++ b/src/graphtea/extensions/actions/product/SymDiff.java @@ -1,49 +1,15 @@ package graphtea.extensions.actions.product; -import graphtea.graph.graph.GraphModel; -import graphtea.graph.ui.GTabbedGraphPane; -import graphtea.platform.parameter.Parameter; -import graphtea.platform.parameter.Parametrizable; -import graphtea.plugins.main.GraphData; -import graphtea.plugins.main.extension.GraphActionExtension; - /** - * Created by rostam on 10.07.15. * @author M. Ali Rostami */ -public class SymDiff implements GraphActionExtension, Parametrizable { - @Parameter(name = "First Graph",description = "First Graph") - public String g0 = "G0"; - @Parameter(name = "Second Graph",description = "Second Graph") - public String g1 = "G1"; - - @Override - public String getName() { - return "Symmetric Difference"; - } - - @Override - public String getDescription() { - return "Symmetric Difference"; - } - +public class SymDiff extends GProductAction { @Override - public void action(GraphData graphData) { - GTabbedGraphPane gtp = graphData.getBlackboard().getData(GTabbedGraphPane.NAME); - GSymmDiff prod = new GSymmDiff(); - GraphModel g= prod.multiply(gtp.getGraphs().get(g0), - gtp.getGraphs().get(g1)); - prod.setPositions(g); - graphData.core.showGraph(g); - } + public String getName() { return "Symmetric Difference"; } @Override - public String checkParameters() { - return null; - } + public String getDescription() { return "Symmetric Difference"; } @Override - public String getCategory() { - return "Products"; - } + protected GProduct createProduct() { return new GSymmDiff(); } } diff --git a/src/graphtea/extensions/actions/product/TensorProduct.java b/src/graphtea/extensions/actions/product/TensorProduct.java index 8e12817c..9a856fe1 100755 --- a/src/graphtea/extensions/actions/product/TensorProduct.java +++ b/src/graphtea/extensions/actions/product/TensorProduct.java @@ -1,49 +1,15 @@ package graphtea.extensions.actions.product; -import graphtea.graph.graph.GraphModel; -import graphtea.graph.ui.GTabbedGraphPane; -import graphtea.platform.parameter.Parameter; -import graphtea.platform.parameter.Parametrizable; -import graphtea.plugins.main.GraphData; -import graphtea.plugins.main.extension.GraphActionExtension; - /** - * Created by rostam on 10.07.15. * @author M. Ali Rostami */ -public class TensorProduct implements GraphActionExtension, Parametrizable { - @Parameter(description = "First Graph") - public String g0 = "G0"; - @Parameter(description = "Second Graph") - public String g1 = "G1"; - - @Override - public String getName() { - return "Tensor Product"; - } - - @Override - public String getDescription() { - return "Tensor Product"; - } - +public class TensorProduct extends GProductAction { @Override - public void action(GraphData graphData) { - GTabbedGraphPane gtp = graphData.getBlackboard().getData(GTabbedGraphPane.NAME); - GTensorProduct tensor = new GTensorProduct(); - GraphModel g= tensor.multiply(gtp.getGraphs().get(g0), - gtp.getGraphs().get(g1)); - tensor.setPositions(g); - graphData.core.showGraph(g); - } + public String getName() { return "Tensor Product"; } @Override - public String checkParameters() { - return null; - } + public String getDescription() { return "Tensor Product"; } @Override - public String getCategory() { - return "Products"; - } + protected GProduct createProduct() { return new GTensorProduct(); } } diff --git a/src/graphtea/extensions/io/GraphSaveObject.java b/src/graphtea/extensions/io/GraphSaveObject.java index a47a9427..b90492ba 100755 --- a/src/graphtea/extensions/io/GraphSaveObject.java +++ b/src/graphtea/extensions/io/GraphSaveObject.java @@ -5,9 +5,9 @@ import graphtea.graph.graph.GraphModel; import graphtea.graph.graph.Vertex; -import javax.xml.bind.DatatypeConverter; import java.io.*; -import java.util.Vector; +import java.util.ArrayList; +import java.util.Base64; /** * Created by rostam on 18.12.15. @@ -22,8 +22,8 @@ public boolean equals(Object obj) { } else return false; } - public Vector vs = new Vector<>(); - Vector es = new Vector<>(); + public ArrayList vs = new ArrayList<>(); + ArrayList es = new ArrayList<>(); boolean directed = false; String label = ""; public GraphSaveObject(GraphModel g) { @@ -71,15 +71,15 @@ public static byte[] getBytesOfGraphSaveObject(GraphSaveObject gso) { } public static String graph2String(GraphModel g){ - return DatatypeConverter.printBase64Binary(getBytesOfGraph(g)); + return Base64.getMimeEncoder().encodeToString(getBytesOfGraph(g)); } public static GraphModel String2Graph(String s){ - return getGraphFromBytes(DatatypeConverter.parseBase64Binary(s)); + return getGraphFromBytes(Base64.getMimeDecoder().decode(s)); } public static GraphSaveObject string2GraphSaveObject(String s){ - return getGraphSaveOobjectfromBytes(DatatypeConverter.parseBase64Binary(s)); + return getGraphSaveOobjectfromBytes(Base64.getMimeDecoder().decode(s)); } public static GraphSaveObject getGraphSaveOobjectfromBytes(byte[] b){ diff --git a/src/graphtea/extensions/reports/others/EdgePartitionIndexBase.java b/src/graphtea/extensions/reports/others/EdgePartitionIndexBase.java new file mode 100644 index 00000000..35547e2c --- /dev/null +++ b/src/graphtea/extensions/reports/others/EdgePartitionIndexBase.java @@ -0,0 +1,50 @@ +// 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.extensions.reports.others; + +import graphtea.extensions.algorithms.shortestpath.algs.FloydWarshall; +import graphtea.graph.graph.Edge; +import graphtea.graph.graph.GraphModel; + +/** + * Shared computation for edge-partition topological indices (Szeged, PI, Mostar, …). + * + * For each edge (u,v) the Floyd-Warshall distance matrix is used to partition + * vertices into three sets: + *
    + *
  • nu — vertices strictly closer to u
  • + *
  • nv — vertices strictly closer to v
  • + *
  • nequal — vertices equidistant from u and v
  • + *
+ * Subclasses supply the per-edge contribution formula via {@link Contribution}. + */ +class EdgePartitionIndexBase { + + @FunctionalInterface + interface Contribution { + double of(GraphModel g, Edge e, int nu, int nv, int nequal); + } + + static double sum(GraphModel g, Contribution fn) { + int[][] dists = new FloydWarshall().getAllPairsShortestPathWithoutWeight(g); + double total = 0; + for (Edge e : g.getEdges()) { + int u = e.source.getId(); + int v = e.target.getId(); + int nu = 0, nv = 0, nequal = 0; + for (int i = 0; i < dists[0].length; i++) { + if (dists[u][i] > dists[v][i]) { + nu++; + } else if (dists[u][i] < dists[v][i]) { + nv++; + } else { + nequal++; + } + } + total += fn.of(g, e, nu, nv, nequal); + } + return total; + } +} diff --git a/src/graphtea/extensions/reports/others/MostarIndex.java b/src/graphtea/extensions/reports/others/MostarIndex.java index 60bb9adc..d065dfe5 100755 --- a/src/graphtea/extensions/reports/others/MostarIndex.java +++ b/src/graphtea/extensions/reports/others/MostarIndex.java @@ -4,8 +4,6 @@ // Distributed under the terms of the GNU General Public License (GPL): http://www.gnu.org/licenses/ package graphtea.extensions.reports.others; -import graphtea.extensions.algorithms.shortestpath.algs.FloydWarshall; -import graphtea.graph.graph.Edge; import graphtea.graph.graph.GraphModel; import graphtea.platform.lang.CommandAttitude; import graphtea.plugins.reports.extension.GraphReportExtension; @@ -13,36 +11,13 @@ /** * @author Ali Rostami */ - @CommandAttitude(name = "mostar_index", abbreviation = "_windex") public class MostarIndex implements GraphReportExtension { - public String getName() { - return "Mostar Index"; - } - - public String getDescription() { - return "Mostar Index"; - } + public String getName() { return "Mostar Index"; } + public String getDescription() { return "Mostar Index"; } + public String getCategory() { return "Topological Indices-Degree Based"; } public Integer calculate(GraphModel g) { - FloydWarshall fw = new FloydWarshall(); - int[][] dists = fw.getAllPairsShortestPathWithoutWeight(g); - int sum = 0; - for(Edge e : g.getEdges()) { - int u = e.source.getId(); - int v = e.target.getId(); - int nu = 0, nv = 0; - for(int i=0;i dists[v][i]) nu++; - if(dists[u][i] < dists[v][i]) nv++; - } - sum += Math.abs(nu - nv); - } - return sum; + return (int) EdgePartitionIndexBase.sum(g, (graph, e, nu, nv, nequal) -> Math.abs(nu - nv)); } - - @Override - public String getCategory() { - return "Topological Indices-Degree Based"; - } } diff --git a/src/graphtea/extensions/reports/others/PiIndex.java b/src/graphtea/extensions/reports/others/PiIndex.java index 48c0b915..52cfc415 100755 --- a/src/graphtea/extensions/reports/others/PiIndex.java +++ b/src/graphtea/extensions/reports/others/PiIndex.java @@ -4,47 +4,20 @@ // Distributed under the terms of the GNU General Public License (GPL): http://www.gnu.org/licenses/ package graphtea.extensions.reports.others; -import graphtea.extensions.algorithms.shortestpath.algs.FloydWarshall; -import graphtea.graph.graph.Edge; import graphtea.graph.graph.GraphModel; import graphtea.platform.lang.CommandAttitude; import graphtea.plugins.reports.extension.GraphReportExtension; /** * @author Ali Rostami - */ - - @CommandAttitude(name = "PI_Index", abbreviation = "_SzegedIndex") public class PiIndex implements GraphReportExtension { - public String getName() { - return "PI Index"; - } - - public String getDescription() { - return "PI Index"; - } + public String getName() { return "PI Index"; } + public String getDescription() { return "PI Index"; } + public String getCategory() { return "Topological Indices-Distance"; } public Integer calculate(GraphModel g) { - FloydWarshall fw = new FloydWarshall(); - int[][] dists = fw.getAllPairsShortestPathWithoutWeight(g); - int sum = 0; - for(Edge e : g.getEdges()) { - int u = e.source.getId(); - int v = e.target.getId(); - int nu = 0, nv = 0; - for(int i=0;i dists[v][i]) nu++; - if(dists[u][i] < dists[v][i]) nv++; - } - sum += nu + nv; - } - return sum; + return (int) EdgePartitionIndexBase.sum(g, (graph, e, nu, nv, nequal) -> nu + nv); } - - @Override - public String getCategory() { - return "Topological Indices-Distance"; - } } diff --git a/src/graphtea/extensions/reports/others/RevisedSzegedIndex.java b/src/graphtea/extensions/reports/others/RevisedSzegedIndex.java index 8b398ed3..6667f406 100755 --- a/src/graphtea/extensions/reports/others/RevisedSzegedIndex.java +++ b/src/graphtea/extensions/reports/others/RevisedSzegedIndex.java @@ -4,49 +4,21 @@ // Distributed under the terms of the GNU General Public License (GPL): http://www.gnu.org/licenses/ package graphtea.extensions.reports.others; -import graphtea.extensions.algorithms.shortestpath.algs.FloydWarshall; -import graphtea.graph.graph.Edge; import graphtea.graph.graph.GraphModel; import graphtea.platform.lang.CommandAttitude; import graphtea.plugins.reports.extension.GraphReportExtension; /** * @author Ali Rostami - */ - - @CommandAttitude(name = "revised_szeged_index", abbreviation = "_RevisedSzegedIndex") public class RevisedSzegedIndex implements GraphReportExtension { - public String getName() { - return "Revised Szeged Index"; - } - - public String getDescription() { - return "Revised Szeged Index"; - } + public String getName() { return "Revised Szeged Index"; } + public String getDescription() { return "Revised Szeged Index"; } + public String getCategory() { return "Topological Indices-Distance"; } public Double calculate(GraphModel g) { - FloydWarshall fw = new FloydWarshall(); - int[][] dists = fw.getAllPairsShortestPathWithoutWeight(g); - double sum = 0; - for (Edge e : g.getEdges()) { - int u = e.source.getId(); - int v = e.target.getId(); - int nu = 0, nv = 0, nequal = 0; - for (int i = 0; i < dists[0].length; i++) { - if (dists[u][i] > dists[v][i]) nu++; - if (dists[u][i] < dists[v][i]) nv++; - if (dists[u][i] == dists[v][i]) nequal++; - } - - sum += (nu + (nequal / 2.)) * (nv + (nequal / 2.)); - } - return sum; + return EdgePartitionIndexBase.sum(g, + (graph, e, nu, nv, nequal) -> (nu + nequal / 2.0) * (nv + nequal / 2.0)); } - - @Override - public String getCategory() { - return "Topological Indices-Distance"; - } } diff --git a/src/graphtea/extensions/reports/others/SzegedIndex.java b/src/graphtea/extensions/reports/others/SzegedIndex.java index 09a24dda..c99480b2 100755 --- a/src/graphtea/extensions/reports/others/SzegedIndex.java +++ b/src/graphtea/extensions/reports/others/SzegedIndex.java @@ -4,47 +4,20 @@ // Distributed under the terms of the GNU General Public License (GPL): http://www.gnu.org/licenses/ package graphtea.extensions.reports.others; -import graphtea.extensions.algorithms.shortestpath.algs.FloydWarshall; -import graphtea.graph.graph.Edge; import graphtea.graph.graph.GraphModel; import graphtea.platform.lang.CommandAttitude; import graphtea.plugins.reports.extension.GraphReportExtension; /** * @author Ali Rostami - */ - - @CommandAttitude(name = "szeged_index", abbreviation = "_SzegedIndex") public class SzegedIndex implements GraphReportExtension { - public String getName() { - return "Szeged Index"; - } - - public String getDescription() { - return "Szeged Index"; - } + public String getName() { return "Szeged Index"; } + public String getDescription() { return "Szeged Index"; } + public String getCategory() { return "Topological Indices-Distance"; } public Integer calculate(GraphModel g) { - FloydWarshall fw = new FloydWarshall(); - int[][] dists = fw.getAllPairsShortestPathWithoutWeight(g); - int sum = 0; - for(Edge e : g.getEdges()) { - int u = e.source.getId(); - int v = e.target.getId(); - int nu = 0, nv = 0; - for(int i=0;i dists[v][i]) nu++; - if(dists[u][i] < dists[v][i]) nv++; - } - sum += nu * nv; - } - return sum; + return (int) EdgePartitionIndexBase.sum(g, (graph, e, nu, nv, nequal) -> nu * nv); } - - @Override - public String getCategory() { - return "Topological Indices-Distance"; - } } diff --git a/src/graphtea/extensions/reports/others/WeightedPiIndex.java b/src/graphtea/extensions/reports/others/WeightedPiIndex.java index dde3c453..6519fef0 100755 --- a/src/graphtea/extensions/reports/others/WeightedPiIndex.java +++ b/src/graphtea/extensions/reports/others/WeightedPiIndex.java @@ -4,50 +4,23 @@ // Distributed under the terms of the GNU General Public License (GPL): http://www.gnu.org/licenses/ package graphtea.extensions.reports.others; -import graphtea.extensions.algorithms.shortestpath.algs.FloydWarshall; -import graphtea.graph.graph.Edge; import graphtea.graph.graph.GraphModel; import graphtea.platform.lang.CommandAttitude; import graphtea.plugins.reports.extension.GraphReportExtension; /** * @author Ali Rostami - */ - - @CommandAttitude(name = "Weighted_PI_Index", abbreviation = "_Weighted PI Index") public class WeightedPiIndex implements GraphReportExtension { - public String getName() { - return "Weighted PI Index"; - } - - public String getDescription() { - return "Weighted PI Index"; - } - + public String getName() { return "Weighted PI Index"; } + public String getDescription() { return "Weighted PI Index"; } + public String getCategory() { return "Topological Indices-Distance"; } public Integer calculate(GraphModel g) { - FloydWarshall fw = new FloydWarshall(); - int[][] dists = fw.getAllPairsShortestPathWithoutWeight(g); - int sum = 0; - for(Edge e : g.getEdges()) { - int u = e.source.getId(); - int v = e.target.getId(); - int nu = 0, nv = 0; - for(int i=0;i dists[v][i]) nu++; - if(dists[u][i] < dists[v][i]) nv++; - } - int degreeOfU = g.getDegree(g.getVertex(u)); - int degreeOfV = g.getDegree(g.getVertex(v)); - sum += (degreeOfU + degreeOfV)* (nu + nv); - } - return sum; + return (int) EdgePartitionIndexBase.sum(g, (graph, e, nu, nv, nequal) -> { + int degSum = graph.getDegree(e.source) + graph.getDegree(e.target); + return degSum * (nu + nv); + }); } - - @Override - public String getCategory() { - return "Topological Indices-Distance"; - } } diff --git a/src/graphtea/extensions/reports/others/WeightedSzegedIndex.java b/src/graphtea/extensions/reports/others/WeightedSzegedIndex.java index ab839db1..a21444ae 100755 --- a/src/graphtea/extensions/reports/others/WeightedSzegedIndex.java +++ b/src/graphtea/extensions/reports/others/WeightedSzegedIndex.java @@ -4,50 +4,23 @@ // Distributed under the terms of the GNU General Public License (GPL): http://www.gnu.org/licenses/ package graphtea.extensions.reports.others; -import graphtea.extensions.algorithms.shortestpath.algs.FloydWarshall; -import graphtea.graph.graph.Edge; import graphtea.graph.graph.GraphModel; import graphtea.platform.lang.CommandAttitude; import graphtea.plugins.reports.extension.GraphReportExtension; /** * @author Ali Rostami - */ - - @CommandAttitude(name = "Weighted_Szeged_Index", abbreviation = "_Weighted Szeged Index") public class WeightedSzegedIndex implements GraphReportExtension { - public String getName() { - return "Weighted Szeged Index"; - } - - public String getDescription() { - return "Weighted Szeged Index"; - } - + public String getName() { return "Weighted Szeged Index"; } + public String getDescription() { return "Weighted Szeged Index"; } + public String getCategory() { return "Topological Indices-Distance"; } public Integer calculate(GraphModel g) { - FloydWarshall fw = new FloydWarshall(); - int[][] dists = fw.getAllPairsShortestPathWithoutWeight(g); - int sum = 0; - for(Edge e : g.getEdges()) { - int u = e.source.getId(); - int v = e.target.getId(); - int nu = 0, nv = 0; - for(int i=0;i dists[v][i]) nu++; - if(dists[u][i] < dists[v][i]) nv++; - } - int degreeOfU = g.getDegree(g.getVertex(u)); - int degreeOfV = g.getDegree(g.getVertex(v)); - sum += (degreeOfU + degreeOfV)* nu * nv; - } - return sum; + return (int) EdgePartitionIndexBase.sum(g, (graph, e, nu, nv, nequal) -> { + int degSum = graph.getDegree(e.source) + graph.getDegree(e.target); + return degSum * nu * nv; + }); } - - @Override - public String getCategory() { - return "Topological Indices-Distance"; - } } diff --git a/src/graphtea/extensions/reports/spectralreports/DistanceEnergy.java b/src/graphtea/extensions/reports/spectralreports/DistanceEnergy.java index db6c0317..9862c99c 100755 --- a/src/graphtea/extensions/reports/spectralreports/DistanceEnergy.java +++ b/src/graphtea/extensions/reports/spectralreports/DistanceEnergy.java @@ -5,8 +5,6 @@ package graphtea.extensions.reports.spectralreports; -import Jama.EigenvalueDecomposition; -import Jama.Matrix; import graphtea.extensions.AlgorithmUtils; import graphtea.graph.graph.GraphModel; import graphtea.platform.lang.CommandAttitude; @@ -15,35 +13,13 @@ /** * @author M. Ali Rostami */ - @CommandAttitude(name = "distance_energy", abbreviation = "_distener") public class DistanceEnergy implements GraphReportExtension { - public Double calculate(GraphModel g) { - Matrix m = AlgorithmUtils.getDistanceAdjacencyMatrix(g); - EigenvalueDecomposition ed = m.eig(); - double[] rv = ed.getRealEigenvalues(); - double sum = 0; + public String getName() { return "Distance Energy"; } + public String getDescription() { return "Distance Energy"; } + public String getCategory() { return "Spectral- Energies"; } - //positive RV - Double[] prv = new Double[rv.length]; - for (int i = 0; i < rv.length; i++) { - prv[i] = Math.abs(rv[i]); - // prv[i] = (double)Math.round(prv[i] * 100000d) / 100000d; - sum += prv[i]; - } - return sum; - } - - public String getName() { - return "Distance Energy"; - } - - public String getDescription() { - return "Distance Energy"; - } - - @Override - public String getCategory() { - return "Spectral- Energies"; + public Double calculate(GraphModel g) { + return AlgorithmUtils.spectralEnergy(AlgorithmUtils.getDistanceAdjacencyMatrix(g), 0); } } diff --git a/src/graphtea/extensions/reports/spectralreports/DistanceLaplacianEnergy.java b/src/graphtea/extensions/reports/spectralreports/DistanceLaplacianEnergy.java index 9f52c2ce..51905c3c 100755 --- a/src/graphtea/extensions/reports/spectralreports/DistanceLaplacianEnergy.java +++ b/src/graphtea/extensions/reports/spectralreports/DistanceLaplacianEnergy.java @@ -1,4 +1,3 @@ - // 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 @@ -6,8 +5,6 @@ package graphtea.extensions.reports.spectralreports; -import Jama.EigenvalueDecomposition; -import Jama.Matrix; import graphtea.extensions.AlgorithmUtils; import graphtea.graph.graph.GraphModel; import graphtea.platform.lang.CommandAttitude; @@ -16,37 +13,14 @@ /** * @author M. Ali Rostami */ - @CommandAttitude(name = "distance_laplacian_energy", abbreviation = "_distener") public class DistanceLaplacianEnergy implements GraphReportExtension { - public Double calculate(GraphModel g) { - Matrix m = AlgorithmUtils.getDistanceLaplacianMatrix(g); - double n = g.getVerticesCount(); - double t = new AvgTransmission().calculate(g); - EigenvalueDecomposition ed = m.eig(); - double[] rv = ed.getRealEigenvalues(); - double sum = 0; - - //positiv RV - Double[] prv = new Double[rv.length]; - for (int i = 0; i < rv.length; i++) { - prv[i] = Math.abs(rv[i]-t); - // prv[i] = (double)Math.round(prv[i] * 100000d) / 100000d; - sum += prv[i]; - } - return sum; - } + public String getName() { return "Distance Laplacian Energy"; } + public String getDescription() { return "Distance Laplacian Energy"; } + public String getCategory() { return "Spectral- Energies"; } - public String getName() { - return "Distance Laplacian Energy"; - } - - public String getDescription() { - return "Distance Laplacian Energy"; - } - - @Override - public String getCategory() { - return "Spectral- Energies"; + public Double calculate(GraphModel g) { + double t = new AvgTransmission().calculate(g); + return AlgorithmUtils.spectralEnergy(AlgorithmUtils.getDistanceLaplacianMatrix(g), t); } } diff --git a/src/graphtea/extensions/reports/spectralreports/DistanceSignlessLaplacianEnergy.java b/src/graphtea/extensions/reports/spectralreports/DistanceSignlessLaplacianEnergy.java index 1eddcdbb..ef105221 100755 --- a/src/graphtea/extensions/reports/spectralreports/DistanceSignlessLaplacianEnergy.java +++ b/src/graphtea/extensions/reports/spectralreports/DistanceSignlessLaplacianEnergy.java @@ -1,4 +1,3 @@ - // 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 @@ -6,8 +5,6 @@ package graphtea.extensions.reports.spectralreports; -import Jama.EigenvalueDecomposition; -import Jama.Matrix; import graphtea.extensions.AlgorithmUtils; import graphtea.graph.graph.GraphModel; import graphtea.platform.lang.CommandAttitude; @@ -16,37 +13,14 @@ /** * @author M. Ali Rostami */ - @CommandAttitude(name = "distance_signless_laplacian_energy", abbreviation = "_distener") public class DistanceSignlessLaplacianEnergy implements GraphReportExtension { - public Double calculate(GraphModel g) { - Matrix m = AlgorithmUtils.getDistanceSignlessLaplacianMatrix(g); - double n = g.getVerticesCount(); - double t = new AvgTransmission().calculate(g); - EigenvalueDecomposition ed = m.eig(); - double[] rv = ed.getRealEigenvalues(); - double sum = 0; - - //positiv RV - Double[] prv = new Double[rv.length]; - for (int i = 0; i < rv.length; i++) { - prv[i] = Math.abs(rv[i]-t); - // prv[i] = (double)Math.round(prv[i] * 100000d) / 100000d; - sum += prv[i]; - } - return sum; - } + public String getName() { return "Distance Signless Laplacian Energy"; } + public String getDescription() { return "Distance Signless Laplacian Energy"; } + public String getCategory() { return "Spectral- Energies"; } - public String getName() { - return "Distance Signless Laplacian Energy"; - } - - public String getDescription() { - return "Distance Signless Laplacian Energy"; - } - - @Override - public String getCategory() { - return "Spectral- Energies"; + public Double calculate(GraphModel g) { + double t = new AvgTransmission().calculate(g); + return AlgorithmUtils.spectralEnergy(AlgorithmUtils.getDistanceSignlessLaplacianMatrix(g), t); } } diff --git a/src/graphtea/extensions/reports/spectralreports/TransmissionEnergy.java b/src/graphtea/extensions/reports/spectralreports/TransmissionEnergy.java index 4960f7c8..36d0727c 100755 --- a/src/graphtea/extensions/reports/spectralreports/TransmissionEnergy.java +++ b/src/graphtea/extensions/reports/spectralreports/TransmissionEnergy.java @@ -5,8 +5,6 @@ package graphtea.extensions.reports.spectralreports; -import Jama.EigenvalueDecomposition; -import Jama.Matrix; import graphtea.extensions.AlgorithmUtils; import graphtea.graph.graph.GraphModel; import graphtea.platform.lang.CommandAttitude; @@ -15,35 +13,13 @@ /** * @author M. Ali Rostami */ - @CommandAttitude(name = "transmission_energy", abbreviation = "_transener") public class TransmissionEnergy implements GraphReportExtension { - public Double calculate(GraphModel g) { - Matrix m = AlgorithmUtils.getDiagonalTransMatrix(g); - EigenvalueDecomposition ed = m.eig(); - double[] rv = ed.getRealEigenvalues(); - double sum = 0; + public String getName() { return "Transmission Energy"; } + public String getDescription() { return "Transmission Energy"; } + public String getCategory() { return "Spectral- Energies"; } - //positiv RV - Double[] prv = new Double[rv.length]; - for (int i = 0; i < rv.length; i++) { - prv[i] = Math.abs(rv[i]); - // prv[i] = (double)Math.round(prv[i] * 100000d) / 100000d; - sum += prv[i]; - } - return sum; - } - - public String getName() { - return "Transmission Energy"; - } - - public String getDescription() { - return "Transmission Energy"; - } - - @Override - public String getCategory() { - return "Spectral- Energies"; + public Double calculate(GraphModel g) { + return AlgorithmUtils.spectralEnergy(AlgorithmUtils.getDiagonalTransMatrix(g), 0); } } diff --git a/src/graphtea/graph/old/ArrowHandler.java b/src/graphtea/graph/old/ArrowHandler.java index aee39d24..682db7f9 100755 --- a/src/graphtea/graph/old/ArrowHandler.java +++ b/src/graphtea/graph/old/ArrowHandler.java @@ -106,8 +106,8 @@ public GraphPreferences GraphPrefFactory() { return new GraphPreferences(this.getClass().getSimpleName(), this, "Graph Drawings"); } - public HashMap defineEligibleValuesForSettings(HashMap objectValues) { - ArrayX t = new ArrayX(3); + public HashMap> defineEligibleValuesForSettings(HashMap> objectValues) { + ArrayX t = new ArrayX<>(3); t.addValidValue(10); t.addValidValue(20); t.addValidValue(30); diff --git a/src/graphtea/platform/StaticUtils.java b/src/graphtea/platform/StaticUtils.java index d1e0a6d8..12f1d522 100755 --- a/src/graphtea/platform/StaticUtils.java +++ b/src/graphtea/platform/StaticUtils.java @@ -17,7 +17,6 @@ import java.io.*; import java.math.BigDecimal; import java.math.BigInteger; -import java.util.Arrays; import java.util.HashMap; import java.util.Scanner; import java.util.jar.JarEntry; @@ -265,44 +264,11 @@ public static boolean isImplementing(Class cl, Class inter) { } public static void browse(String url) { - BareBonesBrowserLaunch.openURL(url); - } -} - -class BareBonesBrowserLaunch { - private static final String[] browsers = {"google-chrome", "firefox", "opera", - "epiphany", "konqueror", "conkeror", "midori", "kazehakase", "mozilla"}; - static final String errMsg = "Error attempting to launch web browser"; - - static void openURL(String url) { - try { //attempt to use Desktop library from JDK 1.6+ - Class d = Class.forName("java.awt.Desktop"); - d.getDeclaredMethod("browse", new Class[]{java.net.URI.class}).invoke( - d.getDeclaredMethod("getDesktop").invoke(null), java.net.URI.create(url)); - //above code mimicks: java.awt.Desktop.getDesktop().browse() - } catch (Exception ignore) { //library not available or failed - String osName = System.getProperty("os.name"); - try { - if (osName.startsWith("Mac OS")) { - Class.forName("com.apple.eio.FileManager").getDeclaredMethod( - "openURL", new Class[]{String.class}).invoke(null, url); - } else if (osName.startsWith("Windows")) - Runtime.getRuntime().exec( - "rundll32 url.dll,FileProtocolHandler " + url); - else { //assume Unix or Linux - String browser = null; - for (String b : browsers) - if (browser == null && Runtime.getRuntime().exec(new String[] - {"which", b}).getInputStream().read() != -1) - Runtime.getRuntime().exec(new String[]{browser = b, url}); - if (browser == null) - throw new Exception(Arrays.toString(browsers)); - } - } catch (Exception ignored) { - } + try { + Desktop.getDesktop().browse(java.net.URI.create(url)); + } catch (Exception ignored) { } } - } diff --git a/src/graphtea/platform/attribute/NotifiableAttributeSetImpl.java b/src/graphtea/platform/attribute/NotifiableAttributeSetImpl.java index 4f36a78c..999c1429 100755 --- a/src/graphtea/platform/attribute/NotifiableAttributeSetImpl.java +++ b/src/graphtea/platform/attribute/NotifiableAttributeSetImpl.java @@ -19,17 +19,9 @@ public class NotifiableAttributeSetImpl extends AttributeSetImpl implements Noti public void put(String name, Object value) { - if (name == null) { - throw new RuntimeException("key=null" + value); - } - Object old = atr.put(name, value); -// Collection listeners = notifiableAttributeSet.getAttributeListeners(name); + Object old = get(name); + super.put(name, value); fireAttributeChange(getAttributeListeners(), name, old, value); - - } - - public Object get(String name) { - return super.get(name); } public void addAttributeListener(AttributeListener attributeListener) { diff --git a/src/graphtea/platform/extension/ExtensionClassLoader.java b/src/graphtea/platform/extension/ExtensionClassLoader.java index 28a4d199..6c3a7759 100755 --- a/src/graphtea/platform/extension/ExtensionClassLoader.java +++ b/src/graphtea/platform/extension/ExtensionClassLoader.java @@ -4,8 +4,8 @@ // Distributed under the terms of the GNU General Public License (GPL): http://www.gnu.org/licenses/ package graphtea.platform.extension; -import java.util.ArrayList; -import java.util.List; +import java.util.ArrayList; +import java.util.List; import graphtea.platform.StaticUtils; import graphtea.platform.core.exception.ExceptionHandler; @@ -22,7 +22,7 @@ */ public class ExtensionClassLoader extends ClassLoader { public Map classesData = new HashMap<>(); - Map classes = new HashMap<>(); + Map> classes = new HashMap<>(); List unknownFiles = new ArrayList<>(); public static URLClassLoader classLoader; public static ClassLoader cl; @@ -31,7 +31,7 @@ public ExtensionClassLoader(String dirPath) { loadClasses(dirPath); } - public Collection getLoadedClasses() { + public Collection> getLoadedClasses() { return classes.values(); } @@ -60,14 +60,16 @@ private void loadClassFiles(String dir, String pack) { else if (file1.getName().endsWith(".class")) try { String name; - if (pack.length() > 0) + if (pack.length() > 0) { name = pack.substring(1) + "."; - else + } else { name = ""; + } name = name + file1.getName().substring(0, file1.getName().length() - 6); byte[] data = new byte[(int) file1.length()]; - FileInputStream fis = new FileInputStream(file1); - fis.read(data); + try (FileInputStream fis = new FileInputStream(file1)) { + fis.read(data); + } classesData.put(name, data); urls.add(file1.toURI().toURL()); } catch (IOException e) { @@ -85,26 +87,28 @@ private void loadClasses(String dirPath) { // defineClasses(); } - public Class findClass(String name) throws ClassNotFoundException { - Class ret = null; - if (!classesData.containsKey(name)) + public Class findClass(String name) throws ClassNotFoundException { + Class ret = null; + if (!classesData.containsKey(name)) { ret = getParent().loadClass(name); + } if (ret == null && !classes.containsKey(name)) { byte[] data = classesData.get(name); - Class c = defineClass(name, data, 0, data.length); + Class c = defineClass(name, data, 0, data.length); classes.put(name, c); } ret = classes.get(name); - if (ret == null) + if (ret == null) { return classLoader.loadClass(name); - else + } else { return ret; + } } - public Collection getClassesImplementing(Class cl) { - Collection col = new ArrayList<>(); - for (Map.Entry entry1 : classes.entrySet()) { - Class c = entry1.getValue(); + public Collection> getClassesImplementing(Class cl) { + Collection> col = new ArrayList<>(); + for (Map.Entry> entry1 : classes.entrySet()) { + Class c = entry1.getValue(); if (StaticUtils.isImplementing(c, cl)) col.add(c); } @@ -131,36 +135,23 @@ public static void copyInputStream(InputStream in, OutputStream out) * @param zipFileName The given zipped file name */ public static void unZip(String zipFileName, String destDir) { - System.out.println(zipFileName); - Enumeration entries; - ZipFile zipFile; - - try { - zipFile = new ZipFile(zipFileName); - - entries = zipFile.entries(); - - while(entries.hasMoreElements()) { - ZipEntry entry = (ZipEntry)entries.nextElement(); - - if(entry.isDirectory()) { - // Assume directories are stored parents first then children. -// System.err.println("Extracting directory: " + entry.getName()); - // This is not robust, just for demonstration purposes. - (new File(destDir+File.separator+entry.getName())).mkdirs(); - continue; - } - - System.out.println("Extracting file: " + destDir+entry.getName()); - copyInputStream(zipFile.getInputStream(entry), - new BufferedOutputStream(new FileOutputStream(destDir+File.separator+entry.getName()))); + try (ZipFile zipFile = new ZipFile(zipFileName)) { + Enumeration entries = zipFile.entries(); + while (entries.hasMoreElements()) { + ZipEntry entry = entries.nextElement(); + if (entry.isDirectory()) { + new File(destDir + File.separator + entry.getName()).mkdirs(); + continue; + } + try (InputStream in = zipFile.getInputStream(entry); + OutputStream out = new BufferedOutputStream( + new FileOutputStream(destDir + File.separator + entry.getName()))) { + copyInputStream(in, out); + } + } + } catch (IOException ioe) { + ExceptionHandler.catchException(ioe); } - - zipFile.close(); - } catch (IOException ioe) { - System.err.println("Unhandled exception:"); - ExceptionHandler.catchException(ioe); - } } diff --git a/src/graphtea/platform/parameter/Parametrizable.java b/src/graphtea/platform/parameter/Parametrizable.java index 789ed06a..ebef8245 100755 --- a/src/graphtea/platform/parameter/Parametrizable.java +++ b/src/graphtea/platform/parameter/Parametrizable.java @@ -19,5 +19,7 @@ public interface Parametrizable { * also if some other fields should be set after setting the parameters * you can do it in this method */ - String checkParameters(); + default String checkParameters() { + return null; + } } diff --git a/src/graphtea/platform/preferences/AbstractPreference.java b/src/graphtea/platform/preferences/AbstractPreference.java index d6208d66..08945cc5 100755 --- a/src/graphtea/platform/preferences/AbstractPreference.java +++ b/src/graphtea/platform/preferences/AbstractPreference.java @@ -30,7 +30,7 @@ public AbstractPreference(String name, Preferences pref, String category) { public NotifiableAttributeSetImpl attributeSet = new NotifiableAttributeSetImpl(); - protected void putAttribute(String name, ArrayX values) { + protected void putAttribute(String name, ArrayX values) { attributeSet.put(name, values); } @@ -45,7 +45,7 @@ protected T getAttribute(String name) { } - public abstract void defineAttributes(HashMap objectValues); + public abstract void defineAttributes(HashMap> objectValues); public abstract void defineListeners(AttributeListener al); diff --git a/src/graphtea/platform/preferences/GraphPreferences.java b/src/graphtea/platform/preferences/GraphPreferences.java index fbe573ae..9f38987a 100755 --- a/src/graphtea/platform/preferences/GraphPreferences.java +++ b/src/graphtea/platform/preferences/GraphPreferences.java @@ -35,7 +35,7 @@ public GraphPreferences(String name, HashSet oneInstances, String catego defineListeners(this); } - public void defineAttributes(HashMap objectValues) { + public void defineAttributes(HashMap> objectValues) { for (Object o : objectValues.keySet()) { putAttribute(o.toString(), objectValues.get(o)); @@ -50,10 +50,10 @@ public void defineAttributes(HashMap objectValues, boolean t) { } } - public void defineMultipleAttributes(HashMap> map) { + public void defineMultipleAttributes(HashMap>> map) { for (Object o : map.keySet()) { - HashMap hashMap = map.get(o); + HashMap> hashMap = map.get(o); for (Object fields : hashMap.keySet()) { putAttribute(o.toString() + "*" + fields.toString(), hashMap.get(fields)); diff --git a/src/graphtea/platform/preferences/UserDefinedEligiblity.java b/src/graphtea/platform/preferences/UserDefinedEligiblity.java index 179fd59f..cd2b1ab4 100755 --- a/src/graphtea/platform/preferences/UserDefinedEligiblity.java +++ b/src/graphtea/platform/preferences/UserDefinedEligiblity.java @@ -14,5 +14,5 @@ public interface UserDefinedEligiblity { GraphPreferences GraphPrefFactory(); - HashMap defineEligibleValuesForSettings(HashMap objectValues); + HashMap> defineEligibleValuesForSettings(HashMap> objectValues); }