Search in sources :

Example 1 with DependencyMap

use of mrmathami.cia.cpp.ast.DependencyMap in project Cpp4CIA by thanhminhmr.

the class VersionBuilder method calculateWeights.

@Nonnull
private static double[] calculateWeights(@Nonnull double[] weightMap, @Nonnull RootNode rootNode) {
    final double[] weights = new double[rootNode.getNodeCount()];
    for (final CppNode node : rootNode) {
        double directWeight = 0.0;
        for (final CppNode dependencyNode : node.getAllDependencyFrom()) {
            final DependencyMap dependencyMap = node.getNodeDependencyFrom(dependencyNode);
            for (final DependencyType type : DependencyType.values) {
                directWeight += weightMap[type.ordinal()] * dependencyMap.getCount(type);
            }
        }
        weights[node.getId()] = directWeight;
    }
    return weights;
}
Also used : DependencyType(mrmathami.cia.cpp.ast.DependencyType) CppNode(mrmathami.cia.cpp.ast.CppNode) DependencyMap(mrmathami.cia.cpp.ast.DependencyMap) Nonnull(mrmathami.annotations.Nonnull)

Aggregations

Nonnull (mrmathami.annotations.Nonnull)1 CppNode (mrmathami.cia.cpp.ast.CppNode)1 DependencyMap (mrmathami.cia.cpp.ast.DependencyMap)1 DependencyType (mrmathami.cia.cpp.ast.DependencyType)1