本文整理汇总了C++中row::push_back方法的典型用法代码示例。如果您正苦于以下问题:C++ row::push_back方法的具体用法?C++ row::push_back怎么用?C++ row::push_back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类row
的用法示例。
在下文中一共展示了row::push_back方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: single_source_dijkstra_path_basic
void single_source_dijkstra_path_basic(Graph &G,int s,row &S,tablist &P,int* sigma,float* D)
{
/*
Graph G:G is the graph object
s:s is the source vertex.
S:S will contain the nodes in a topological order.
P:P[w] gives the predecessors of w in the DAG rooted at s.
sigma:sigma[t] gives the number of shortest paths from s to t.
D:D[t] gives the distance from s to t.
*/
float vw_dist;
onemap_d seen;
int* find=new int[G.len()];
for(int i=0;i<G.len();i++)
{
find[i]=0;
}
for(int i=0;i<G.len();i++)
{
D[i]=numeric_limits<float>::infinity();
sigma[i]=0;
}
sigma[s]=1;
seen[s]=0.0;
/*Create a priority queue*/
priority_queue<Elem,vector<Elem>,dist_compare> Q;
/*Add s to the queue*/
Elem e1(s,s,0.0);
Q.push(e1);
S.reserve(G.len()+1);
while(!Q.empty())
{
Elem e=Q.top();
Q.pop();
int v=e.node;
if(find[v]==1)
{
continue;
}
if(v!=s)
{
sigma[v]+=sigma[e.pred];
}
S.push_back (v);
D[v]=e.dist;
find[v]=1;
for (vector<Edge>::iterator it = G.adj_list[v].begin(); it != G.adj_list[v].end(); ++it)
{
int w=it->vertex;
vw_dist=e.dist+ it->weight;
if ((find[w]==0)&&((seen.find(w)==seen.end())||(vw_dist<seen[w])))
{
seen[w]=vw_dist;
Q.push( Elem(v,w,vw_dist));
sigma[w]=0;
vector<int> new_vector(1);
new_vector[0]=v;
P[w]=new_vector;
}
else if (abs(vw_dist-seen[w])<EPSILON)
{
sigma[w]+=sigma[v];
P[w].push_back(v);
}
}
}
delete[] find;
return;
}