当前位置: 首页>>代码示例>>C++>>正文


C++ Graph::BegEI方法代码示例

本文整理汇总了C++中Graph::BegEI方法的典型用法代码示例。如果您正苦于以下问题:C++ Graph::BegEI方法的具体用法?C++ Graph::BegEI怎么用?C++ Graph::BegEI使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Graph的用法示例。


在下文中一共展示了Graph::BegEI方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: kruskalCluster

void kruskalCluster(Graph & G)
{
    std::vector<Cluster> clusters;
    for (SnapNode NI = G->BegNI(); NI < G->EndNI(); NI++)
    {
        Cluster c;
        c.empty = false;
        c.clusterElements.push_back(NI.GetDat());
        clusters.push_back(c);
    }

    std::vector <SnapEdge> result;
    std::deque <SnapEdge> Q;

    for (SnapEdge NI = G->BegEI(); NI < G->EndEI(); NI++)
    {
        Q.push_back(NI);
    }

    while(!Q.empty())
    {
        std::sort(Q.begin(), Q.end(), sortClusters);
        SnapEdge edge = Q.front();
        Q.pop_front();
        if(!compareCluster((int)edge.GetSrcNDat(), (int)edge.GetDstNDat(), clusters))
        {
            result.push_back(edge);
        }
    }

    for(int i = 0; i<result.size(); i++)
    {
        std::cout << "(" << result[i].GetSrcNDat() << ", " << result[i].GetDstNDat() << ", " << result[i].GetDat() << ")" << std::endl;
    }
}
开发者ID:sexistaMatula,项目名称:SNAP-Graph,代码行数:35,代码来源:testgraph.cpp

示例2: printDetail

void printDetail(Graph & G)
{
    for (SnapNode NI = G->BegNI(); NI != G->EndNI(); NI++)
    {
        std::cout << "Id: " << NI.GetId() << " Out Degree: " << NI.GetOutDeg() << " In Degree: " << NI.GetInDeg() << std::endl;
    }

    for (SnapEdge NI = G->BegEI(); NI < G->EndEI(); NI++)
    {
        std::cout << "Edge from " << (int)NI.GetSrcNDat() << " --> " << (int)NI.GetDstNDat() << " with weight " << (int)NI.GetDstNDat() << std::endl;
    }
}
开发者ID:sexistaMatula,项目名称:SNAP-Graph,代码行数:12,代码来源:testgraph.cpp

示例3: kruskal

void kruskal(Graph & G, bool bench)
{
    int largestNode = getLargestNode(G);
    std::vector<disjointTreeNode*> disjointNodes(largestNode);
    std::vector<SnapEdge> result;
    std::deque<SnapEdge> Q;

    for(SnapNode NI = G->BegNI(); NI < G->EndNI(); NI++)
    {
        disjointTreeNode* x =  new disjointTreeNode();
        x->id = NI.GetDat();
        makeSet(x);
        disjointNodes[x->id-1] = x;
    }


    for (SnapEdge NI = G->BegEI(); NI < G->EndEI(); NI++)
    {
        Q.push_back(NI);
    }

    while (! Q.empty())
    {
        std::sort(Q.begin(), Q.end(), sortClusters);
        SnapEdge e = Q.front();
        Q.pop_front();
        disjointTreeNode* u = Find(disjointNodes[e.GetSrcNDat()-1]);
        disjointTreeNode* v = Find(disjointNodes[e.GetDstNDat()()-1]);
        if ( u != v )
        {
            result.push_back(e);
            Union(disjointNodes[e.GetSrcNDat()-1], disjointNodes[e.GetDstNDat()-1]);
        }

    }
    if(!bench)
    {
        for(int i = 0; i<result.size(); i++)
        {
            std::cout << result[i].GetSrcNDat() << " --> " << result[i].GetDstNDat() << " peso: " << result[i].GetDat() << std::endl;
        }
    }
}
开发者ID:sexistaMatula,项目名称:SNAP-Graph,代码行数:43,代码来源:testgraph.cpp

示例4: floydWarshallPaths

void floydWarshallPaths(Graph & G, int size, bool bench)
{
    std::vector< std::vector<float > > VectorGraph(size, std::vector<float>(size, inf));
    for(int i=0; i<VectorGraph.size(); i++)
    {
        for(int j = 0; j<VectorGraph.size(); j++)
        {
            if(i == j)
                VectorGraph[i][j] = 0;
        }
    }
    for (TNodeEDatNet<TInt, TFlt>::TEdgeI NI = G->BegEI(); NI < G->EndEI(); NI++)
    {
        int vert1 = NI.GetSrcNDat();
        int vert2 = NI.GetDstNDat();
        VectorGraph[vert1-1][vert2-1] = (float) NI.GetDat();
    }
    floydWarshall(VectorGraph);
    if(!bench)
        printFloydWarshall(VectorGraph);
}
开发者ID:sexistaMatula,项目名称:SNAP-Graph,代码行数:21,代码来源:testgraph.cpp


注:本文中的Graph::BegEI方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。