本文整理汇总了C++中ListDigraph::split方法的典型用法代码示例。如果您正苦于以下问题:C++ ListDigraph::split方法的具体用法?C++ ListDigraph::split怎么用?C++ ListDigraph::split使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ListDigraph
的用法示例。
在下文中一共展示了ListDigraph::split方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createMACGraph
void createMACGraph(ListDigraph& g, int num_paths, int path_length, ListDigraph::ArcMap<int>& demands){
srand(time(NULL));
ListDigraph::Node prev[num_paths];
ListDigraph::Node current[num_paths];
for (int i = 0; i < num_paths; ++i)
{
prev[i] = g.addNode();
}
for (int i = 0; i < path_length-1; ++i)
{
for (int j = 0; j < num_paths; ++j)
{
current[j] = g.addNode();
g.addArc(prev[j], current[j]);
}
for (int j = 0; j < num_paths; ++j)
{
if(rand()%100 < 50){
int targetIndex = j;
while(targetIndex != j){
targetIndex = rand()%num_paths;
}
g.addArc(prev[j], current[targetIndex]);
}
}
for (int j = 0; j < num_paths; ++j)
{
prev[j] = current[j];
}
}
//this splits every node and sets demand for the edge between the halves to 1
for (ListDigraph::NodeIt n(g); n != INVALID; ++n){
ListDigraph::Node new_node = g.split(n, false);
ListDigraph::Arc new_edge = g.addArc(n, new_node);
demands[new_edge] = 1;
}
}
示例2: createKPathGraph
void createKPathGraph(ListDigraph& g, int k, int n, int m, ListDigraph::ArcMap<int>& weights, ListDigraph::ArcMap<int>& demands){
srand(time(NULL));
ListDigraph::Node* nodes[k];
for (int i = 0; i < k; ++i)
{
nodes[i] = (ListDigraph::Node*) calloc(n, sizeof(ListDigraph::Node));
}
for (int i = 0; i < k; ++i)
{
for (int j = 0; j < n; ++j)
{
nodes[i][j] = g.addNode();
if(j != 0) g.addArc(nodes[i][j-1], nodes[i][j]);
}
}
for (int i = 0; i < m; ++i)
{
int k1 = rand()%k;
int k2 = rand()%k;
int n1 = rand()%(n-1);
int n2 = (rand()%(n-n1-1))+n1+1;
if(findArc(g, nodes[k1][n1], nodes[k2][n2]) == INVALID){
g.addArc(nodes[k1][n1], nodes[k2][n2]);
}
}
for (ListDigraph::ArcIt a(g); a != INVALID; ++a)
{
weights[a] = rand()%1000;
}
//this splits every node and sets demand for the edge between the halves to 1
for (ListDigraph::NodeIt n(g); n != INVALID; ++n){
ListDigraph::Node new_node = g.split(n, false);
ListDigraph::Arc new_edge = g.addArc(n, new_node);
demands[new_edge] = 1;
}
}