Smrf.NodeXL.ExcelTemplate.WordMetricCalculator2.TryCountVertexTermsByGroup C# (CSharp) Method

TryCountVertexTermsByGroup() protected method

protected TryCountVertexTermsByGroup ( IGraph oGraph, WordMetricUserSettings oWordMetricUserSettings, WordCounter oWordCounter, WordPairCounter oWordPairCounter, HashSet oUniqueImportedIDs, GraphMetricColumn &oGraphMetricColumns ) : System.Boolean
oGraph IGraph
oWordMetricUserSettings WordMetricUserSettings
oWordCounter WordCounter
oWordPairCounter WordPairCounter
oUniqueImportedIDs HashSet
oGraphMetricColumns GraphMetricColumn
return System.Boolean
    TryCountVertexTermsByGroup
    (
        IGraph oGraph,
        WordMetricUserSettings oWordMetricUserSettings,
        WordCounter oWordCounter,
        WordPairCounter oWordPairCounter,
        HashSet<String> oUniqueImportedIDs,
        out GraphMetricColumn [] oGraphMetricColumns
    )
    {
        Debug.Assert(oGraph != null);
        Debug.Assert(oWordMetricUserSettings != null);
        Debug.Assert(oWordCounter != null);
        Debug.Assert(oWordPairCounter != null);
        AssertValid();

        List<GraphMetricValueOrdered> oWordWordValues, oWordCountValues,
            oWordSalienceValues;

        List<GraphMetricValueOrdered> oWordPairWord1Values,
            oWordPairWord2Values, oWordPairCountValues,
            oWordPairSalienceValues, oWordPairMutualInformationValues;

        CreateGraphMetricValueLists(
            out oWordWordValues, out oWordCountValues, out oWordSalienceValues,
            
            out oWordPairWord1Values, out oWordPairWord2Values,
            out oWordPairCountValues, out oWordPairSalienceValues,
            out oWordPairMutualInformationValues
            );

        List<GraphMetricValueOrdered> oWordGroupNameValues =
            new List<GraphMetricValueOrdered>();

        List<GraphMetricValueOrdered> oWordPairGroupNameValues =
            new List<GraphMetricValueOrdered>();

        // Get a list of the graph's groups, adding a dummy group for the
        // entire graph and another to contain any non-grouped vertices.

        foreach ( GroupInfo oGroup in
            EnumerateGroupsForCountingVertexTerms(oGraph) )
        {
            // Count the terms in this group.

            oWordCounter.Clear();
            oWordPairCounter.Clear();

            foreach ( IVertex oVertex in EnumerateEdgesOrVertices(
                oGroup.Vertices, false, oGraph, oUniqueImportedIDs) )
            {
                CountTermsInEdgeOrVertex(oVertex,
                    oWordMetricUserSettings.TextColumnName, oWordCounter,
                    oWordPairCounter);
            }

            oWordCounter.CalculateSalienceOfCountedTerms();
            oWordPairCounter.CalculateSalienceOfCountedTerms();
            oWordPairCounter.CalculateMutualInformationOfCountedTerms();

            // Transfer the words and word pairs to the graph metric value
            // lists.

            AddCountedWordsToValueLists(oWordCounter.CountedTerms,
                oWordMetricUserSettings, oGroup.Name, oWordWordValues,
                oWordCountValues, oWordSalienceValues, oWordGroupNameValues);

            AddCountedWordPairsToValueLists(oWordPairCounter.CountedTerms,
                oWordMetricUserSettings, oGroup.Name, oWordPairWord1Values,
                oWordPairWord2Values, oWordPairCountValues,
                oWordPairSalienceValues, oWordPairMutualInformationValues,
                oWordPairGroupNameValues);
        }

        oGraphMetricColumns = CreateGraphMetricColumns(
            oWordWordValues, oWordCountValues, oWordSalienceValues,
            oWordGroupNameValues,
        
            oWordPairWord1Values, oWordPairWord2Values, oWordPairCountValues,
            oWordPairSalienceValues, oWordPairMutualInformationValues,
            oWordPairGroupNameValues
            );

        return (true);
    }