예제 #1
0
HRESULT ViewTest1::Run()
{
	m_qxvoTest.CreateInstance(CLSID_VwOverlay);

	TestName();
	TestGuid();
	TestVwOverlayFlags();
	TestFontName();
	TestFontSize();
	TestMaxShowTags();
	TestCTags();
	TestSetTagInfo();
	TestGetDbTagInfo();
	TestGetDlgTagInfo();
	TestGetDispTagInfo();
	TestSort();
	TestMerge();

	return S_OK;
}
예제 #2
0
    static uint32_t MergeCommunities(const CGraph* graph, CommunityPartition* partition, const double64_t alfa) {
        // Look for community interactions.
        InteractionsSet candidateMerges(CompareById);
        uint32_t N = graph->GetNumNodes();
        for( uint32_t i = 0; i < N; ++i ) {
            uint32_t communityLabel1 = partition->m_NodeLabels[i];
            uint32_t degree = graph->GetDegree(i);
            const uint32_t* adjacencies = graph->GetNeighbors(i);
            for( uint32_t j = 0; j < degree; ++j ) {
                uint32_t communityLabel2 = partition->m_NodeLabels[adjacencies[j]];
                if( communityLabel1 != communityLabel2 ) {
                    CommunityInteraction cI;
                    cI.degree = 0;
                    if( communityLabel1 < communityLabel2 ) {
                        cI.m_CommunityId1 = communityLabel1;
                        cI.m_CommunityId2 = communityLabel2;
                    } else {
                        cI.m_CommunityId2 = communityLabel1;
                        cI.m_CommunityId1 = communityLabel2;
                    }
                    candidateMerges.insert(cI);
                }
            }
        }
        std::vector<CommunityInteraction> filteredInteractions;
        uint32_t earlyFilter = 0;
        // Test each community interaction and rank it.
        for( InteractionsSet::iterator it = candidateMerges.begin(); it != candidateMerges.end(); ++it ) {
            CommunityInteraction cI = *it;
            if( partition->m_Communities[partition->m_CommunityIndices[cI.m_CommunityId1]] > 2 &&
                    partition->m_Communities[partition->m_CommunityIndices[cI.m_CommunityId2]] > 2 ) {
                    earlyFilter++;
                    double64_t improvement = TestMerge(graph, partition, alfa, cI);
                    if( improvement > 0.0 ) {
                        cI.m_Improvement = improvement;
                        filteredInteractions.push_back(cI);
                    }
            }
        } 
        std::cout << earlyFilter << " " << filteredInteractions.size() << " " << candidateMerges.size() << std::endl;
        // Sort community interactions by improvement.
        uint32_t* tempNodeLabels = new uint32_t[partition->m_NumNodes];
        memcpy(tempNodeLabels, partition->m_NodeLabels, sizeof(uint32_t)*partition->m_NumNodes);
        std::sort(filteredInteractions.begin(), filteredInteractions.end(), CompareByImprovement);
        std::set<uint32_t> touched;
        uint32_t numInteractions = filteredInteractions.size();
        for( uint32_t i = 0; i < numInteractions; ++i ) {
            if( (touched.find(filteredInteractions[i].m_CommunityId1) == touched.end()) && 
                    (touched.find(filteredInteractions[i].m_CommunityId2) == touched.end()) ) {
                uint32_t communitySize = partition->m_Communities[partition->m_CommunityIndices[filteredInteractions[i].m_CommunityId1]];
                const uint32_t* community = &partition->m_Communities[partition->m_CommunityIndices[filteredInteractions[i].m_CommunityId1]+1];
                for( uint32_t j = 0; j < communitySize; ++j ) {
                    tempNodeLabels[community[j]] = filteredInteractions[i].m_CommunityId2;
                }
                touched.insert(filteredInteractions[i].m_CommunityId1);
                touched.insert(filteredInteractions[i].m_CommunityId2);
            }
        }

        // Perform interactions constrained by independence and create a new labels array to create a partition from.
        FreeResources(partition);
        if (InitializeFromLabelsArray(graph, partition, tempNodeLabels, alfa)) {
            printf("Error initializing from label array.\n");
            return 1;
        }
        delete [] tempNodeLabels;
        return 0;
    }