// GraphTea Project: http://github.com/graphtheorysoftware/GraphTea
// Copyright (C) 2012 Graph Theory Software Foundation: http://GraphTheorySoftware.com
// Copyright (C) 2008 Mathematical Science Department of Sharif University of Technology
// Distributed under the terms of the GNU General Public License (GPL): http://www.gnu.org/licenses/

package graphtea.extensions.reports.basicreports;

import graphtea.extensions.AlgorithmUtils;
import graphtea.graph.graph.GraphModel;
import graphtea.graph.graph.Vertex;
import graphtea.platform.lang.CommandAttitude;
import graphtea.plugins.reports.extension.GraphReportExtension;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Mohammad Ali Rostami
 */

@CommandAttitude(name = "total_num_of_stars", abbreviation = "_tnoss")
public class TotalNumOfStars implements GraphReportExtension<List<String>> {
    public List<String> calculate(GraphModel g) {
        List<String> ret = new ArrayList<>();
        for(int i = 0; i< AlgorithmUtils.getMaxDegree(g); i++) {
            int sum = 0;
            for (Vertex v : g) {
                int deg = g.getDegree(v);
                sum += AlgorithmUtils.choose(deg, i+1).intValue();
            }
            if(i==0) sum /= 2;
            ret.add("NumOf(K1," + (i+1) + ") = "+sum );
        }

        return ret;
    }

    public String getName() {
        return "Total Number of Stars";
    }

    public String getDescription() {
        return "Total Number of Stars";
    }

	@Override
	public String getCategory() {
		// TODO Auto-generated method stub
		return "General";
	}

}
