Java tutorial
/* *********************************************************************** * * project: org.matsim.* * FrequencyTask.java * * * *********************************************************************** * * * * copyright : (C) 2010 by the members listed in the COPYING, * * LICENSE and WARRANTY file. * * email : info at matsim dot org * * * * *********************************************************************** * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * See also COPYING, LICENSE and WARRANTY file * * * * *********************************************************************** */ package playground.johannes.socialnetworks.survey.ivt2009.analysis; import java.io.FileNotFoundException; import java.io.IOException; import java.util.Map; import java.util.Set; import org.apache.commons.math.stat.descriptive.DescriptiveStatistics; import playground.johannes.sna.graph.Graph; import playground.johannes.sna.graph.analysis.AnalyzerTask; import playground.johannes.sna.math.Distribution; import playground.johannes.socialnetworks.graph.social.SocialEdge; /** * @author illenberger * */ public class FrequencyTask extends AnalyzerTask { @Override public void analyze(Graph graph, Map<String, DescriptiveStatistics> statsMap) { DescriptiveStatistics distr = new Frequency().statistics((Set<SocialEdge>) graph.getEdges()); if (getOutputDirectory() != null) { Distribution distr2 = new Distribution(distr.getValues()); try { writeHistograms(distr2, 1.0, false, "freq.txt"); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } }