Boost logo

Boost Users :

Subject: Re: [Boost-users] [Graph] newbie to graph (Andrew Sutton) (Phillip Jones)
From: Lior Weizman (lior.weizman_at_[hidden])
Date: 2008-11-03 05:29:47

Applying the suggestion below:

> struct Node {
> std::string name;
> long index;
> boost::default_color_type color;
> long distance;
> graph_traits<Graph>::edge_descriptor predecessor;
> };
> struct Arc {
> long capacity;
> long residual;
> graph_traits<Graph>::edge_descriptor rev;
> };
> With the following call:
> flow = kolmogorov_max_flow(g, s, t,
> capacity_map(get(&Arc::capacity, g)).
> residual_capacity_map(get(&Arc::residual, g)).
> reverse_edge_map(get(&Arc::rev, g)).
> predecessor_map(get(&Node::predecessor, g)).
> color_map(get(&Node::color, g)).
> distance_map(get(&Node::distance, g)).
> vertex_index_map(get(&Node::index, g))
> );
> Resulted with many errors.But I think I found the right way. The following
code compiles without errors or warnings:
#include <boost/config.hpp>
#include <iostream>
#include <string>
#include <boost/graph/kolmogorov_max_flow.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/write_dimacs.hpp>
#include <boost/graph/read_dimacs.hpp>
using namespace boost;
struct Arc;
struct Node;
typedef adjacency_list<vecS,vecS,directedS,Node,Arc> Graph;
struct Arc {
    long capacity;
    long residual_capacity;
    Graph::edge_descriptor reverse;
struct Node {
    std::string name;
    Graph::edge_descriptor predecessor;
    default_color_type color;
    long distance;
    long index;
    typedef Graph::vertex_descriptor vertex_descriptor;
    typedef Graph::edge_descriptor edge_descriptor;
    typedef std::pair<edge_descriptor, bool> EdgePair;
    typedef std::pair<int,int> Pair;
    Graph g;

    property_map<Graph, long Arc::*>::type capacity
        = get(&Arc::capacity, g);
    property_map<Graph, long Arc::*>::type res_capacity
        = get(&Arc::residual_capacity, g);
    property_map<Graph, Graph::edge_descriptor Arc::*>::type reverse
        = get(&Arc::reverse,g);
    property_map<Graph,Graph::edge_descriptor Node::*>::type predecessor
        = get(&Node::predecessor,g);
    property_map<Graph,default_color_type Node::*>::type color
        = get(&Node::color,g);
    property_map<Graph,long Node::*>::type distance
        = get(&Node::distance,g);
    property_map<Graph,long Node::*>::type index
        = get(&Node::index,g);
    long flow;
    vertex_descriptor s, t;
    Pair edge_array[6] = { Pair(0,1), Pair(0,2), Pair(0,3),
                           Pair(1,3), Pair(4,3),
    EdgePair edge_desc_obj;

    for (int i = 1; i < 5; ++i){
        edge_desc_obj=add_edge(edge_array[i].first, edge_array[i].second,g);
    char str[2];
    int i=0;
    vertex_descriptor v1=*vertices(g).first,v2=*vertices(g).second;
    while (v1!=v2)
    edge_descriptor from_s,to_t;
    flow =
    return 0;
-----------------------------END OFCODE-----------------

However when trying to run this code I receive "Segmentation error". (this
error does not appear when I remove the call to kolmogorov)
I work under linux and I tried to compile with both g++ and g++-3.3
The valgrind output can be found at:

Any suggestions?


Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at