Skip to content

Commit

Permalink
Fix issue gephi#636
Browse files Browse the repository at this point in the history
  • Loading branch information
mbastian committed Jul 7, 2012
1 parent c8bf74c commit 80fb770
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 62 deletions.
2 changes: 1 addition & 1 deletion StatisticsPlugin/manifest.mf
Expand Up @@ -2,5 +2,5 @@ Manifest-Version: 1.0
AutoUpdate-Essential-Module: true
OpenIDE-Module: org.gephi.statistics.plugin
OpenIDE-Module-Localizing-Bundle: org/gephi/statistics/plugin/Bundle.properties
OpenIDE-Module-Specification-Version: 0.8.0.7
OpenIDE-Module-Specification-Version: 0.8.0.8

122 changes: 61 additions & 61 deletions StatisticsPlugin/src/org/gephi/statistics/plugin/WeightedDegree.java
@@ -1,43 +1,43 @@
/*
Copyright 2008-2011 Gephi
Authors : Sebastien Heymann <seb@gephi.org>
Website : http://www.gephi.org
This file is part of Gephi.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
Copyright 2011 Gephi Consortium. All rights reserved.
The contents of this file are subject to the terms of either the GNU
General Public License Version 3 only ("GPL") or the Common
Development and Distribution License("CDDL") (collectively, the
"License"). You may not use this file except in compliance with the
License. You can obtain a copy of the License at
http://gephi.org/about/legal/license-notice/
or /cddl-1.0.txt and /gpl-3.0.txt. See the License for the
specific language governing permissions and limitations under the
License. When distributing the software, include this License Header
Notice in each file and include the License files at
/cddl-1.0.txt and /gpl-3.0.txt. If applicable, add the following below the
License Header, with the fields enclosed by brackets [] replaced by
your own identifying information:
"Portions Copyrighted [year] [name of copyright owner]"
If you wish your version of this file to be governed by only the CDDL
or only the GPL Version 3, indicate your decision by adding
"[Contributor] elects to include this software in this distribution
under the [CDDL or GPL Version 3] license." If you do not indicate a
single choice of license, a recipient has the option to distribute
your version of this file under either the CDDL, the GPL Version 3 or
to extend the choice of license to its licensees as provided above.
However, if you add GPL Version 3 code and therefore, elected the GPL
Version 3 license, then the option applies only if the new code is
made subject to such option by the copyright holder.
Contributor(s):
Portions Copyrighted 2011 Gephi Consortium.
Copyright 2008-2011 Gephi
Authors : Sebastien Heymann <seb@gephi.org>
Website : http://www.gephi.org
This file is part of Gephi.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
Copyright 2011 Gephi Consortium. All rights reserved.
The contents of this file are subject to the terms of either the GNU
General Public License Version 3 only ("GPL") or the Common
Development and Distribution License("CDDL") (collectively, the
"License"). You may not use this file except in compliance with the
License. You can obtain a copy of the License at
http://gephi.org/about/legal/license-notice/
or /cddl-1.0.txt and /gpl-3.0.txt. See the License for the
specific language governing permissions and limitations under the
License. When distributing the software, include this License Header
Notice in each file and include the License files at
/cddl-1.0.txt and /gpl-3.0.txt. If applicable, add the following below the
License Header, with the fields enclosed by brackets [] replaced by
your own identifying information:
"Portions Copyrighted [year] [name of copyright owner]"
If you wish your version of this file to be governed by only the CDDL
or only the GPL Version 3, indicate your decision by adding
"[Contributor] elects to include this software in this distribution
under the [CDDL or GPL Version 3] license." If you do not indicate a
single choice of license, a recipient has the option to distribute
your version of this file under either the CDDL, the GPL Version 3 or
to extend the choice of license to its licensees as provided above.
However, if you add GPL Version 3 code and therefore, elected the GPL
Version 3 license, then the option applies only if the new code is
made subject to such option by the copyright holder.
Contributor(s):
Portions Copyrighted 2011 Gephi Consortium.
*/
package org.gephi.statistics.plugin;

Expand Down Expand Up @@ -81,9 +81,9 @@ public class WeightedDegree implements Statistics, LongTask {
private boolean isCanceled;
private ProgressTicket progress;
private double avgWDegree;
private Map<Float, Integer> degreeDist;
private Map<Float, Integer> inDegreeDist;
private Map<Float, Integer> outDegreeDist;
private Map<Double, Integer> degreeDist;
private Map<Double, Integer> inDegreeDist;
private Map<Double, Integer> outDegreeDist;

public double getAverageDegree() {
return avgWDegree;
Expand All @@ -97,23 +97,23 @@ public void execute(GraphModel graphModel, AttributeModel attributeModel) {
public void execute(HierarchicalGraph graph, AttributeModel attributeModel) {
isDirected = graph instanceof DirectedGraph;
isCanceled = false;
degreeDist = new HashMap<Float, Integer>();
inDegreeDist = new HashMap<Float, Integer>();
outDegreeDist = new HashMap<Float, Integer>();
degreeDist = new HashMap<Double, Integer>();
inDegreeDist = new HashMap<Double, Integer>();
outDegreeDist = new HashMap<Double, Integer>();

AttributeTable nodeTable = attributeModel.getNodeTable();
AttributeColumn degCol = nodeTable.getColumn(WDEGREE);
AttributeColumn inCol = nodeTable.getColumn(WINDEGREE);
AttributeColumn outCol = nodeTable.getColumn(WOUTDEGREE);
if (degCol == null) {
degCol = nodeTable.addColumn(WDEGREE, "Weighted Degree", AttributeType.INT, AttributeOrigin.COMPUTED, 0);
degCol = nodeTable.addColumn(WDEGREE, "Weighted Degree", AttributeType.DOUBLE, AttributeOrigin.COMPUTED, 0.0);
}
if (isDirected) {
if (inCol == null) {
inCol = nodeTable.addColumn(WINDEGREE, "Weighted In-Degree", AttributeType.INT, AttributeOrigin.COMPUTED, 0);
inCol = nodeTable.addColumn(WINDEGREE, "Weighted In-Degree", AttributeType.DOUBLE, AttributeOrigin.COMPUTED, 0.0);
}
if (outCol == null) {
outCol = nodeTable.addColumn(WOUTDEGREE, "Weighted Out-Degree", AttributeType.INT, AttributeOrigin.COMPUTED, 0);
outCol = nodeTable.addColumn(WOUTDEGREE, "Weighted Out-Degree", AttributeType.DOUBLE, AttributeOrigin.COMPUTED, 0.0);
}
}

Expand All @@ -124,17 +124,17 @@ public void execute(HierarchicalGraph graph, AttributeModel attributeModel) {

for (Node n : graph.getNodes()) {
AttributeRow row = (AttributeRow) n.getNodeData().getAttributes();
float totalWeight = 0;
double totalWeight = 0;
if (isDirected) {
HierarchicalDirectedGraph hdg = graph.getGraphModel().getHierarchicalDirectedGraph();
float totalInWeight = 0;
float totalOutWeight = 0;
double totalInWeight = 0;
double totalOutWeight = 0;
for (Iterator it = graph.getEdgesAndMetaEdges(n).iterator(); it.hasNext();) {
Edge e = (Edge) it.next();
if (e.getSource().equals(n)) {
if (e.getSource().getNodeData().equals(n.getNodeData())) {
totalOutWeight += e.getWeight();
}
if (e.getTarget().equals(n)) {
if (e.getTarget().getNodeData().equals(n.getNodeData())) {
totalInWeight += e.getWeight();
}
}
Expand Down Expand Up @@ -178,7 +178,7 @@ public void execute(HierarchicalGraph graph, AttributeModel attributeModel) {

public String getReport() {
String report = "";

if (isDirected) {
report = getDirectedReport();
} else {
Expand Down Expand Up @@ -208,7 +208,7 @@ public String getReport() {
+ "<hr>"
+ "<br> <h2> Results: </h2>"
+ "Average Weighted Degree: " + f.format(avgWDegree)
+ "<br /><br />"+degreeImageFile
+ "<br /><br />" + degreeImageFile
+ "</BODY></HTML>";
}
return report;
Expand All @@ -219,10 +219,10 @@ public String getDirectedReport() {
XYSeries dSeries = ChartUtils.createXYSeries(degreeDist, "Degree Distribution");
XYSeries idSeries = ChartUtils.createXYSeries(inDegreeDist, "In-Degree Distribution");
XYSeries odSeries = ChartUtils.createXYSeries(outDegreeDist, "Out-Degree Distribution");

XYSeriesCollection dataset1 = new XYSeriesCollection();
dataset1.addSeries(dSeries);

XYSeriesCollection dataset2 = new XYSeriesCollection();
dataset2.addSeries(idSeries);

Expand Down Expand Up @@ -267,16 +267,16 @@ public String getDirectedReport() {
ChartUtils.decorateChart(chart3);
ChartUtils.scaleChart(chart3, dSeries, false);
String outdegreeImageFile = ChartUtils.renderChart(chart3, "outdegree-distribution.png");

NumberFormat f = new DecimalFormat("#0.000");

String report = "<HTML> <BODY> <h1>Weighted Degree Report </h1> "
+ "<hr>"
+ "<br> <h2> Results: </h2>"
+ "Average Weighted Degree: " + f.format(avgWDegree)
+ "<br /><br />"+degreeImageFile
+ "<br /><br />"+indegreeImageFile
+ "<br /><br />"+outdegreeImageFile
+ "<br /><br />" + degreeImageFile
+ "<br /><br />" + indegreeImageFile
+ "<br /><br />" + outdegreeImageFile
+ "</BODY></HTML>";

return report;
Expand Down

0 comments on commit 80fb770

Please sign in to comment.