本文整理汇总了C++中Graph::EndEI方法的典型用法代码示例。如果您正苦于以下问题:C++ Graph::EndEI方法的具体用法?C++ Graph::EndEI怎么用?C++ Graph::EndEI使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Graph
的用法示例。
在下文中一共展示了Graph::EndEI方法的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;
}
}
示例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;
}
}
示例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;
}
}
}
示例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);
}