void ProgramState::computeNearestNeighborsDegree(PropertyMap& propertyMap) { if (!propertyMap.containsPropertySet("degreeDistribution")) { computeDegreeDistribution(propertyMap); } VariantsSet& degrees = propertyMap.getPropertySet("degreeDistribution"); VariantsSet::const_iterator it = degrees.begin(); double knn = 0; if (isWeighted()) { IGraphFactory<WeightedGraph, WeightedVertex> *weightedFactory = new WeightedGraphFactory<WeightedGraph, WeightedVertex>(); INearestNeighborsDegree<WeightedGraph, WeightedVertex> *nearestNeighborDegree = weightedFactory->createNearestNeighborsDegree(); while (it != degrees.end()) { knn = nearestNeighborDegree->meanDegree(weightedGraph, from_string<unsigned int>(it->first)); propertyMap.addProperty<double>("nearestNeighborDegreeForDegree", it->first, knn); ++it; } delete nearestNeighborDegree; } else { IGraphFactory<Graph, Vertex> *factory = new GraphFactory<Graph, Vertex>(); INearestNeighborsDegree<Graph, Vertex> *nearestNeighborDegree = factory->createNearestNeighborsDegree(); while (it != degrees.end()) { knn = nearestNeighborDegree->meanDegree(graph, from_string<unsigned int>(it->first)); propertyMap.addProperty<double>("nearestNeighborDegreeForDegree", it->first, knn); ++it; } delete nearestNeighborDegree; } }
void ProgramState::computeClusteringCoefficient(PropertyMap& propertyMap) { if (!propertyMap.containsPropertySet("degreeDistribution")) { computeDegreeDistribution(propertyMap); } VariantsSet& degrees = propertyMap.getPropertySet("degreeDistribution"); VariantsSet::const_iterator it = degrees.begin(); double cc = 0; if (isWeighted()) { IGraphFactory<WeightedGraph, WeightedVertex> *weightedFactory = new WeightedGraphFactory<WeightedGraph, WeightedVertex>(); IClusteringCoefficient<WeightedGraph, WeightedVertex> *clusteringCoefficient = weightedFactory->createClusteringCoefficient(); while (it != degrees.end()) { cc = clusteringCoefficient->clusteringCoefficient(weightedGraph, from_string<unsigned int>(it->first)); propertyMap.addProperty<double>("clusteringCoeficientForDegree", it->first, cc); ++it; } delete clusteringCoefficient; } else { IGraphFactory<Graph, Vertex> *factory = new GraphFactory<Graph, Vertex>(); IClusteringCoefficient<Graph, Vertex>* clusteringCoefficient = factory->createClusteringCoefficient(); while (it != degrees.end()) { cc = clusteringCoefficient->clusteringCoefficient(graph, from_string<unsigned int>(it->first)); propertyMap.addProperty<double>("clusteringCoeficientForDegree", it->first, cc); ++it; } delete clusteringCoefficient; } }