From d08696233e388e662a9c89d92b0ca2758357c80d Mon Sep 17 00:00:00 2001 From: Anderson Santos Date: Mon, 12 Nov 2018 18:50:48 -0200 Subject: [PATCH 01/11] Bridging Centrality Plugin --- modules/BridgingPlugin/README.md | 4 + modules/BridgingPlugin/nb-configuration.xml | 18 + modules/BridgingPlugin/nbactions.xml | 16 + modules/BridgingPlugin/pom.xml | 97 ++++ .../BCgephi/BridgingCentralityMetric.java | 546 ++++++++++++++++++ .../BridgingCentralityMetricBuilder.java | 26 + .../BridgingCentralityMetricPanel.form | 170 ++++++ .../BridgingCentralityMetricPanel.java | 147 +++++ .../BCgephi/BridgingCentralityMetricUI.java | 124 ++++ .../BridgingPlugin/src/main/nbm/manifest.mf | 5 + .../main/resources/BCgephi/Bundle.properties | 30 + .../resources/BCgephi/Bundle_pt_BR.properties | 30 + nb-configuration.xml | 18 + pom.xml | 56 +- 14 files changed, 1279 insertions(+), 8 deletions(-) create mode 100644 modules/BridgingPlugin/README.md create mode 100644 modules/BridgingPlugin/nb-configuration.xml create mode 100644 modules/BridgingPlugin/nbactions.xml create mode 100644 modules/BridgingPlugin/pom.xml create mode 100644 modules/BridgingPlugin/src/main/java/BCgephi/BridgingCentralityMetric.java create mode 100644 modules/BridgingPlugin/src/main/java/BCgephi/BridgingCentralityMetricBuilder.java create mode 100644 modules/BridgingPlugin/src/main/java/BCgephi/BridgingCentralityMetricPanel.form create mode 100644 modules/BridgingPlugin/src/main/java/BCgephi/BridgingCentralityMetricPanel.java create mode 100644 modules/BridgingPlugin/src/main/java/BCgephi/BridgingCentralityMetricUI.java create mode 100644 modules/BridgingPlugin/src/main/nbm/manifest.mf create mode 100644 modules/BridgingPlugin/src/main/resources/BCgephi/Bundle.properties create mode 100644 modules/BridgingPlugin/src/main/resources/BCgephi/Bundle_pt_BR.properties create mode 100644 nb-configuration.xml diff --git a/modules/BridgingPlugin/README.md b/modules/BridgingPlugin/README.md new file mode 100644 index 0000000000..61ca9b57bc --- /dev/null +++ b/modules/BridgingPlugin/README.md @@ -0,0 +1,4 @@ +## Bridge Plugin + +This README supports Markdown, see [syntax](https://help.github.com/articles/markdown-basics/) + diff --git a/modules/BridgingPlugin/nb-configuration.xml b/modules/BridgingPlugin/nb-configuration.xml new file mode 100644 index 0000000000..c3e8f4d1fd --- /dev/null +++ b/modules/BridgingPlugin/nb-configuration.xml @@ -0,0 +1,18 @@ + + + + + + false + + diff --git a/modules/BridgingPlugin/nbactions.xml b/modules/BridgingPlugin/nbactions.xml new file mode 100644 index 0000000000..ca77c79221 --- /dev/null +++ b/modules/BridgingPlugin/nbactions.xml @@ -0,0 +1,16 @@ + + + + run + + nbm + + + nbm:cluster + nbm:run-ide + + + -J-Xmx1024m -J-Xss2m -J-Xms32m -J-XX:PermSize=32m + + + diff --git a/modules/BridgingPlugin/pom.xml b/modules/BridgingPlugin/pom.xml new file mode 100644 index 0000000000..07c1a35b23 --- /dev/null +++ b/modules/BridgingPlugin/pom.xml @@ -0,0 +1,97 @@ + + + 4.0.0 + + gephi-plugin-parent + org.gephi + 0.9.2 + + + ia.ppgco.facom.ufu.br + bridge-plugin + 1.0.1 + nbm + + Bridging Centrality Plugin + Bridging Centrality plugin. + + + + org.gephi + statistics-api + + + org.gephi + utils-longtask + + + org.netbeans.api + org-openide-util + + + + + org.gephi + graph-api + + + org.gephi + statistics-plugin + + + org.gephi + utils-longtask + + + org.gephi + ui-utils + + + org.gephi + utils + + + org.gephi + core-library-wrapper + + + jfree + jfreechart + + + + + org.netbeans.api + org-openide-util + + + org.netbeans.api + org-openide-util-lookup + + + org.jfree + jfreechart + 1.0.19 + + + + + + + org.codehaus.mojo + nbm-maven-plugin + + Apache 2.0 + Getúlio de Morais Pereira and Anderson Rodrigues dos Santos + santosardr@ufu.br + $sourcecode_url + + + + + + + + + + diff --git a/modules/BridgingPlugin/src/main/java/BCgephi/BridgingCentralityMetric.java b/modules/BridgingPlugin/src/main/java/BCgephi/BridgingCentralityMetric.java new file mode 100644 index 0000000000..6eeb36b596 --- /dev/null +++ b/modules/BridgingPlugin/src/main/java/BCgephi/BridgingCentralityMetric.java @@ -0,0 +1,546 @@ +package BCgephi; + +import java.io.IOException; +import java.time.Duration; +import java.time.LocalDateTime; +import org.gephi.graph.api.Graph; +import org.gephi.graph.api.GraphModel; +import org.gephi.graph.api.Node; +import org.gephi.graph.api.Table; +import org.gephi.statistics.plugin.GraphDistance; +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.ListIterator; +import java.util.Map; +import java.util.Stack; +import java.util.logging.Logger; +import javax.swing.JOptionPane; +import org.gephi.graph.api.*; +import org.gephi.statistics.plugin.ChartUtils; +import org.gephi.statistics.spi.Statistics; +import org.gephi.utils.TempDirUtils; +import org.gephi.utils.TempDirUtils.TempDir; +import org.gephi.utils.progress.Progress; +import org.gephi.utils.progress.ProgressTicket; +import org.jfree.chart.ChartFactory; +import org.jfree.chart.JFreeChart; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.data.xy.XYSeries; +import org.jfree.data.xy.XYSeriesCollection; +import org.openide.util.NbBundle; + +/** + * + * @author getulio + */ +public class BridgingCentralityMetric extends GraphDistance implements Statistics { + + private static final Logger logger = Logger.getLogger(BridgingCentralityMetric.class.getName()); + + public static final String BRIDGING_CENTRALITY = "bridgingcentrality"; + public static final String BRIDGING_COEFFICIENT = "bridgingcoefficient"; + + // relatorio de execucao + private String report = ""; + + // controle de execucao, com possibilidade de interrupcao pelo usuario + private boolean cancelled = false; + private ProgressTicket progressTicket; + + // parametros de entrada do usuario + private boolean directed; + private boolean normalized; + + // tomada de tempo de execucao + private LocalDateTime start = null; + private LocalDateTime stop_betweeness = null; + private LocalDateTime stop_bridging = null; + + // estatisticas calculadas pelo algoritmo + private double[] mybetweenness; + private double[] bridging_cent; + private double bridging_coef; + + // variaveis globais + private int Number_of_Nodes; + + /** + * Bridging Centrality algorithm .... + * + * @param graphModel + */ + @Override + public void execute(GraphModel graphModel) { + + directed = graphModel.getGraphVisible().isDirected(); + + Graph graph = null; + if ( directed ) { + graph = graphModel.getDirectedGraphVisible(); + } else { + graph = graphModel.getUndirectedGraphVisible(); + } + + execute(graph); + logger.log(java.util.logging.Level.INFO, "Success Bridging Centrality calculations."); + } + + @Override + public void execute(Graph graph) { + + graph.readLock(); + + try { + + initializeAttributeColunms(graph.getModel()); + //number of nodes + Number_of_Nodes = graph.getNodeCount(); + + //creates one array for each coeficient to be calculated + mybetweenness = new double[Number_of_Nodes]; + bridging_cent = new double[Number_of_Nodes]; + + //a humble index strategy, a sequential index + HashMap indicies = createIndiciesMap(graph); + //marks the start of the process + start = LocalDateTime.now(); + //calculates mybetweenness + mybetweenness = calculateBetweeness(graph, indicies, directed, normalized); + //mark the end of the process + stop_betweeness = LocalDateTime.now(); + // calculates bridging coefficient and bridging centrality + saveCalculatedValues(graph, indicies, mybetweenness); + //mark the end of the process of the bridging metrics + stop_bridging = LocalDateTime.now(); + // ----------- + if (cancelled) { + String msg = NbBundle.getMessage(BridgingCentralityMetric.class, "BridgingCentralityMetric.alert.message"); + String title = NbBundle.getMessage(BridgingCentralityMetric.class, "BridgingCentralityMetric.alert.title"); + JOptionPane.showMessageDialog(null, msg, title, JOptionPane.WARNING_MESSAGE); + logger.log(java.util.logging.Level.WARNING, msg); + } else { + //Print results + Duration diff_1 = Duration.between(start, stop_betweeness); + Duration diff_2 = Duration.between(stop_betweeness, stop_bridging); + String duration = NbBundle.getMessage(BridgingCentralityMetric.class, "BridgingCentralityMetric.report.duration"); + + report += "" + duration + " : " + diff_1.getSeconds() + " seconds (Betweenness)
"; + report += "" + duration + " : " + diff_2.getSeconds() + " seconds (Bridging)
"; + report += "" + duration + " : " + (diff_1.getSeconds() + diff_2.getSeconds()) + " seconds (Total)
"; + + report += "
"; + } + // ----------- + } finally { + graph.readUnlock(); + } + } + + /** + * Inicializa a tabela de nós + * + * @param graphModel + */ + private void initializeAttributeColunms(GraphModel graphModel) { + + Table nodeTable = graphModel.getNodeTable(); + + if ( ! nodeTable.hasColumn(BETWEENNESS) ){ + nodeTable.addColumn(BETWEENNESS, "Betweenness Centrality", Double.class, (double) 0); + } + + if ( ! nodeTable.hasColumn(BRIDGING_COEFFICIENT) ){ + nodeTable.addColumn(BRIDGING_COEFFICIENT, "Bridging Coefficient", Double.class, (double) 0); + } + + if ( ! nodeTable.hasColumn(BRIDGING_CENTRALITY) ){ + nodeTable.addColumn(BRIDGING_CENTRALITY, "Bridging Centrality", Double.class, (double) 0); + } + } + + @Override + public HashMap createIndiciesMap(Graph graph) { + + HashMap indicies = new HashMap(); + + int index = 0; + for (Node n : graph.getNodes()) { + indicies.put(n, index); + index++; + } + + return indicies; + } + + /** + * + * @param graph + * @param indicies + * @param directed + * @param normalized + * + * @return array with betweeness statistics + */ + private double[] calculateBetweeness(Graph graph, HashMap indicies, boolean directed, boolean normalized) { + + double[] nodeBetweenness = new double[ Number_of_Nodes ]; + + int count = 0; + + Progress.start(progressTicket, Number_of_Nodes); + //Bread First Search (BFS) to calculate all the shortest paths from node s to t + for (Node s : graph.getNodes()) { + //The below structures are candidates to performance improvments: + //Creates a stack for each node, ... + Stack S = new Stack(); + //... a linked listed for each node, ... + LinkedList[] Pred = new LinkedList[ Number_of_Nodes ]; + // ... define sigma(s, t) as the number of shortest paths between nodes s and t ... + double[] sigma = new double[ Number_of_Nodes ]; + //...and also a distance for each node. + int[] dist = new int[ Number_of_Nodes ]; + + int s_index = indicies.get(s); + //all parameters are set empty + BFS_Initialization( Pred, sigma, dist, s_index, Number_of_Nodes ); + + LinkedList Q = new LinkedList(); + //All nodes are added to the end of the Q list + //Starting node: 1. Choose the starting node s and put it on the queue Q. + Q.addLast(s); + while ( ! Q.isEmpty() ) { + //The calculation always starts from first node. 1. dequeue v from Q + Node v = Q.removeFirst(); + //Despite of being removed of the list the node is stored in a stack S + //This stack will be poped up to simulate the backtracking of the shortest paths + //from all nodes s and t; and allows us to calculate the mybetweenness in the process + S.push(v); + //Recovery of the node index. + //Using this index we will directely access the 'dist' and 'sigma' attributes of the node + int v_index = indicies.get(v); + //Read all edges conected to the node + EdgeIterable edgeIter = getEdgeIter(graph, v, directed); + //Iterate for all edges to access their nodes in the opposite side + for (Edge edge : edgeIter) { + //Obtain a new node in the opposite edge of the node + Node reachable = graph.getOpposite(v, edge); + //recover the index of the reachable node + //Using this index we will directely access the 'dist' and 'sigma' attributes of the reachable node + int r_index = indicies.get(reachable); + //if the reachable node where not investigated yet (dist<0) ... + if (dist[r_index] < 0) { + //... add the reachable node to the list of further nodes to be analysed ... + Q.addLast(reachable); + //... and increment the 'dist' of the reachable node to the value of the initial node plus zero + dist[r_index] = dist[v_index] + 1; + //It meaks sense because the distance from the reachable node to the current node is exactly 1. + } + //If the reachable node was just incorporated to the list of further analyses then the next condition + //will be always true, even because v_index no longer changes. However, the current node here + //could be a reachable node from another one causing the increment of the distantce 'dist'. Once the + //distance is augmented by one the node no longer will be analysed (no loops). Still, the + //next condition certificates the 'sigma' sum only in care of difference of exacltly one edge between + //the current node and the reachable node, no matter the value of 'dist'. + if (dist[r_index] == (dist[v_index] + 1)) { + sigma[r_index] = sigma[r_index] + sigma[v_index]; + //The current node v will be added to the list of nodes to visit of the reachable node + Pred[r_index].addLast(v); + } + } + } + + // ------------- + //All nodes and its connections had its paths length computed. + //Now is possible to calculate the mybetweenness poping up the stack created with the BFS + //1. set delta(v) to zero for all nodes v in V. + double[] delta = new double[ Number_of_Nodes ]; + //3. while S is not empty, ... + while ( ! S.empty() ) { + //... pop w off S + Node w = S.pop(); + + int w_index = indicies.get(w); + + ListIterator it = Pred[w_index].listIterator(); + while (it.hasNext()) { + Node u = it.next(); + int u_index = indicies.get(u); + //for all nodes u in Pred(w) set delta(u) to delta(u) + MAGIC(delta(w)). + delta[u_index] += (sigma[u_index] / sigma[w_index]) * (1 + delta[w_index]); + //MAGIC(delta(w)) is an incremental formula based on the recursive definition + //of the shortests paths from s to w. It means that a proportion of shortests + //paths from the w predecessors incorporates the u (or v) node. This proportion + //is the division operation. This proportion multiplies at least one path plus + //the remaining shortest paths to w. The incremental sum of all these shortests + //paths proportions (deltas) raises the integral mybetweenness metric. + } + + if (w != s) { + nodeBetweenness[w_index] += delta[w_index]; + } + } + + count++; + + if (cancelled) { + return nodeBetweenness; + } + + Progress.progress(progressTicket, count); + } + + // corrige e normaliza o resultado da mybetweenness + calculateCorrection(graph, indicies, nodeBetweenness, directed, normalized); + + return nodeBetweenness; + } + + /** + * Salva as estatisticas calculadas como atributos de cada nó + * + * @param graph + * @param indicies + * @param nodeBetweenness + */ + private void saveCalculatedValues(Graph graph, HashMap indicies, double[] nodeBetweenness) { + + for (Node s : graph.getNodes()) { + + int s_index = indicies.get(s); + + bridging_coef = bridging_coeficient(graph, s); + //The bridging centrality is just a multiplication of two other metrics + bridging_cent[s_index] = bridging_coef * mybetweenness[s_index]; + + s.setAttribute(BETWEENNESS, nodeBetweenness[s_index]); + s.setAttribute(BRIDGING_COEFFICIENT, bridging_coef); + s.setAttribute(BRIDGING_CENTRALITY, bridging_cent[s_index]); + } + } + + /** + * Aplica as correcoes/normalizacoes nos nós, para a betweeness + * + * @param graph + * @param indicies + * @param nodeBetweenness + * @param directed + * @param normalized + */ + private void calculateCorrection(Graph graph, HashMap indicies, double[] nodeBetweenness, boolean directed, boolean normalized) { + + int s_index = 0; + for (Node s : graph.getNodes()) { + + s_index = indicies.get(s); + + // corrige o resultado, para o caso de rede nao dirigida + if (! directed) { + nodeBetweenness[s_index] /= 2; + } + + // normaliza o resultado + if (normalized) { + nodeBetweenness[s_index] /= directed ? (Number_of_Nodes - 1) * (Number_of_Nodes - 2) : (Number_of_Nodes - 1) * (Number_of_Nodes - 2) / 2; + } + } + } + + private void BFS_Initialization( LinkedList[] Pred, double[] sigma, int[] dist, int index, int n) { + //There is a potential problem in this function: the Node s is passed but never used. + //For what node these parameteres are being set? + for (int w = 0; w < n; w++) { + //1. Mark w as unvisited by setting dist[w] (the distance between s and the node w) to infinity. + dist[w] = -1; + //2. Set Pred[w] (nodes that immediately precede w on a shortest path from s) to the empty list. + Pred[w] = new LinkedList(); + + sigma[w] = 0; + } + //The number of shortest paths start with the value 1 since sigma(v,v)=1 + sigma[index] = 1; + //Starting node: 2. Set dist[s] to 0. + dist[index] = 0; + } + + private EdgeIterable getEdgeIter(Graph graph, Node v, boolean directed) { + + if (directed) { + return ((DirectedGraph) graph).getOutEdges(v); + } + + return graph.getEdges(v); + } + + /** + * Should return plain text or HTML text that describe the algorithm + * execution. + * + * @return + */ + @Override + public String getReport() { + + String htmlIMG1 = ""; + String htmlIMG2 = ""; + String htmlIMG3 = ""; + + try { + TempDir tempDir = TempDirUtils.createTempDir(); + htmlIMG1 = createImageFile(tempDir, bridging_cent, "Bridging Centrality Distribution", "Value", "Count"); + // htmlIMG2 = createImageFile(tempDir, bridging_coef, "Bridging Coefficient Distribution", "Value", "Count"); + htmlIMG3 = createImageFile(tempDir, mybetweenness, "Betweenness Centrality Distribution", "Value", "Count"); + } catch (IOException ex) { + + String msg = NbBundle.getMessage(BridgingCentralityMetric.class, "BridgingCentralityMetric.error.message"); + String title = NbBundle.getMessage(BridgingCentralityMetric.class, "BridgingCentralityMetric.error.title"); + JOptionPane.showMessageDialog(null, msg, title, JOptionPane.ERROR_MESSAGE); + + logger.log(java.util.logging.Level.SEVERE, msg, ex); + } + + String report_title = NbBundle.getMessage(BridgingCentralityMetric.class, "BridgingCentralityMetric.report.title"); + String params = NbBundle.getMessage(BridgingCentralityMetric.class, "BridgingCentralityMetric.report.params"); + String param_1 = NbBundle.getMessage(BridgingCentralityMetric.class, "BridgingCentralityMetric.report.params.par_1"); + String value_1_1 = NbBundle.getMessage(BridgingCentralityMetric.class, "BridgingCentralityMetric.report.params.par_1.value_1"); + String value_1_2 = NbBundle.getMessage(BridgingCentralityMetric.class, "BridgingCentralityMetric.report.params.par_1.value_2"); + String value_2_1 = NbBundle.getMessage(BridgingCentralityMetric.class, "BridgingCentralityMetric.report.params.par_2.value_1"); + String value_2_2 = NbBundle.getMessage(BridgingCentralityMetric.class, "BridgingCentralityMetric.report.params.par_2.value_2"); + String results = NbBundle.getMessage(BridgingCentralityMetric.class, "BridgingCentralityMetric.report.results"); + + String param_2 = NbBundle.getMessage(BridgingCentralityMetric.class, "BridgingCentralityMetric.report.params.par_2"); + + String rep = "

" + report_title + "

" + + "
" + + "
" + + "

" + params + " :

" + + param_1 + " : " + (directed ? value_1_1 : value_1_2) + "
" + + param_2 + " : " + (normalized ? value_2_1 : value_2_2) + "
" + + "

" + results + ":

"; + + rep += report; + + String algorithms = NbBundle.getMessage(BridgingCentralityMetric.class, "BridgingCentralityMetric.report.algorithm"); + String credits = NbBundle.getMessage(BridgingCentralityMetric.class, "BridgingCentralityMetric.report.credits"); + String contact = NbBundle.getMessage(BridgingCentralityMetric.class, "BridgingCentralityMetric.report.contact"); + + rep += "

" + + "
Please, check the Data Laboratory Tab for the full listing of Bridging Centrality for the graph.
" + + "

" + + htmlIMG1 + "

" + + htmlIMG2 + "

" + + htmlIMG3 + "

" + + "

" + + "

" + algorithms + ":

" + + "
    " + + "
  • Ulrik Brandes, A Faster Algorithm for Betweenness Centrality, in Journal of Mathematical Sociology 25(2):163-177, (2001)
  • " + + "
  • Hwang, W., Cho, Y. R., Zhang, A., & Ramanathan, M. (2006, March). Bridging centrality: identifying bridging nodes in scale-free networks. In Proceedings of the 12th ACM SIGKDD international conference on Knowledge discovery and data mining (pp. 20-23).
  • " + + "
" + + "" + credits + ": " + + "
    " + + "
  • Getúlio de Morais Pereira
  • " + + "
  • Anderson Rodrigues dos Santos
  • " + + "
      " + + "
    • " + contact + " : santosardr@ufu.br
    • " + + "
    " + + "
      " + + " "; + + return rep; + } + + private String createImageFile(TempDir tempDir, double[] pVals, String pName, String pX, String pY) { + + //distribution of nodeIDs + Map dist = new HashMap(); + + for (int i = 0; i < Number_of_Nodes; i++) { + Double d = pVals[i]; + if (dist.containsKey(d)) { + Integer v = dist.get(d); + dist.put(d, v + 1); + } else { + dist.put(d, 1); + } + } + + //Distribution series + XYSeries dSeries = ChartUtils.createXYSeries(dist, pName); + + XYSeriesCollection dataset = new XYSeriesCollection(); + dataset.addSeries(dSeries); + + JFreeChart chart = ChartFactory.createXYLineChart( + pName, + pX, + pY, + dataset, + PlotOrientation.HORIZONTAL, + true, + false, + false); + + chart.removeLegend(); + ChartUtils.decorateChart(chart); + ChartUtils.scaleChart(chart, dSeries, normalized); + + return ChartUtils.renderChart(chart, pName + ".png"); + } + + /** + * Calcula o bridging coeficient de um dado vertice + * + * @param graph + * @param node + * + * @return bridging coefficient value + */ + private static double bridging_coeficient(Graph graph, Node node) { + //The inverse degree of a node divided by the inverse degree of all their imediate neighbors + double n = 1.0 / graph.getDegree(node); + + double d = 0.0; + Iterator it = graph.getNeighbors(node).iterator(); + while( it.hasNext() ) { + Node t = (Node) it.next(); + d += 1.0 / graph.getDegree( t ); + } + + return n / d; + } + + /** + * cancelar a execucao do algoritmo + */ + @Override + public boolean cancel() { + this.cancelled = true; + return true; + } + + @Override + public void setProgressTicket(ProgressTicket progressTicket) { + this.progressTicket = progressTicket; + } + + @Override + public boolean isDirected() { + return directed; + } + + @Override + public void setDirected(boolean directed) { + this.directed = directed; + } + + @Override + public boolean isNormalized() { + return normalized; + } + + @Override + public void setNormalized(boolean normalized) { + this.normalized = normalized; + } +} diff --git a/modules/BridgingPlugin/src/main/java/BCgephi/BridgingCentralityMetricBuilder.java b/modules/BridgingPlugin/src/main/java/BCgephi/BridgingCentralityMetricBuilder.java new file mode 100644 index 0000000000..4f0a44e827 --- /dev/null +++ b/modules/BridgingPlugin/src/main/java/BCgephi/BridgingCentralityMetricBuilder.java @@ -0,0 +1,26 @@ +package BCgephi; + +import org.gephi.statistics.spi.Statistics; +import org.gephi.statistics.spi.StatisticsBuilder; +import org.openide.util.NbBundle; +import org.openide.util.lookup.ServiceProvider; + +/** + * + * @author Getúlio de Morais Pereira + */ +@ServiceProvider(service = StatisticsBuilder.class) +public class BridgingCentralityMetricBuilder implements StatisticsBuilder { + + public String getName() { + return NbBundle.getMessage(BridgingCentralityMetricBuilder.class, "BridgingCentralityMetricBuilder.name"); + } + + public Statistics getStatistics() { + return new BridgingCentralityMetric(); + } + + public Class getStatisticsClass() { + return BridgingCentralityMetric.class; + } +} diff --git a/modules/BridgingPlugin/src/main/java/BCgephi/BridgingCentralityMetricPanel.form b/modules/BridgingPlugin/src/main/java/BCgephi/BridgingCentralityMetricPanel.form new file mode 100644 index 0000000000..c7f3d7e369 --- /dev/null +++ b/modules/BridgingPlugin/src/main/java/BCgephi/BridgingCentralityMetricPanel.form @@ -0,0 +1,170 @@ + + +
      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/modules/BridgingPlugin/src/main/java/BCgephi/BridgingCentralityMetricPanel.java b/modules/BridgingPlugin/src/main/java/BCgephi/BridgingCentralityMetricPanel.java new file mode 100644 index 0000000000..a9177b94f4 --- /dev/null +++ b/modules/BridgingPlugin/src/main/java/BCgephi/BridgingCentralityMetricPanel.java @@ -0,0 +1,147 @@ +package BCgephi; + +/** + * + * @author getulio + */ +public class BridgingCentralityMetricPanel extends javax.swing.JPanel { + + private static final long serialVersionUID = -3590479963190614570L; + + public BridgingCentralityMetricPanel() { + initComponents(); + } + + public boolean isDirected() { + return isDirectedCheckBox.isSelected(); + } + + public void setDirected(boolean directed) { + isDirectedCheckBox.setSelected(directed); + } + + public void directedCheckBox(boolean enabled) { + isDirectedCheckBox.setEnabled(enabled); + isDirectedLabel.setEnabled(enabled); + } + + public boolean isNormalized() { + return isNormalizedCheckBox.isSelected(); + } + + public void setNormalized(boolean normalized) { + isNormalizedCheckBox.setSelected(normalized); + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + jPanel1 = new javax.swing.JPanel(); + jPanel2 = new javax.swing.JPanel(); + titleLabel = new javax.swing.JLabel(); + isDirectedLabel = new javax.swing.JLabel(); + isDirectedCheckBox = new javax.swing.JCheckBox(); + jSeparator1 = new javax.swing.JSeparator(); + isNormalizedLabel = new javax.swing.JLabel(); + isNormalizedCheckBox = new javax.swing.JCheckBox(); + + setPreferredSize(new java.awt.Dimension(340, 194)); + + jPanel1.setPreferredSize(new java.awt.Dimension(340, 194)); + jPanel1.setLayout(new java.awt.BorderLayout()); + + jPanel2.setPreferredSize(new java.awt.Dimension(340, 194)); + + titleLabel.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N + titleLabel.setText(org.openide.util.NbBundle.getMessage(BridgingCentralityMetricPanel.class, "BridgingCentralityMetricPanel.titleLabel.text")); // NOI18N + + isDirectedLabel.setText(org.openide.util.NbBundle.getMessage(BridgingCentralityMetricPanel.class, "BridgingCentralityMetricPanel.isDirectedLabel.text")); // NOI18N + isDirectedLabel.setMaximumSize(new java.awt.Dimension(110, 23)); + isDirectedLabel.setMinimumSize(new java.awt.Dimension(110, 23)); + + isNormalizedLabel.setText(org.openide.util.NbBundle.getMessage(BridgingCentralityMetricPanel.class, "BridgingCentralityMetricPanel.isNormalizedLabel.text")); // NOI18N + isNormalizedLabel.setMaximumSize(new java.awt.Dimension(110, 23)); + isNormalizedLabel.setMinimumSize(new java.awt.Dimension(110, 23)); + + javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); + jPanel2.setLayout(jPanel2Layout); + jPanel2Layout.setHorizontalGroup( + jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel2Layout.createSequentialGroup() + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel2Layout.createSequentialGroup() + .addContainerGap() + .addComponent(isNormalizedCheckBox) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(isNormalizedLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel2Layout.createSequentialGroup() + .addContainerGap() + .addComponent(isDirectedCheckBox) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(isDirectedLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel2Layout.createSequentialGroup() + .addContainerGap() + .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 300, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel2Layout.createSequentialGroup() + .addGap(56, 56, 56) + .addComponent(titleLabel))) + .addContainerGap(497, Short.MAX_VALUE)) + ); + jPanel2Layout.setVerticalGroup( + jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel2Layout.createSequentialGroup() + .addGap(23, 23, 23) + .addComponent(titleLabel) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(isDirectedCheckBox) + .addComponent(isDirectedLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel2Layout.createSequentialGroup() + .addComponent(isNormalizedLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 23, Short.MAX_VALUE) + .addGap(157, 157, 157)) + .addGroup(jPanel2Layout.createSequentialGroup() + .addComponent(isNormalizedCheckBox) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))) + ); + + jPanel1.add(jPanel2, java.awt.BorderLayout.CENTER); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(0, 0, Short.MAX_VALUE) + .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 803, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(0, 0, Short.MAX_VALUE)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(0, 0, Short.MAX_VALUE) + .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 283, javax.swing.GroupLayout.PREFERRED_SIZE)) + ); + }// //GEN-END:initComponents + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JCheckBox isDirectedCheckBox; + private javax.swing.JLabel isDirectedLabel; + private javax.swing.JCheckBox isNormalizedCheckBox; + private javax.swing.JLabel isNormalizedLabel; + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JSeparator jSeparator1; + private javax.swing.JLabel titleLabel; + // End of variables declaration//GEN-END:variables +} diff --git a/modules/BridgingPlugin/src/main/java/BCgephi/BridgingCentralityMetricUI.java b/modules/BridgingPlugin/src/main/java/BCgephi/BridgingCentralityMetricUI.java new file mode 100644 index 0000000000..7c14765df3 --- /dev/null +++ b/modules/BridgingPlugin/src/main/java/BCgephi/BridgingCentralityMetricUI.java @@ -0,0 +1,124 @@ +package BCgephi; + +import javax.swing.JPanel; +import org.gephi.graph.api.Graph; +import org.gephi.graph.api.GraphController; +import org.gephi.statistics.spi.Statistics; +import org.gephi.statistics.spi.StatisticsUI; +import org.openide.util.Lookup; +import org.openide.util.NbBundle; +import org.openide.util.lookup.ServiceProvider; + +/** + * + * @author getulio + */ +@ServiceProvider(service = StatisticsUI.class) +public class BridgingCentralityMetricUI implements StatisticsUI { + + private final StatSettings settings = new StatSettings(); + + private BridgingCentralityMetricPanel panel; + private BridgingCentralityMetric metric; + + private boolean isDirected; + private boolean isNormalized; + + public void setDirected(boolean isDirected) { + this.isDirected = isDirected; + } + + public boolean isDirected() { + return isDirected; + } + + public void setNormalized(boolean isNormalized) { + this.isNormalized = isNormalized; + } + + public boolean isNormalized() { + return isNormalized; + } + + public JPanel getSettingsPanel() { + panel = new BridgingCentralityMetricPanel(); + return panel; + } + + public void setup(Statistics ststcs) { + + metric = (BridgingCentralityMetric) ststcs; + + if ( panel != null ) { + + metric.setNormalized( true ); // default + + panel.setDirected(metric.isDirected()); + panel.setNormalized(metric.isNormalized()); + + GraphController graphController = Lookup.getDefault().lookup(GraphController.class); + Graph graph = graphController.getGraphModel().getGraphVisible(); + panel.directedCheckBox( graph.isDirected() ); + } + } + + public void unsetup() { + if (panel != null) { + metric.setDirected(panel.isDirected()); + metric.setNormalized(panel.isNormalized()); + settings.save(metric); + } + panel = null; + metric = null; + } + + public Class getStatisticsClass() { + return BridgingCentralityMetric.class; + } + + /** + * If your metric doesn't have a single result value, return null. + */ + public String getValue() { + return null; + } + + public String getDisplayName() { + return NbBundle.getMessage(BridgingCentralityMetricUI.class, "BridgingCentralityMetricUI.displayName"); + } + + public String getShortDescription() { + return NbBundle.getMessage(BridgingCentralityMetricUI.class, "BridgingCentralityMetricUI.shortDescription"); + } + + public String getCategory() { + return StatisticsUI.CATEGORY_NETWORK_OVERVIEW; + } + + /** + * The position control the order the metric front-end are displayed. + * Returns a value between 1 and 1000, that indicates the position. + * Less means upper. + */ + public int getPosition() { + return 200; + } + + + private static class StatSettings { + + private boolean isDirectedGraph = false; + private boolean isNormalized = false; + + private void save(BridgingCentralityMetric stat) { + this.isDirectedGraph = stat.isDirected(); + this.isNormalized = stat.isNormalized(); + } + + private void load(BridgingCentralityMetric stat) { + stat.setDirected(isDirectedGraph); + stat.setNormalized(isNormalized); + } + } + +} diff --git a/modules/BridgingPlugin/src/main/nbm/manifest.mf b/modules/BridgingPlugin/src/main/nbm/manifest.mf new file mode 100644 index 0000000000..b27ba34884 --- /dev/null +++ b/modules/BridgingPlugin/src/main/nbm/manifest.mf @@ -0,0 +1,5 @@ +Manifest-Version: 1.0 +OpenIDE-Module-Name: Bridging Centrality Plugin +OpenIDE-Module-Short-Description: Bridging Centrality +OpenIDE-Module-Long-Description: Bridging Centrality for undirected networks +OpenIDE-Module-Display-Category: Metric diff --git a/modules/BridgingPlugin/src/main/resources/BCgephi/Bundle.properties b/modules/BridgingPlugin/src/main/resources/BCgephi/Bundle.properties new file mode 100644 index 0000000000..78fd96b8b3 --- /dev/null +++ b/modules/BridgingPlugin/src/main/resources/BCgephi/Bundle.properties @@ -0,0 +1,30 @@ +BridgingCentralityMetricBuilder.name=Bridging Centrality Algorithm + +BridgingCentralityMetricUI.displayName=Bridging Centrality +BridgingCentralityMetricUI.shortDescription=Bridging Centrality + +BridgingCentralityMetricPanel.isDirectedLabel.text=Directed Network +BridgingCentralityMetricPanel.titleLabel.text=Bridging Centrality +BridgingCentralityMetricPanel.isNormalizedLabel.text=Normalized [0..1] + +BridgingCentralityMetric.bwexists.message=Betweenness Centrality values already exists. Recalculate? +BridgingCentralityMetric.finish.message=Bridging Centrality calculated successfully. +BridgingCentralityMetric.alert.message=Execution interrupted by user +BridgingCentralityMetric.alert.title=Warning + +BridgingCentralityMetric.error.message=Error creating graphs to the report. Please, verify directory permissions. +BridgingCentralityMetric.error.title=Error + +BridgingCentralityMetric.report.title=Bridging Centrality - Final Report +BridgingCentralityMetric.report.params=Parameters +BridgingCentralityMetric.report.params.par_1=Network type +BridgingCentralityMetric.report.params.par_2=Normalized[0..1] +BridgingCentralityMetric.report.params.par_1.value_1=directed +BridgingCentralityMetric.report.params.par_1.value_2=undirected +BridgingCentralityMetric.report.params.par_2.value_1=normalized +BridgingCentralityMetric.report.params.par_2.value_2=not normalized +BridgingCentralityMetric.report.results=Results +BridgingCentralityMetric.report.duration=Duration +BridgingCentralityMetric.report.algorithm=Algorithms +BridgingCentralityMetric.report.credits=Implemented by +BridgingCentralityMetric.report.contact=Contact diff --git a/modules/BridgingPlugin/src/main/resources/BCgephi/Bundle_pt_BR.properties b/modules/BridgingPlugin/src/main/resources/BCgephi/Bundle_pt_BR.properties new file mode 100644 index 0000000000..027f82dccc --- /dev/null +++ b/modules/BridgingPlugin/src/main/resources/BCgephi/Bundle_pt_BR.properties @@ -0,0 +1,30 @@ +BridgingCentralityMetricBuilder.name=Bridging Centrality Algorithm + +BridgingCentralityMetricUI.displayName=Bridging Centrality +BridgingCentralityMetricUI.shortDescription=Bridging Centrality + +BridgingCentralityMetricPanel.isDirectedLabel.text=Rede dirigida +BridgingCentralityMetricPanel.titleLabel.text=Bridging Centrality +BridgingCentralityMetricPanel.isNormalizedLabel.text=Normalizado [0..1] + +BridgingCentralityMetric.bwexists.message=Valores de Betweenness Centrality j\u00e1 existem. Recalcular? +BridgingCentralityMetric.finish.message=C\u00e1lculo de Bridging Centrality concluido com sucesso. +BridgingCentralityMetric.alert.message=Execu\u00e7\u00e3o interrompida pelo usu\u00e1rio +BridgingCentralityMetric.alert.title=Alerta + +BridgingCentralityMetric.error.message=Erro na cria\u00e7\u00e3o dos gr\u00e1ficos do relat\u00f3rio de execu\u00e7\u00e3o. Verifique permiss\u00e3o de escrita/leitura no diret\u00f3rio da aplica\u00e7\u00e3o. +BridgingCentralityMetric.error.title=Erro + +BridgingCentralityMetric.report.title=Bridging Centrality - Relat\u00f3rio de Execu\u00e7\u00e3o +BridgingCentralityMetric.report.params=Par\u00e2metros +BridgingCentralityMetric.report.params.par_1=Tipo de rede +BridgingCentralityMetric.report.params.par_2=Normalizado [0..1] +BridgingCentralityMetric.report.params.par_1.value_1=dirigida +BridgingCentralityMetric.report.params.par_1.value_2=n\u00e3o dirigida +BridgingCentralityMetric.report.params.par_2.value_1=normalizado +BridgingCentralityMetric.report.params.par_2.value_2=n\u00e3o normalizado +BridgingCentralityMetric.report.results=Resultados +BridgingCentralityMetric.report.duration=Dura\u00e7\u00e3o +BridgingCentralityMetric.report.algorithm=Algoritmos +BridgingCentralityMetric.report.credits=Implementado por +BridgingCentralityMetric.report.contact=Contato \ No newline at end of file diff --git a/nb-configuration.xml b/nb-configuration.xml new file mode 100644 index 0000000000..6af45c765e --- /dev/null +++ b/nb-configuration.xml @@ -0,0 +1,18 @@ + + + + + + false + + diff --git a/pom.xml b/pom.xml index 838d3f503f..5c6dfe364f 100644 --- a/pom.xml +++ b/pom.xml @@ -8,10 +8,55 @@ pom gephi-plugins + Bridging Centrality Gephi plugin. + 2018 + + + + + CDDL 1.0 + http://www.opensource.org/licenses/CDDL-1.0 + CDDL License 1.0 + + + GPL v3 + http://www.opensource.org/licenses/GPL-3.0 + GPL v3 License + + + + + + scm:git:git://github.com/santosardr/gephi-plugins.git + scm:git:git@github.com:santosardr/gephi-plugins.git + https://github.com/santosardr/gephi-plugins + + + + + + getulio + Getúlio de Morais Pereira + getulio@iftm.edu.br + https://www.researchgate.net/profile/Getulio_De_Morais_Pereira + IFTM Campus Ituiutaba + http://www.iftm.edu.br + -3 + + + santosardr + Anderson Rodrigues dos Santos + santosardr@ufu.br + https://www.researchgate.net/profile/Anderson_Santos_3 + Universidade Federal de Uberlândia + http://www.ufu.br + -3 + + - + modules/BridgingPlugin @@ -20,15 +65,10 @@ 0.9.2 ${project.build.directory}/plugins_clusters github + 1.8 + 1.8 - - - scm:git:git://github.com/gephi/gephi-plugins.git - scm:git:git@github.com:gephi/gephi-plugins.git - https://github.com/gephi/gephi-plugins - - From 683b5b68ddf571d5af35d7ff310378aca5701880 Mon Sep 17 00:00:00 2001 From: Anderson Santos Date: Tue, 13 Nov 2018 08:41:32 -0200 Subject: [PATCH 02/11] Description --- modules/BridgingPlugin/src/main/nbm/manifest.mf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/BridgingPlugin/src/main/nbm/manifest.mf b/modules/BridgingPlugin/src/main/nbm/manifest.mf index b27ba34884..37d498e7d5 100644 --- a/modules/BridgingPlugin/src/main/nbm/manifest.mf +++ b/modules/BridgingPlugin/src/main/nbm/manifest.mf @@ -1,5 +1,5 @@ Manifest-Version: 1.0 OpenIDE-Module-Name: Bridging Centrality Plugin -OpenIDE-Module-Short-Description: Bridging Centrality -OpenIDE-Module-Long-Description: Bridging Centrality for undirected networks +OpenIDE-Module-Short-Description: Bridging Centrality Plugin +OpenIDE-Module-Long-Description: Bridging Centrality (BC) depicts nodes connected to immediate neighbors that, by turn, are connecting clusters of nodes. BC is the result of Betweenness Centrality multiplied by Bridging Node Centrality. BC can be useful to identify links for groups of nodes. For instance, considering a protein network, BC could point up proteins acting as a bridge betweenn complementary molecular functions. This plugin appends the new data columns to the Gephi data laboratory tab: Betweenness, Bridging Node and Bridging Centrality. OpenIDE-Module-Display-Category: Metric From ca9b5fc4b750b9d53552e87881ca0610671bfeee Mon Sep 17 00:00:00 2001 From: Anderson Santos Date: Tue, 13 Nov 2018 08:55:19 -0200 Subject: [PATCH 03/11] Description --- modules/BridgingPlugin/src/main/nbm/manifest.mf | 2 +- .../BridgingPlugin/src/main/resources/BCgephi/Bundle.properties | 2 +- .../src/main/resources/BCgephi/Bundle_pt_BR.properties | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/BridgingPlugin/src/main/nbm/manifest.mf b/modules/BridgingPlugin/src/main/nbm/manifest.mf index 37d498e7d5..c39d47f66c 100644 --- a/modules/BridgingPlugin/src/main/nbm/manifest.mf +++ b/modules/BridgingPlugin/src/main/nbm/manifest.mf @@ -1,5 +1,5 @@ Manifest-Version: 1.0 OpenIDE-Module-Name: Bridging Centrality Plugin OpenIDE-Module-Short-Description: Bridging Centrality Plugin -OpenIDE-Module-Long-Description: Bridging Centrality (BC) depicts nodes connected to immediate neighbors that, by turn, are connecting clusters of nodes. BC is the result of Betweenness Centrality multiplied by Bridging Node Centrality. BC can be useful to identify links for groups of nodes. For instance, considering a protein network, BC could point up proteins acting as a bridge betweenn complementary molecular functions. This plugin appends the new data columns to the Gephi data laboratory tab: Betweenness, Bridging Node and Bridging Centrality. +OpenIDE-Module-Long-Description: Bridging Centrality (BC) depicts nodes connected to immediate neighbors that, by turn, are connecting clusters of nodes. BC is the result of Betweenness Centrality multiplied by Bridging Node Centrality. BC can be useful to identify links for groups of nodes. This plugin appends the new data columns to the Gephi data laboratory tab: Betweenness, Bridging Node and Bridging Centrality. OpenIDE-Module-Display-Category: Metric diff --git a/modules/BridgingPlugin/src/main/resources/BCgephi/Bundle.properties b/modules/BridgingPlugin/src/main/resources/BCgephi/Bundle.properties index 78fd96b8b3..46a5a3f108 100644 --- a/modules/BridgingPlugin/src/main/resources/BCgephi/Bundle.properties +++ b/modules/BridgingPlugin/src/main/resources/BCgephi/Bundle.properties @@ -1,7 +1,7 @@ BridgingCentralityMetricBuilder.name=Bridging Centrality Algorithm BridgingCentralityMetricUI.displayName=Bridging Centrality -BridgingCentralityMetricUI.shortDescription=Bridging Centrality +BridgingCentralityMetricUI.shortDescription=Bridging Centrality (BC) depicts nodes connected to immediate neighbors that, by turn, are connecting clusters of nodes. BC is the result of Betweenness Centrality multiplied by Bridging Node Centrality. BC can be useful to identify links for groups of nodes. For instance, considering a protein network, BC could point up proteins acting as a bridge betweenn complementary molecular functions. This plugin appends the new data columns to the Gephi data laboratory tab: Betweenness, Bridging Node and Bridging Centrality. BridgingCentralityMetricPanel.isDirectedLabel.text=Directed Network BridgingCentralityMetricPanel.titleLabel.text=Bridging Centrality diff --git a/modules/BridgingPlugin/src/main/resources/BCgephi/Bundle_pt_BR.properties b/modules/BridgingPlugin/src/main/resources/BCgephi/Bundle_pt_BR.properties index 027f82dccc..25d7be07ab 100644 --- a/modules/BridgingPlugin/src/main/resources/BCgephi/Bundle_pt_BR.properties +++ b/modules/BridgingPlugin/src/main/resources/BCgephi/Bundle_pt_BR.properties @@ -1,7 +1,7 @@ BridgingCentralityMetricBuilder.name=Bridging Centrality Algorithm BridgingCentralityMetricUI.displayName=Bridging Centrality -BridgingCentralityMetricUI.shortDescription=Bridging Centrality +BridgingCentralityMetricUI.shortDescription=Bridging Centrality (BC) depicts nodes connected to immediate neighbors that, by turn, are connecting clusters of nodes. BC is the result of Betweenness Centrality multiplied by Bridging Node Centrality. BC can be useful to identify links for groups of nodes. For instance, considering a protein network, BC could point up proteins acting as a bridge betweenn complementary molecular functions. This plugin appends the new data columns to the Gephi data laboratory tab: Betweenness, Bridging Node and Bridging Centrality. BridgingCentralityMetricPanel.isDirectedLabel.text=Rede dirigida BridgingCentralityMetricPanel.titleLabel.text=Bridging Centrality From 23856dd17cde681111620758abf2d6fd65a012c9 Mon Sep 17 00:00:00 2001 From: Anderson Santos Date: Tue, 13 Nov 2018 09:50:26 -0200 Subject: [PATCH 04/11] Description --- .../BridgingPlugin/src/main/resources/BCgephi/Bundle.properties | 2 +- .../src/main/resources/BCgephi/Bundle_pt_BR.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/BridgingPlugin/src/main/resources/BCgephi/Bundle.properties b/modules/BridgingPlugin/src/main/resources/BCgephi/Bundle.properties index 46a5a3f108..6ad7467dfb 100644 --- a/modules/BridgingPlugin/src/main/resources/BCgephi/Bundle.properties +++ b/modules/BridgingPlugin/src/main/resources/BCgephi/Bundle.properties @@ -1,7 +1,7 @@ BridgingCentralityMetricBuilder.name=Bridging Centrality Algorithm BridgingCentralityMetricUI.displayName=Bridging Centrality -BridgingCentralityMetricUI.shortDescription=Bridging Centrality (BC) depicts nodes connected to immediate neighbors that, by turn, are connecting clusters of nodes. BC is the result of Betweenness Centrality multiplied by Bridging Node Centrality. BC can be useful to identify links for groups of nodes. For instance, considering a protein network, BC could point up proteins acting as a bridge betweenn complementary molecular functions. This plugin appends the new data columns to the Gephi data laboratory tab: Betweenness, Bridging Node and Bridging Centrality. +BridgingCentralityMetricUI.shortDescription=Bridging Centrality (BC) depicts nodes connected to immediate neighbors that, by turn, are connecting clusters of nodes. BC is the result of Betweenness Centrality multiplied by Bridging Node Centrality. BC can be useful to identify links for groups of nodes. For instance, considering a protein network, BC could point up proteins acting as a bridge between corresponding molecular functions. This plugin appends the new data columns to the Gephi data laboratory tab: Betweenness, Bridging Node and Bridging Centrality. BridgingCentralityMetricPanel.isDirectedLabel.text=Directed Network BridgingCentralityMetricPanel.titleLabel.text=Bridging Centrality diff --git a/modules/BridgingPlugin/src/main/resources/BCgephi/Bundle_pt_BR.properties b/modules/BridgingPlugin/src/main/resources/BCgephi/Bundle_pt_BR.properties index 25d7be07ab..c585394e93 100644 --- a/modules/BridgingPlugin/src/main/resources/BCgephi/Bundle_pt_BR.properties +++ b/modules/BridgingPlugin/src/main/resources/BCgephi/Bundle_pt_BR.properties @@ -1,7 +1,7 @@ BridgingCentralityMetricBuilder.name=Bridging Centrality Algorithm BridgingCentralityMetricUI.displayName=Bridging Centrality -BridgingCentralityMetricUI.shortDescription=Bridging Centrality (BC) depicts nodes connected to immediate neighbors that, by turn, are connecting clusters of nodes. BC is the result of Betweenness Centrality multiplied by Bridging Node Centrality. BC can be useful to identify links for groups of nodes. For instance, considering a protein network, BC could point up proteins acting as a bridge betweenn complementary molecular functions. This plugin appends the new data columns to the Gephi data laboratory tab: Betweenness, Bridging Node and Bridging Centrality. +BridgingCentralityMetricUI.shortDescription=Bridging Centrality (BC) depicts nodes connected to immediate neighbors that, by turn, are connecting clusters of nodes. BC is the result of Betweenness Centrality multiplied by Bridging Node Centrality. BC can be useful to identify links for groups of nodes. For instance, considering a protein network, BC could point up proteins acting as a bridge between corresponding molecular functions. This plugin appends the new data columns to the Gephi data laboratory tab: Betweenness, Bridging Node and Bridging Centrality. BridgingCentralityMetricPanel.isDirectedLabel.text=Rede dirigida BridgingCentralityMetricPanel.titleLabel.text=Bridging Centrality From 3340a9974bed9e6aabfd2fc758b7aaaf32d11497 Mon Sep 17 00:00:00 2001 From: Anderson Santos Date: Wed, 14 Nov 2018 20:52:16 -0200 Subject: [PATCH 05/11] Appended columns to the Data laboratory set to BigDecimal, and solving the problem of limited numerical precision --- .../main/java/BCgephi/BridgingCentralityMetric.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/modules/BridgingPlugin/src/main/java/BCgephi/BridgingCentralityMetric.java b/modules/BridgingPlugin/src/main/java/BCgephi/BridgingCentralityMetric.java index 6eeb36b596..90dd106c14 100644 --- a/modules/BridgingPlugin/src/main/java/BCgephi/BridgingCentralityMetric.java +++ b/modules/BridgingPlugin/src/main/java/BCgephi/BridgingCentralityMetric.java @@ -29,6 +29,7 @@ import org.jfree.data.xy.XYSeries; import org.jfree.data.xy.XYSeriesCollection; import org.openide.util.NbBundle; +import java.math.BigDecimal; /** * @@ -147,15 +148,15 @@ private void initializeAttributeColunms(GraphModel graphModel) { Table nodeTable = graphModel.getNodeTable(); if ( ! nodeTable.hasColumn(BETWEENNESS) ){ - nodeTable.addColumn(BETWEENNESS, "Betweenness Centrality", Double.class, (double) 0); + nodeTable.addColumn(BETWEENNESS, "Betweenness Centrality", BigDecimal.class, new BigDecimal("0")); } if ( ! nodeTable.hasColumn(BRIDGING_COEFFICIENT) ){ - nodeTable.addColumn(BRIDGING_COEFFICIENT, "Bridging Coefficient", Double.class, (double) 0); + nodeTable.addColumn(BRIDGING_COEFFICIENT, "Bridging Coefficient", BigDecimal.class, new BigDecimal("0")); } if ( ! nodeTable.hasColumn(BRIDGING_CENTRALITY) ){ - nodeTable.addColumn(BRIDGING_CENTRALITY, "Bridging Centrality", Double.class, (double) 0); + nodeTable.addColumn(BRIDGING_CENTRALITY, "Bridging Centrality", BigDecimal.class, new BigDecimal("0")); } } @@ -313,9 +314,9 @@ private void saveCalculatedValues(Graph graph, HashMap indicies, //The bridging centrality is just a multiplication of two other metrics bridging_cent[s_index] = bridging_coef * mybetweenness[s_index]; - s.setAttribute(BETWEENNESS, nodeBetweenness[s_index]); - s.setAttribute(BRIDGING_COEFFICIENT, bridging_coef); - s.setAttribute(BRIDGING_CENTRALITY, bridging_cent[s_index]); + s.setAttribute(BETWEENNESS, new BigDecimal (nodeBetweenness[s_index])); + s.setAttribute(BRIDGING_COEFFICIENT, new BigDecimal (bridging_coef)); + s.setAttribute(BRIDGING_CENTRALITY, new BigDecimal (bridging_cent[s_index])); } } From 2d5e813ff7ad2251904c663c5f3d18fdca4625e6 Mon Sep 17 00:00:00 2001 From: Anderson Santos Date: Mon, 19 Nov 2018 19:15:36 -0200 Subject: [PATCH 06/11] Resolving conflict among the betweenness column created by Gephi versus the column with the same name created by this plugin; plotting in the VERTICAL orientation; dividing the domain into ten tips according to the maximum value --- .../BCgephi/BridgingCentralityMetric.java | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/modules/BridgingPlugin/src/main/java/BCgephi/BridgingCentralityMetric.java b/modules/BridgingPlugin/src/main/java/BCgephi/BridgingCentralityMetric.java index 90dd106c14..1dd3be3dad 100644 --- a/modules/BridgingPlugin/src/main/java/BCgephi/BridgingCentralityMetric.java +++ b/modules/BridgingPlugin/src/main/java/BCgephi/BridgingCentralityMetric.java @@ -30,6 +30,9 @@ import org.jfree.data.xy.XYSeriesCollection; import org.openide.util.NbBundle; import java.math.BigDecimal; +import org.jfree.chart.plot.XYPlot; +import org.jfree.chart.axis.NumberAxis; +import org.jfree.chart.axis.NumberTickUnit; /** * @@ -39,6 +42,7 @@ public class BridgingCentralityMetric extends GraphDistance implements Statistic private static final Logger logger = Logger.getLogger(BridgingCentralityMetric.class.getName()); + public static final String BETWEENNESS_CENTRALITY = "betweennesscentrality2"; public static final String BRIDGING_CENTRALITY = "bridgingcentrality"; public static final String BRIDGING_COEFFICIENT = "bridgingcoefficient"; @@ -147,8 +151,8 @@ private void initializeAttributeColunms(GraphModel graphModel) { Table nodeTable = graphModel.getNodeTable(); - if ( ! nodeTable.hasColumn(BETWEENNESS) ){ - nodeTable.addColumn(BETWEENNESS, "Betweenness Centrality", BigDecimal.class, new BigDecimal("0")); + if ( ! nodeTable.hasColumn(BETWEENNESS_CENTRALITY) ){ + nodeTable.addColumn(BETWEENNESS_CENTRALITY, "Betweenness Centrality", BigDecimal.class, new BigDecimal("0")); } if ( ! nodeTable.hasColumn(BRIDGING_COEFFICIENT) ){ @@ -314,7 +318,7 @@ private void saveCalculatedValues(Graph graph, HashMap indicies, //The bridging centrality is just a multiplication of two other metrics bridging_cent[s_index] = bridging_coef * mybetweenness[s_index]; - s.setAttribute(BETWEENNESS, new BigDecimal (nodeBetweenness[s_index])); + s.setAttribute(BETWEENNESS_CENTRALITY, new BigDecimal (nodeBetweenness[s_index])); s.setAttribute(BRIDGING_COEFFICIENT, new BigDecimal (bridging_coef)); s.setAttribute(BRIDGING_CENTRALITY, new BigDecimal (bridging_cent[s_index])); } @@ -471,20 +475,26 @@ private String createImageFile(TempDir tempDir, double[] pVals, String pName, St XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(dSeries); + dataset.setAutoWidth(true); JFreeChart chart = ChartFactory.createXYLineChart( pName, pX, pY, dataset, - PlotOrientation.HORIZONTAL, + PlotOrientation.VERTICAL, true, false, false); + XYPlot xyPlot = (XYPlot) chart.getPlot(); + NumberAxis domain = (NumberAxis) xyPlot.getDomainAxis(); + domain.setRange(0.00, domain.getUpperBound()); + domain.setTickUnit(new NumberTickUnit(domain.getUpperBound()/10)); + chart.removeLegend(); ChartUtils.decorateChart(chart); - ChartUtils.scaleChart(chart, dSeries, normalized); + // ChartUtils.scaleChart(chart, dSeries, normalized); return ChartUtils.renderChart(chart, pName + ".png"); } From b98e0410e11fb4aa78ff39ee9bd33853514dd277 Mon Sep 17 00:00:00 2001 From: Eduardo Ramos Date: Fri, 4 Jan 2019 17:21:44 +0100 Subject: [PATCH 07/11] Fix pull request problems #200 --- modules/BridgingPlugin/nb-configuration.xml | 18 - modules/BridgingPlugin/nbactions.xml | 16 - modules/BridgingPlugin/pom.xml | 18 +- .../BridgingCentralityMetric.java | 331 +++++++++--------- .../BridgingCentralityMetricBuilder.java | 2 +- .../BridgingCentralityMetricPanel.form | 6 +- .../BridgingCentralityMetricPanel.java | 2 +- .../BridgingCentralityMetricUI.java | 2 +- .../BridgingPlugin/src/main/nbm/manifest.mf | 2 +- .../bridgingcoefficient}/Bundle.properties | 0 .../Bundle_pt_BR.properties | 0 nb-configuration.xml | 18 - 12 files changed, 175 insertions(+), 240 deletions(-) delete mode 100644 modules/BridgingPlugin/nb-configuration.xml delete mode 100644 modules/BridgingPlugin/nbactions.xml rename modules/BridgingPlugin/src/main/java/{BCgephi => ia/ppgco/facom/ufu/br/gephi/plugin/bridgingcoefficient}/BridgingCentralityMetric.java (71%) rename modules/BridgingPlugin/src/main/java/{BCgephi => ia/ppgco/facom/ufu/br/gephi/plugin/bridgingcoefficient}/BridgingCentralityMetricBuilder.java (91%) rename modules/BridgingPlugin/src/main/java/{BCgephi => ia/ppgco/facom/ufu/br/gephi/plugin/bridgingcoefficient}/BridgingCentralityMetricPanel.form (91%) rename modules/BridgingPlugin/src/main/java/{BCgephi => ia/ppgco/facom/ufu/br/gephi/plugin/bridgingcoefficient}/BridgingCentralityMetricPanel.java (99%) rename modules/BridgingPlugin/src/main/java/{BCgephi => ia/ppgco/facom/ufu/br/gephi/plugin/bridgingcoefficient}/BridgingCentralityMetricUI.java (98%) rename modules/BridgingPlugin/src/main/resources/{BCgephi => ia/ppgco/facom/ufu/br/gephi/plugin/bridgingcoefficient}/Bundle.properties (100%) rename modules/BridgingPlugin/src/main/resources/{BCgephi => ia/ppgco/facom/ufu/br/gephi/plugin/bridgingcoefficient}/Bundle_pt_BR.properties (100%) delete mode 100644 nb-configuration.xml diff --git a/modules/BridgingPlugin/nb-configuration.xml b/modules/BridgingPlugin/nb-configuration.xml deleted file mode 100644 index c3e8f4d1fd..0000000000 --- a/modules/BridgingPlugin/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - false - - diff --git a/modules/BridgingPlugin/nbactions.xml b/modules/BridgingPlugin/nbactions.xml deleted file mode 100644 index ca77c79221..0000000000 --- a/modules/BridgingPlugin/nbactions.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - run - - nbm - - - nbm:cluster - nbm:run-ide - - - -J-Xmx1024m -J-Xss2m -J-Xms32m -J-XX:PermSize=32m - - - diff --git a/modules/BridgingPlugin/pom.xml b/modules/BridgingPlugin/pom.xml index 07c1a35b23..6c55a1bb6f 100644 --- a/modules/BridgingPlugin/pom.xml +++ b/modules/BridgingPlugin/pom.xml @@ -8,7 +8,7 @@ ia.ppgco.facom.ufu.br - bridge-plugin + bridge-gephi-plugin 1.0.1 nbm @@ -53,12 +53,6 @@ org.gephi core-library-wrapper - - - jfree - jfreechart - - org.netbeans.api @@ -68,11 +62,6 @@ org.netbeans.api org-openide-util-lookup - - org.jfree - jfreechart - 1.0.19 - @@ -82,9 +71,10 @@ nbm-maven-plugin Apache 2.0 - Getúlio de Morais Pereira and Anderson Rodrigues dos Santos + Getúlio de Morais Pereira + Anderson Rodrigues dos Santos santosardr@ufu.br - $sourcecode_url + https://github.com/santosardr/gephi-plugins diff --git a/modules/BridgingPlugin/src/main/java/BCgephi/BridgingCentralityMetric.java b/modules/BridgingPlugin/src/main/java/ia/ppgco/facom/ufu/br/gephi/plugin/bridgingcoefficient/BridgingCentralityMetric.java similarity index 71% rename from modules/BridgingPlugin/src/main/java/BCgephi/BridgingCentralityMetric.java rename to modules/BridgingPlugin/src/main/java/ia/ppgco/facom/ufu/br/gephi/plugin/bridgingcoefficient/BridgingCentralityMetric.java index 1dd3be3dad..c83d6adfee 100644 --- a/modules/BridgingPlugin/src/main/java/BCgephi/BridgingCentralityMetric.java +++ b/modules/BridgingPlugin/src/main/java/ia/ppgco/facom/ufu/br/gephi/plugin/bridgingcoefficient/BridgingCentralityMetric.java @@ -1,4 +1,4 @@ -package BCgephi; +package ia.ppgco.facom.ufu.br.gephi.plugin.bridgingcoefficient; import java.io.IOException; import java.time.Duration; @@ -39,37 +39,37 @@ * @author getulio */ public class BridgingCentralityMetric extends GraphDistance implements Statistics { - - private static final Logger logger = Logger.getLogger(BridgingCentralityMetric.class.getName()); - + + private static final Logger LOG = Logger.getLogger(BridgingCentralityMetric.class.getName()); + public static final String BETWEENNESS_CENTRALITY = "betweennesscentrality2"; public static final String BRIDGING_CENTRALITY = "bridgingcentrality"; public static final String BRIDGING_COEFFICIENT = "bridgingcoefficient"; - + // relatorio de execucao private String report = ""; // controle de execucao, com possibilidade de interrupcao pelo usuario private boolean cancelled = false; private ProgressTicket progressTicket; - + // parametros de entrada do usuario private boolean directed; private boolean normalized; - + // tomada de tempo de execucao private LocalDateTime start = null; private LocalDateTime stop_betweeness = null; private LocalDateTime stop_bridging = null; - + // estatisticas calculadas pelo algoritmo private double[] mybetweenness; private double[] bridging_cent; private double bridging_coef; - + // variaveis globais private int Number_of_Nodes; - + /** * Bridging Centrality algorithm .... * @@ -77,36 +77,35 @@ public class BridgingCentralityMetric extends GraphDistance implements Statistic */ @Override public void execute(GraphModel graphModel) { - directed = graphModel.getGraphVisible().isDirected(); - Graph graph = null; - if ( directed ) { + final Graph graph; + if (directed) { graph = graphModel.getDirectedGraphVisible(); } else { graph = graphModel.getUndirectedGraphVisible(); } - - execute(graph); - logger.log(java.util.logging.Level.INFO, "Success Bridging Centrality calculations."); + + execute(graph); + LOG.log(java.util.logging.Level.INFO, "Success Bridging Centrality calculations."); } - + @Override public void execute(Graph graph) { - + graph.readLock(); - + try { - + initializeAttributeColunms(graph.getModel()); //number of nodes Number_of_Nodes = graph.getNodeCount(); - //creates one array for each coeficient to be calculated + //creates one array for each coeficient to be calculated mybetweenness = new double[Number_of_Nodes]; bridging_cent = new double[Number_of_Nodes]; - //a humble index strategy, a sequential index + //a humble index strategy, a sequential index HashMap indicies = createIndiciesMap(graph); //marks the start of the process start = LocalDateTime.now(); @@ -115,7 +114,7 @@ public void execute(Graph graph) { //mark the end of the process stop_betweeness = LocalDateTime.now(); // calculates bridging coefficient and bridging centrality - saveCalculatedValues(graph, indicies, mybetweenness); + saveCalculatedValues(graph, indicies, mybetweenness); //mark the end of the process of the bridging metrics stop_bridging = LocalDateTime.now(); // ----------- @@ -123,150 +122,150 @@ public void execute(Graph graph) { String msg = NbBundle.getMessage(BridgingCentralityMetric.class, "BridgingCentralityMetric.alert.message"); String title = NbBundle.getMessage(BridgingCentralityMetric.class, "BridgingCentralityMetric.alert.title"); JOptionPane.showMessageDialog(null, msg, title, JOptionPane.WARNING_MESSAGE); - logger.log(java.util.logging.Level.WARNING, msg); + LOG.log(java.util.logging.Level.WARNING, msg); } else { - //Print results - Duration diff_1 = Duration.between(start, stop_betweeness); - Duration diff_2 = Duration.between(stop_betweeness, stop_bridging); - String duration = NbBundle.getMessage(BridgingCentralityMetric.class, "BridgingCentralityMetric.report.duration"); + //Print results + Duration diff_1 = Duration.between(start, stop_betweeness); + Duration diff_2 = Duration.between(stop_betweeness, stop_bridging); + String duration = NbBundle.getMessage(BridgingCentralityMetric.class, "BridgingCentralityMetric.report.duration"); - report += "" + duration + " : " + diff_1.getSeconds() + " seconds (Betweenness)
      "; - report += "" + duration + " : " + diff_2.getSeconds() + " seconds (Bridging)
      "; - report += "" + duration + " : " + (diff_1.getSeconds() + diff_2.getSeconds()) + " seconds (Total)
      "; + report += "" + duration + " : " + diff_1.getSeconds() + " seconds (Betweenness)
      "; + report += "" + duration + " : " + diff_2.getSeconds() + " seconds (Bridging)
      "; + report += "" + duration + " : " + (diff_1.getSeconds() + diff_2.getSeconds()) + " seconds (Total)
      "; - report += "
      "; + report += "
      "; } // ----------- } finally { graph.readUnlock(); } } - + /** * Inicializa a tabela de nós - * - * @param graphModel + * + * @param graphModel */ private void initializeAttributeColunms(GraphModel graphModel) { - + Table nodeTable = graphModel.getNodeTable(); - - if ( ! nodeTable.hasColumn(BETWEENNESS_CENTRALITY) ){ + + if (!nodeTable.hasColumn(BETWEENNESS_CENTRALITY)) { nodeTable.addColumn(BETWEENNESS_CENTRALITY, "Betweenness Centrality", BigDecimal.class, new BigDecimal("0")); } - - if ( ! nodeTable.hasColumn(BRIDGING_COEFFICIENT) ){ + + if (!nodeTable.hasColumn(BRIDGING_COEFFICIENT)) { nodeTable.addColumn(BRIDGING_COEFFICIENT, "Bridging Coefficient", BigDecimal.class, new BigDecimal("0")); } - - if ( ! nodeTable.hasColumn(BRIDGING_CENTRALITY) ){ + + if (!nodeTable.hasColumn(BRIDGING_CENTRALITY)) { nodeTable.addColumn(BRIDGING_CENTRALITY, "Bridging Centrality", BigDecimal.class, new BigDecimal("0")); } } - + @Override public HashMap createIndiciesMap(Graph graph) { - + HashMap indicies = new HashMap(); - + int index = 0; for (Node n : graph.getNodes()) { indicies.put(n, index); index++; } - + return indicies; } /** - * + * * @param graph * @param indicies * @param directed * @param normalized - * + * * @return array with betweeness statistics */ private double[] calculateBetweeness(Graph graph, HashMap indicies, boolean directed, boolean normalized) { - - double[] nodeBetweenness = new double[ Number_of_Nodes ]; + + double[] nodeBetweenness = new double[Number_of_Nodes]; int count = 0; Progress.start(progressTicket, Number_of_Nodes); //Bread First Search (BFS) to calculate all the shortest paths from node s to t for (Node s : graph.getNodes()) { - //The below structures are candidates to performance improvments: + //The below structures are candidates to performance improvments: //Creates a stack for each node, ... Stack S = new Stack(); - //... a linked listed for each node, ... - LinkedList[] Pred = new LinkedList[ Number_of_Nodes ]; + //... a linked listed for each node, ... + LinkedList[] Pred = new LinkedList[Number_of_Nodes]; // ... define sigma(s, t) as the number of shortest paths between nodes s and t ... - double[] sigma = new double[ Number_of_Nodes ]; + double[] sigma = new double[Number_of_Nodes]; //...and also a distance for each node. - int[] dist = new int[ Number_of_Nodes ]; + int[] dist = new int[Number_of_Nodes]; int s_index = indicies.get(s); - //all parameters are set empty - BFS_Initialization( Pred, sigma, dist, s_index, Number_of_Nodes ); + //all parameters are set empty + BFS_Initialization(Pred, sigma, dist, s_index, Number_of_Nodes); LinkedList Q = new LinkedList(); - //All nodes are added to the end of the Q list + //All nodes are added to the end of the Q list //Starting node: 1. Choose the starting node s and put it on the queue Q. Q.addLast(s); - while ( ! Q.isEmpty() ) { - //The calculation always starts from first node. 1. dequeue v from Q + while (!Q.isEmpty()) { + //The calculation always starts from first node. 1. dequeue v from Q Node v = Q.removeFirst(); - //Despite of being removed of the list the node is stored in a stack S + //Despite of being removed of the list the node is stored in a stack S //This stack will be poped up to simulate the backtracking of the shortest paths //from all nodes s and t; and allows us to calculate the mybetweenness in the process S.push(v); - //Recovery of the node index. - //Using this index we will directely access the 'dist' and 'sigma' attributes of the node + //Recovery of the node index. + //Using this index we will directely access the 'dist' and 'sigma' attributes of the node int v_index = indicies.get(v); - //Read all edges conected to the node + //Read all edges conected to the node EdgeIterable edgeIter = getEdgeIter(graph, v, directed); - //Iterate for all edges to access their nodes in the opposite side + //Iterate for all edges to access their nodes in the opposite side for (Edge edge : edgeIter) { //Obtain a new node in the opposite edge of the node Node reachable = graph.getOpposite(v, edge); - //recover the index of the reachable node - //Using this index we will directely access the 'dist' and 'sigma' attributes of the reachable node + //recover the index of the reachable node + //Using this index we will directely access the 'dist' and 'sigma' attributes of the reachable node int r_index = indicies.get(reachable); //if the reachable node where not investigated yet (dist<0) ... if (dist[r_index] < 0) { - //... add the reachable node to the list of further nodes to be analysed ... + //... add the reachable node to the list of further nodes to be analysed ... Q.addLast(reachable); - //... and increment the 'dist' of the reachable node to the value of the initial node plus zero + //... and increment the 'dist' of the reachable node to the value of the initial node plus zero dist[r_index] = dist[v_index] + 1; //It meaks sense because the distance from the reachable node to the current node is exactly 1. } //If the reachable node was just incorporated to the list of further analyses then the next condition - //will be always true, even because v_index no longer changes. However, the current node here - //could be a reachable node from another one causing the increment of the distantce 'dist'. Once the - //distance is augmented by one the node no longer will be analysed (no loops). Still, the - //next condition certificates the 'sigma' sum only in care of difference of exacltly one edge between - //the current node and the reachable node, no matter the value of 'dist'. + //will be always true, even because v_index no longer changes. However, the current node here + //could be a reachable node from another one causing the increment of the distantce 'dist'. Once the + //distance is augmented by one the node no longer will be analysed (no loops). Still, the + //next condition certificates the 'sigma' sum only in care of difference of exacltly one edge between + //the current node and the reachable node, no matter the value of 'dist'. if (dist[r_index] == (dist[v_index] + 1)) { sigma[r_index] = sigma[r_index] + sigma[v_index]; - //The current node v will be added to the list of nodes to visit of the reachable node + //The current node v will be added to the list of nodes to visit of the reachable node Pred[r_index].addLast(v); } } } - + // ------------- //All nodes and its connections had its paths length computed. //Now is possible to calculate the mybetweenness poping up the stack created with the BFS //1. set delta(v) to zero for all nodes v in V. - double[] delta = new double[ Number_of_Nodes ]; + double[] delta = new double[Number_of_Nodes]; //3. while S is not empty, ... - while ( ! S.empty() ) { + while (!S.empty()) { //... pop w off S Node w = S.pop(); - + int w_index = indicies.get(w); - + ListIterator it = Pred[w_index].listIterator(); while (it.hasNext()) { Node u = it.next(); @@ -280,71 +279,70 @@ private double[] calculateBetweeness(Graph graph, HashMap indicie //the remaining shortest paths to w. The incremental sum of all these shortests //paths proportions (deltas) raises the integral mybetweenness metric. } - + if (w != s) { nodeBetweenness[w_index] += delta[w_index]; } } - + count++; - + if (cancelled) { return nodeBetweenness; } - + Progress.progress(progressTicket, count); } - + // corrige e normaliza o resultado da mybetweenness calculateCorrection(graph, indicies, nodeBetweenness, directed, normalized); - return nodeBetweenness; + return nodeBetweenness; } - + /** * Salva as estatisticas calculadas como atributos de cada nó - * + * * @param graph * @param indicies - * @param nodeBetweenness + * @param nodeBetweenness */ private void saveCalculatedValues(Graph graph, HashMap indicies, double[] nodeBetweenness) { - + for (Node s : graph.getNodes()) { - + int s_index = indicies.get(s); - + bridging_coef = bridging_coeficient(graph, s); - //The bridging centrality is just a multiplication of two other metrics + //The bridging centrality is just a multiplication of two other metrics bridging_cent[s_index] = bridging_coef * mybetweenness[s_index]; - s.setAttribute(BETWEENNESS_CENTRALITY, new BigDecimal (nodeBetweenness[s_index])); - s.setAttribute(BRIDGING_COEFFICIENT, new BigDecimal (bridging_coef)); - s.setAttribute(BRIDGING_CENTRALITY, new BigDecimal (bridging_cent[s_index])); + s.setAttribute(BETWEENNESS_CENTRALITY, new BigDecimal(nodeBetweenness[s_index])); + s.setAttribute(BRIDGING_COEFFICIENT, new BigDecimal(bridging_coef)); + s.setAttribute(BRIDGING_CENTRALITY, new BigDecimal(bridging_cent[s_index])); } } /** * Aplica as correcoes/normalizacoes nos nós, para a betweeness - * + * * @param graph * @param indicies * @param nodeBetweenness * @param directed - * @param normalized + * @param normalized */ private void calculateCorrection(Graph graph, HashMap indicies, double[] nodeBetweenness, boolean directed, boolean normalized) { - - int s_index = 0; + int s_index; for (Node s : graph.getNodes()) { s_index = indicies.get(s); - + // corrige o resultado, para o caso de rede nao dirigida - if (! directed) { + if (!directed) { nodeBetweenness[s_index] /= 2; } - + // normaliza o resultado if (normalized) { nodeBetweenness[s_index] /= directed ? (Number_of_Nodes - 1) * (Number_of_Nodes - 2) : (Number_of_Nodes - 1) * (Number_of_Nodes - 2) / 2; @@ -352,15 +350,15 @@ private void calculateCorrection(Graph graph, HashMap indicies, d } } - private void BFS_Initialization( LinkedList[] Pred, double[] sigma, int[] dist, int index, int n) { + private void BFS_Initialization(LinkedList[] Pred, double[] sigma, int[] dist, int index, int n) { //There is a potential problem in this function: the Node s is passed but never used. - //For what node these parameteres are being set? + //For what node these parameteres are being set? for (int w = 0; w < n; w++) { //1. Mark w as unvisited by setting dist[w] (the distance between s and the node w) to infinity. dist[w] = -1; //2. Set Pred[w] (nodes that immediately precede w on a shortest path from s) to the empty list. Pred[w] = new LinkedList(); - + sigma[w] = 0; } //The number of shortest paths start with the value 1 since sigma(v,v)=1 @@ -368,41 +366,40 @@ private void BFS_Initialization( LinkedList[] Pred, double[] sigma, int[] //Starting node: 2. Set dist[s] to 0. dist[index] = 0; } - + private EdgeIterable getEdgeIter(Graph graph, Node v, boolean directed) { - + if (directed) { return ((DirectedGraph) graph).getOutEdges(v); - } - + } + return graph.getEdges(v); } - + /** - * Should return plain text or HTML text that describe the algorithm - * execution. + * Should return plain text or HTML text that describe the algorithm execution. * * @return */ @Override public String getReport() { - + String htmlIMG1 = ""; String htmlIMG2 = ""; String htmlIMG3 = ""; - + try { TempDir tempDir = TempDirUtils.createTempDir(); htmlIMG1 = createImageFile(tempDir, bridging_cent, "Bridging Centrality Distribution", "Value", "Count"); - // htmlIMG2 = createImageFile(tempDir, bridging_coef, "Bridging Coefficient Distribution", "Value", "Count"); + // htmlIMG2 = createImageFile(tempDir, bridging_coef, "Bridging Coefficient Distribution", "Value", "Count"); htmlIMG3 = createImageFile(tempDir, mybetweenness, "Betweenness Centrality Distribution", "Value", "Count"); } catch (IOException ex) { - + String msg = NbBundle.getMessage(BridgingCentralityMetric.class, "BridgingCentralityMetric.error.message"); String title = NbBundle.getMessage(BridgingCentralityMetric.class, "BridgingCentralityMetric.error.title"); JOptionPane.showMessageDialog(null, msg, title, JOptionPane.ERROR_MESSAGE); - - logger.log(java.util.logging.Level.SEVERE, msg, ex); + + LOG.log(java.util.logging.Level.SEVERE, msg, ex); } String report_title = NbBundle.getMessage(BridgingCentralityMetric.class, "BridgingCentralityMetric.report.title"); @@ -413,53 +410,53 @@ public String getReport() { String value_2_1 = NbBundle.getMessage(BridgingCentralityMetric.class, "BridgingCentralityMetric.report.params.par_2.value_1"); String value_2_2 = NbBundle.getMessage(BridgingCentralityMetric.class, "BridgingCentralityMetric.report.params.par_2.value_2"); String results = NbBundle.getMessage(BridgingCentralityMetric.class, "BridgingCentralityMetric.report.results"); - + String param_2 = NbBundle.getMessage(BridgingCentralityMetric.class, "BridgingCentralityMetric.report.params.par_2"); - + String rep = "

      " + report_title + "

      " - + "
      " - + "
      " - + "

      " + params + " :

      " - + param_1 + " : " + (directed ? value_1_1 : value_1_2) + "
      " - + param_2 + " : " + (normalized ? value_2_1 : value_2_2) + "
      " - + "

      " + results + ":

      "; - + + "
      " + + "
      " + + "

      " + params + " :

      " + + param_1 + " : " + (directed ? value_1_1 : value_1_2) + "
      " + + param_2 + " : " + (normalized ? value_2_1 : value_2_2) + "
      " + + "

      " + results + ":

      "; + rep += report; - + String algorithms = NbBundle.getMessage(BridgingCentralityMetric.class, "BridgingCentralityMetric.report.algorithm"); String credits = NbBundle.getMessage(BridgingCentralityMetric.class, "BridgingCentralityMetric.report.credits"); String contact = NbBundle.getMessage(BridgingCentralityMetric.class, "BridgingCentralityMetric.report.contact"); - + rep += "

      " - + "
      Please, check the Data Laboratory Tab for the full listing of Bridging Centrality for the graph.
      " - + "

      " - + htmlIMG1 + "

      " - + htmlIMG2 + "

      " - + htmlIMG3 + "

      " - + "

      " - + "

      " + algorithms + ":

      " - + "
        " - + "
      • Ulrik Brandes, A Faster Algorithm for Betweenness Centrality, in Journal of Mathematical Sociology 25(2):163-177, (2001)
      • " - + "
      • Hwang, W., Cho, Y. R., Zhang, A., & Ramanathan, M. (2006, March). Bridging centrality: identifying bridging nodes in scale-free networks. In Proceedings of the 12th ACM SIGKDD international conference on Knowledge discovery and data mining (pp. 20-23).
      • " - + "
      " - + "" + credits + ": " - + "
        " - + "
      • Getúlio de Morais Pereira
      • " - + "
      • Anderson Rodrigues dos Santos
      • " - + "
          " - + "
        • " + contact + " : santosardr@ufu.br
        • " - + "
        " - + "
          " - + " "; - + + "
          Please, check the Data Laboratory Tab for the full listing of Bridging Centrality for the graph.
          " + + "

          " + + htmlIMG1 + "

          " + + htmlIMG2 + "

          " + + htmlIMG3 + "

          " + + "

          " + + "

          " + algorithms + ":

          " + + "
            " + + "
          • Ulrik Brandes, A Faster Algorithm for Betweenness Centrality, in Journal of Mathematical Sociology 25(2):163-177, (2001)
          • " + + "
          • Hwang, W., Cho, Y. R., Zhang, A., & Ramanathan, M. (2006, March). Bridging centrality: identifying bridging nodes in scale-free networks. In Proceedings of the 12th ACM SIGKDD international conference on Knowledge discovery and data mining (pp. 20-23).
          • " + + "
          " + + "" + credits + ": " + + "
            " + + "
          • Getúlio de Morais Pereira
          • " + + "
          • Anderson Rodrigues dos Santos
          • " + + "
              " + + "
            • " + contact + " : santosardr@ufu.br
            • " + + "
            " + + "
              " + + " "; + return rep; } - + private String createImageFile(TempDir tempDir, double[] pVals, String pName, String pX, String pY) { - + //distribution of nodeIDs Map dist = new HashMap(); - + for (int i = 0; i < Number_of_Nodes; i++) { Double d = pVals[i]; if (dist.containsKey(d)) { @@ -486,16 +483,16 @@ private String createImageFile(TempDir tempDir, double[] pVals, String pName, St true, false, false); - - XYPlot xyPlot = (XYPlot) chart.getPlot(); - NumberAxis domain = (NumberAxis) xyPlot.getDomainAxis(); + + XYPlot xyPlot = (XYPlot) chart.getPlot(); + NumberAxis domain = (NumberAxis) xyPlot.getDomainAxis(); domain.setRange(0.00, domain.getUpperBound()); - domain.setTickUnit(new NumberTickUnit(domain.getUpperBound()/10)); - + domain.setTickUnit(new NumberTickUnit(domain.getUpperBound() / 10)); + chart.removeLegend(); ChartUtils.decorateChart(chart); - // ChartUtils.scaleChart(chart, dSeries, normalized); - + // ChartUtils.scaleChart(chart, dSeries, normalized); + return ChartUtils.renderChart(chart, pName + ".png"); } @@ -513,9 +510,9 @@ private static double bridging_coeficient(Graph graph, Node node) { double d = 0.0; Iterator it = graph.getNeighbors(node).iterator(); - while( it.hasNext() ) { + while (it.hasNext()) { Node t = (Node) it.next(); - d += 1.0 / graph.getDegree( t ); + d += 1.0 / graph.getDegree(t); } return n / d; @@ -534,7 +531,7 @@ public boolean cancel() { public void setProgressTicket(ProgressTicket progressTicket) { this.progressTicket = progressTicket; } - + @Override public boolean isDirected() { return directed; @@ -543,8 +540,8 @@ public boolean isDirected() { @Override public void setDirected(boolean directed) { this.directed = directed; - } - + } + @Override public boolean isNormalized() { return normalized; @@ -553,5 +550,5 @@ public boolean isNormalized() { @Override public void setNormalized(boolean normalized) { this.normalized = normalized; - } + } } diff --git a/modules/BridgingPlugin/src/main/java/BCgephi/BridgingCentralityMetricBuilder.java b/modules/BridgingPlugin/src/main/java/ia/ppgco/facom/ufu/br/gephi/plugin/bridgingcoefficient/BridgingCentralityMetricBuilder.java similarity index 91% rename from modules/BridgingPlugin/src/main/java/BCgephi/BridgingCentralityMetricBuilder.java rename to modules/BridgingPlugin/src/main/java/ia/ppgco/facom/ufu/br/gephi/plugin/bridgingcoefficient/BridgingCentralityMetricBuilder.java index 4f0a44e827..152d8da612 100644 --- a/modules/BridgingPlugin/src/main/java/BCgephi/BridgingCentralityMetricBuilder.java +++ b/modules/BridgingPlugin/src/main/java/ia/ppgco/facom/ufu/br/gephi/plugin/bridgingcoefficient/BridgingCentralityMetricBuilder.java @@ -1,4 +1,4 @@ -package BCgephi; +package ia.ppgco.facom.ufu.br.gephi.plugin.bridgingcoefficient; import org.gephi.statistics.spi.Statistics; import org.gephi.statistics.spi.StatisticsBuilder; diff --git a/modules/BridgingPlugin/src/main/java/BCgephi/BridgingCentralityMetricPanel.form b/modules/BridgingPlugin/src/main/java/ia/ppgco/facom/ufu/br/gephi/plugin/bridgingcoefficient/BridgingCentralityMetricPanel.form similarity index 91% rename from modules/BridgingPlugin/src/main/java/BCgephi/BridgingCentralityMetricPanel.form rename to modules/BridgingPlugin/src/main/java/ia/ppgco/facom/ufu/br/gephi/plugin/bridgingcoefficient/BridgingCentralityMetricPanel.form index c7f3d7e369..f2eb2d3b75 100644 --- a/modules/BridgingPlugin/src/main/java/BCgephi/BridgingCentralityMetricPanel.form +++ b/modules/BridgingPlugin/src/main/java/ia/ppgco/facom/ufu/br/gephi/plugin/bridgingcoefficient/BridgingCentralityMetricPanel.form @@ -126,14 +126,14 @@ - + - + @@ -150,7 +150,7 @@ - + diff --git a/modules/BridgingPlugin/src/main/java/BCgephi/BridgingCentralityMetricPanel.java b/modules/BridgingPlugin/src/main/java/ia/ppgco/facom/ufu/br/gephi/plugin/bridgingcoefficient/BridgingCentralityMetricPanel.java similarity index 99% rename from modules/BridgingPlugin/src/main/java/BCgephi/BridgingCentralityMetricPanel.java rename to modules/BridgingPlugin/src/main/java/ia/ppgco/facom/ufu/br/gephi/plugin/bridgingcoefficient/BridgingCentralityMetricPanel.java index a9177b94f4..d648f340de 100644 --- a/modules/BridgingPlugin/src/main/java/BCgephi/BridgingCentralityMetricPanel.java +++ b/modules/BridgingPlugin/src/main/java/ia/ppgco/facom/ufu/br/gephi/plugin/bridgingcoefficient/BridgingCentralityMetricPanel.java @@ -1,4 +1,4 @@ -package BCgephi; +package ia.ppgco.facom.ufu.br.gephi.plugin.bridgingcoefficient; /** * diff --git a/modules/BridgingPlugin/src/main/java/BCgephi/BridgingCentralityMetricUI.java b/modules/BridgingPlugin/src/main/java/ia/ppgco/facom/ufu/br/gephi/plugin/bridgingcoefficient/BridgingCentralityMetricUI.java similarity index 98% rename from modules/BridgingPlugin/src/main/java/BCgephi/BridgingCentralityMetricUI.java rename to modules/BridgingPlugin/src/main/java/ia/ppgco/facom/ufu/br/gephi/plugin/bridgingcoefficient/BridgingCentralityMetricUI.java index 7c14765df3..26a3954ed6 100644 --- a/modules/BridgingPlugin/src/main/java/BCgephi/BridgingCentralityMetricUI.java +++ b/modules/BridgingPlugin/src/main/java/ia/ppgco/facom/ufu/br/gephi/plugin/bridgingcoefficient/BridgingCentralityMetricUI.java @@ -1,4 +1,4 @@ -package BCgephi; +package ia.ppgco.facom.ufu.br.gephi.plugin.bridgingcoefficient; import javax.swing.JPanel; import org.gephi.graph.api.Graph; diff --git a/modules/BridgingPlugin/src/main/nbm/manifest.mf b/modules/BridgingPlugin/src/main/nbm/manifest.mf index c39d47f66c..ebc7706b53 100644 --- a/modules/BridgingPlugin/src/main/nbm/manifest.mf +++ b/modules/BridgingPlugin/src/main/nbm/manifest.mf @@ -1,5 +1,5 @@ Manifest-Version: 1.0 OpenIDE-Module-Name: Bridging Centrality Plugin OpenIDE-Module-Short-Description: Bridging Centrality Plugin -OpenIDE-Module-Long-Description: Bridging Centrality (BC) depicts nodes connected to immediate neighbors that, by turn, are connecting clusters of nodes. BC is the result of Betweenness Centrality multiplied by Bridging Node Centrality. BC can be useful to identify links for groups of nodes. This plugin appends the new data columns to the Gephi data laboratory tab: Betweenness, Bridging Node and Bridging Centrality. +OpenIDE-Module-Long-Description: Bridging Centrality (BC) depicts nodes connected to immediate neighbors that, by turn, are connecting clusters of nodes. BC is the result of Betweenness Centrality multiplied by Bridging Node Centrality. BC can be useful to identify links for groups of nodes. This plugin appends the new data columns to the Gephi data laboratory tab: Betweenness, Bridging Node and Bridging Centrality. OpenIDE-Module-Display-Category: Metric diff --git a/modules/BridgingPlugin/src/main/resources/BCgephi/Bundle.properties b/modules/BridgingPlugin/src/main/resources/ia/ppgco/facom/ufu/br/gephi/plugin/bridgingcoefficient/Bundle.properties similarity index 100% rename from modules/BridgingPlugin/src/main/resources/BCgephi/Bundle.properties rename to modules/BridgingPlugin/src/main/resources/ia/ppgco/facom/ufu/br/gephi/plugin/bridgingcoefficient/Bundle.properties diff --git a/modules/BridgingPlugin/src/main/resources/BCgephi/Bundle_pt_BR.properties b/modules/BridgingPlugin/src/main/resources/ia/ppgco/facom/ufu/br/gephi/plugin/bridgingcoefficient/Bundle_pt_BR.properties similarity index 100% rename from modules/BridgingPlugin/src/main/resources/BCgephi/Bundle_pt_BR.properties rename to modules/BridgingPlugin/src/main/resources/ia/ppgco/facom/ufu/br/gephi/plugin/bridgingcoefficient/Bundle_pt_BR.properties diff --git a/nb-configuration.xml b/nb-configuration.xml deleted file mode 100644 index 6af45c765e..0000000000 --- a/nb-configuration.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - false - - From ecba2e009e0a016404aa4c96d4020763a12b40d0 Mon Sep 17 00:00:00 2001 From: LuisFelipeNuness Date: Wed, 29 Mar 2023 11:33:48 -0300 Subject: [PATCH 08/11] bugfix isolated nodes --- modules/BridgingPlugin/pom.xml | 19 ++++++++++++++++++- .../BridgingCentralityMetric.java | 15 +++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/modules/BridgingPlugin/pom.xml b/modules/BridgingPlugin/pom.xml index 6c55a1bb6f..34320e84d2 100644 --- a/modules/BridgingPlugin/pom.xml +++ b/modules/BridgingPlugin/pom.xml @@ -9,7 +9,7 @@ ia.ppgco.facom.ufu.br bridge-gephi-plugin - 1.0.1 + 1.0.2 nbm Bridging Centrality Plugin @@ -73,6 +73,7 @@ Apache 2.0 Getúlio de Morais Pereira Anderson Rodrigues dos Santos + Luis Felipe Nunes Reis santosardr@ufu.br https://github.com/santosardr/gephi-plugins @@ -80,6 +81,22 @@ + + org.apache.maven.plugins + maven-jar-plugin + 2.4 + + true + + + + org.apache.maven.plugins + maven-compiler-plugin + + 8 + 8 + + diff --git a/modules/BridgingPlugin/src/main/java/ia/ppgco/facom/ufu/br/gephi/plugin/bridgingcoefficient/BridgingCentralityMetric.java b/modules/BridgingPlugin/src/main/java/ia/ppgco/facom/ufu/br/gephi/plugin/bridgingcoefficient/BridgingCentralityMetric.java index c83d6adfee..8e054ef7f6 100644 --- a/modules/BridgingPlugin/src/main/java/ia/ppgco/facom/ufu/br/gephi/plugin/bridgingcoefficient/BridgingCentralityMetric.java +++ b/modules/BridgingPlugin/src/main/java/ia/ppgco/facom/ufu/br/gephi/plugin/bridgingcoefficient/BridgingCentralityMetric.java @@ -443,6 +443,7 @@ public String getReport() { + "
                " + "
              • Getúlio de Morais Pereira
              • " + "
              • Anderson Rodrigues dos Santos
              • " + + "
              • Luis Felipe Nunes Reis
              • " + "
                  " + "
                • " + contact + " : santosardr@ufu.br
                • " + "
                " @@ -505,6 +506,9 @@ private String createImageFile(TempDir tempDir, double[] pVals, String pName, St * @return bridging coefficient value */ private static double bridging_coeficient(Graph graph, Node node) { + if(isIsolatedNode(graph,node)){ + return 0; + } //The inverse degree of a node divided by the inverse degree of all their imediate neighbors double n = 1.0 / graph.getDegree(node); @@ -551,4 +555,15 @@ public boolean isNormalized() { public void setNormalized(boolean normalized) { this.normalized = normalized; } + + public static boolean isIsolatedNode(Graph graph, Node node) { + for (Node s : graph.getNodes()) { + if (graph.isAdjacent(node, s)) { + return false; + } + } + // If loop ends without return false, it is an isolated node + return true; + } + } From 40d211eef0ef35c2985a75485dadd3a8ca984594 Mon Sep 17 00:00:00 2001 From: LuisFelipeNuness Date: Tue, 25 Apr 2023 11:32:09 -0300 Subject: [PATCH 09/11] resolving mbastian's suggestion --- .../bridgingcoefficient/BridgingCentralityMetric.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/BridgingPlugin/src/main/java/ia/ppgco/facom/ufu/br/gephi/plugin/bridgingcoefficient/BridgingCentralityMetric.java b/modules/BridgingPlugin/src/main/java/ia/ppgco/facom/ufu/br/gephi/plugin/bridgingcoefficient/BridgingCentralityMetric.java index 8e054ef7f6..7a85015130 100644 --- a/modules/BridgingPlugin/src/main/java/ia/ppgco/facom/ufu/br/gephi/plugin/bridgingcoefficient/BridgingCentralityMetric.java +++ b/modules/BridgingPlugin/src/main/java/ia/ppgco/facom/ufu/br/gephi/plugin/bridgingcoefficient/BridgingCentralityMetric.java @@ -557,8 +557,12 @@ public void setNormalized(boolean normalized) { } public static boolean isIsolatedNode(Graph graph, Node node) { - for (Node s : graph.getNodes()) { + + NodeIterable iterable = graph.getNodes(); + + for (Node s : iterable) { if (graph.isAdjacent(node, s)) { + iterable.doBreak(); return false; } } From 6ce1526d7f03f20390af3380b80f742f493e74b2 Mon Sep 17 00:00:00 2001 From: Anderson Santos Date: Wed, 30 Aug 2023 17:18:12 -0300 Subject: [PATCH 10/11] I am accepting some Netbeans editor advice. --- modules/BridgingPlugin/pom.xml | 2 +- .../BridgingCentralityMetric.java | 3 +-- .../BridgingCentralityMetricPanel.java | 1 - .../BridgingCentralityMetricUI.java | 12 ++---------- pom.xml | 15 +++++++++++++++ 5 files changed, 19 insertions(+), 14 deletions(-) diff --git a/modules/BridgingPlugin/pom.xml b/modules/BridgingPlugin/pom.xml index 34320e84d2..8cb97a804f 100644 --- a/modules/BridgingPlugin/pom.xml +++ b/modules/BridgingPlugin/pom.xml @@ -4,7 +4,7 @@ gephi-plugin-parent org.gephi - 0.9.2 + 0.10.0 ia.ppgco.facom.ufu.br diff --git a/modules/BridgingPlugin/src/main/java/ia/ppgco/facom/ufu/br/gephi/plugin/bridgingcoefficient/BridgingCentralityMetric.java b/modules/BridgingPlugin/src/main/java/ia/ppgco/facom/ufu/br/gephi/plugin/bridgingcoefficient/BridgingCentralityMetric.java index 7a85015130..17873894df 100644 --- a/modules/BridgingPlugin/src/main/java/ia/ppgco/facom/ufu/br/gephi/plugin/bridgingcoefficient/BridgingCentralityMetric.java +++ b/modules/BridgingPlugin/src/main/java/ia/ppgco/facom/ufu/br/gephi/plugin/bridgingcoefficient/BridgingCentralityMetric.java @@ -18,7 +18,6 @@ import javax.swing.JOptionPane; import org.gephi.graph.api.*; import org.gephi.statistics.plugin.ChartUtils; -import org.gephi.statistics.spi.Statistics; import org.gephi.utils.TempDirUtils; import org.gephi.utils.TempDirUtils.TempDir; import org.gephi.utils.progress.Progress; @@ -38,7 +37,7 @@ * * @author getulio */ -public class BridgingCentralityMetric extends GraphDistance implements Statistics { +public class BridgingCentralityMetric extends GraphDistance { private static final Logger LOG = Logger.getLogger(BridgingCentralityMetric.class.getName()); diff --git a/modules/BridgingPlugin/src/main/java/ia/ppgco/facom/ufu/br/gephi/plugin/bridgingcoefficient/BridgingCentralityMetricPanel.java b/modules/BridgingPlugin/src/main/java/ia/ppgco/facom/ufu/br/gephi/plugin/bridgingcoefficient/BridgingCentralityMetricPanel.java index d648f340de..faac527fa9 100644 --- a/modules/BridgingPlugin/src/main/java/ia/ppgco/facom/ufu/br/gephi/plugin/bridgingcoefficient/BridgingCentralityMetricPanel.java +++ b/modules/BridgingPlugin/src/main/java/ia/ppgco/facom/ufu/br/gephi/plugin/bridgingcoefficient/BridgingCentralityMetricPanel.java @@ -38,7 +38,6 @@ public void setNormalized(boolean normalized) { * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ - @SuppressWarnings("unchecked") // //GEN-BEGIN:initComponents private void initComponents() { diff --git a/modules/BridgingPlugin/src/main/java/ia/ppgco/facom/ufu/br/gephi/plugin/bridgingcoefficient/BridgingCentralityMetricUI.java b/modules/BridgingPlugin/src/main/java/ia/ppgco/facom/ufu/br/gephi/plugin/bridgingcoefficient/BridgingCentralityMetricUI.java index 26a3954ed6..1517732ed4 100644 --- a/modules/BridgingPlugin/src/main/java/ia/ppgco/facom/ufu/br/gephi/plugin/bridgingcoefficient/BridgingCentralityMetricUI.java +++ b/modules/BridgingPlugin/src/main/java/ia/ppgco/facom/ufu/br/gephi/plugin/bridgingcoefficient/BridgingCentralityMetricUI.java @@ -107,17 +107,9 @@ public int getPosition() { private static class StatSettings { - private boolean isDirectedGraph = false; - private boolean isNormalized = false; - private void save(BridgingCentralityMetric stat) { - this.isDirectedGraph = stat.isDirected(); - this.isNormalized = stat.isNormalized(); - } - - private void load(BridgingCentralityMetric stat) { - stat.setDirected(isDirectedGraph); - stat.setNormalized(isNormalized); + stat.isDirected(); + stat.isNormalized(); } } diff --git a/pom.xml b/pom.xml index 4c2a778e82..62e4fa4855 100644 --- a/pom.xml +++ b/pom.xml @@ -137,6 +137,14 @@ maven-scm-publish-plugin 3.1.0 + + org.netbeans.api + nbm-maven-plugin + 4.5 + + GPL-3.0 + + @@ -254,6 +262,13 @@ true + + org.netbeans.api + nbm-maven-plugin + + GPL-3.0 + + From fd7d7068b355d06c6c81c1e11ff4a78cb63adddc Mon Sep 17 00:00:00 2001 From: Anderson Santos Date: Wed, 30 Aug 2023 20:35:27 -0300 Subject: [PATCH 11/11] After updating the java version from 8 to 11 and insert the 'licenseName' property in the 'bridge-ghepi-plugin.pom' file the build error was resolved: Failed to execute goal org.gephi:gephi-maven-plugin:1.3.4:validate (validate-plugin) on project gephi-plugins, The 'licenseName' configuration should be set --- modules/BridgingPlugin/pom.xml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/modules/BridgingPlugin/pom.xml b/modules/BridgingPlugin/pom.xml index 8cb97a804f..6e2ea8fdd9 100644 --- a/modules/BridgingPlugin/pom.xml +++ b/modules/BridgingPlugin/pom.xml @@ -93,8 +93,16 @@ org.apache.maven.plugins maven-compiler-plugin - 8 - 8 + 11 + 11 + + + + org.netbeans.api + nbm-maven-plugin + 4.5 + + GPL-3.0