jeudi 5 mars 2015

Boost adjacency_list errors when using boost Dijkstra

I am attempting to leverage this code: boost's official example to implement the boost library version of Dijkstra's algorithm. Now, I am doing it a more object-orientated manner, so I have my class file and my header file.


In my header file (spc.h) I have the following:



#ifndef _SPC_H_
#define _SPC_H_

#pragma once

#include <boost/config.hpp>
#include <boost/graph/graph_traits.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/dijkstra_shortest_paths.hpp>
#include <boost/property_map/property_map.hpp>
#include <vector>

using namespace Utilities;
using namespace Flow;
using namespace boost;
using namespace std;

namespace FlowAlgorithms {

class SPC {
public:
SPC();
SPC(vector<VEdge*>);
~SPC();

// Templated entry point for all algorithmic starts
void start();
private:
void run_dijkstra();
void run_kruskal();

int kNumNodes;
DEdge* kEdgeArray;
int* kWeightsArray;
vector<VEdge*> kEdges;
vector<int> kWeights;
//graph_t kGraph;
};
}


typedef boost::adjacency_list < boost::listS, boost::vecS, boost::directedS,
boost::no_property, boost::property < boost::edge_weight_t, int > > graph_t;

//typedef graph_traits < graph_t >::vertex_descriptor vertex_descriptor;
typedef pair<int, int> DVertex;
typedef pair<DVertex, DVertex> DEdge;

#endif


And in my CC file (spc.cc) I have the following:



#include "../Headers/spc.h"
#include "../Headers/vedge.h"
#include "../headers/claim.h"

using namespace FlowAlgorithms;
using namespace Flow;

SPC::SPC(){}

SPC::SPC(vector<VEdge*> edges) {
kEdges = edges;
kNumNodes = (int)edges.size();
VEdge* at;
kEdgeArray = new DEdge[kNumNodes];
kWeightsArray = new int[kNumNodes];

for(int x = 0;x<kNumNodes;x++) {
at = kEdges.at(x);
kEdgeArray[x] = DEdge(DVertex(at->kStart->get_x(), at->kStart->get_y()),
DVertex(at->kEnd->get_x(), at->kEnd->get_y()));
kWeightsArray[x] = 1;
}
delete at;
}

SPC::~SPC(){
delete [] kEdgeArray;
delete [] kWeightsArray;
}

void SPC::start() {
claim("S/start: starting SPC", kDebug);
run_dijkstra();
run_kruskal();
}


void SPC::run_dijkstra() {
claim("S/run_dijkstra: starting boost/dijkstra", kDebug);

int num_arcs = (int) sizeof(kEdgeArray) / kNumNodes;

graph_t kGraph(kEdgeArray, kEdgeArray + num_arcs, kWeights, kNumNodes);

//graph_t g(edge_array, edge_array + num_arcs, kWeights, kNumNodes);
//property_map<graph_t, edge_weight_t>::type weight_map = get(edge_weight, kGraph);

//vector<vertex_descriptor> p(num_vertices(kGraph));
//vector<int> d(num_vertices(kGraph));
//vertex_descriptor v_d = vertex(kEdgeArray[0], kGraph);

//dijkstra_shortest_paths(kGraph, v_d, predecessor_map(&p[0]).distance_map(&d[0]));

}

void SPC::run_kruskal() {
claim("S/run)kruskal: starting boost/kruskal", kDebug);
}


When I try to compile my code I get a litany of errors, most of which I don't understand:



In file included from /Users/user/Projects/CLion/final/Source/map.cc:1:
In file included from /Users/user/Projects/CLion/final/Source/../Headers/controller.h:8:
In file included from /Users/user/Projects/CLion/final/Headers/spc.h:8:
In file included from /usr/local/include/boost/graph/adjacency_list.hpp:45:
In file included from /usr/local/include/boost/graph/named_graph.hpp:18:
/usr/local/include/boost/multi_index/hashed_index.hpp:887:36: error: too many arguments provided to function-like macro invocation
hashed_index<KeyFromValue,Hash,Pred,SuperMeta,TagList,Category>& x)
^
/Users/user/Projects/CLion/final/Headers/map.h:16:9: note: macro 'swap_' defined here
#define swap_(a, b) do{ __typeof__(a) tmp; tmp = a; a = b; b = tmp; }while(0)
^
In file included from /Users/user/Projects/CLion/final/Source/map.cc:1:
In file included from /Users/user/Projects/CLion/final/Source/../Headers/controller.h:8:
In file included from /Users/user/Projects/CLion/final/Headers/spc.h:8:
In file included from /usr/local/include/boost/graph/adjacency_list.hpp:45:
In file included from /usr/local/include/boost/graph/named_graph.hpp:18:
/usr/local/include/boost/multi_index/hashed_index.hpp:886:8: error: field has incomplete type 'void'
void swap_(
^
/usr/local/include/boost/multi_index/hashed_index.hpp:890:15: error: C++ requires a type specifier for all declarations
std::swap(hash_,x.hash_);
^~~~~
In file included from /Users/user/Projects/CLion/final/Source/controller.cc:2:
In file included from /Users/user/Projects/CLion/final/Source/../Headers/controller.h:8:
In file included from /Users/user/Projects/CLion/final/Headers/spc.h:8:
In file included from /usr/local/include/boost/graph/adjacency_list.hpp:45:
In file included from /usr/local/include/boost/graph/named_graph.hpp:18:
/usr/local/include/boost/multi_index/hashed_index.hpp:887:36: error: too many arguments provided to function-like macro invocation
hashed_index<KeyFromValue,Hash,Pred,SuperMeta,TagList,Category>& x)
^
/Users/user/Projects/CLion/final/Source/../Headers/map.h:16:9: note: macro 'swap_' defined here
#define swap_(a, b) do{ __typeof__(a) tmp; tmp = a; a = b; b = tmp; }while(0)
^
In file included from /Users/user/Projects/CLion/final/Source/controller.cc:2:
In file included from /Users/user/Projects/CLion/final/Source/../Headers/controller.h:8:
In file included from /Users/user/Projects/CLion/final/Headers/spc.h:8:
In file included from /usr/local/include/boost/graph/adjacency_list.hpp:45:
In file included from /usr/local/include/boost/graph/named_graph.hpp:18:
/usr/local/include/boost/multi_index/hashed_index.hpp:886:8: error: field has incomplete type 'void'
void swap_(
^
/usr/local/include/boost/multi_index/hashed_index.hpp:890:15: error: C++ requires a type specifier for all declarations
std::swap(hash_,x.hash_);
^~~~~
In file included from /Users/user/Projects/CLion/final/Source/voronoi.cc:2:
In file included from /Users/user/Projects/CLion/final/Source/../Headers/controller.h:8:
In file included from /Users/user/Projects/CLion/final/Headers/spc.h:8:
In file included from /usr/local/include/boost/graph/adjacency_list.hpp:45:
In file included from /usr/local/include/boost/graph/named_graph.hpp:18:
/usr/local/include/boost/multi_index/hashed_index.hpp:887:36: error: too many arguments provided to function-like macro invocation
hashed_index<KeyFromValue,Hash,Pred,SuperMeta,TagList,Category>& x)
^
/Users/user/Projects/CLion/final/Headers/map.h:16:9: note: macro 'swap_' defined here
#define swap_(a, b) do{ __typeof__(a) tmp; tmp = a; a = b; b = tmp; }while(0)
^
In file included from /Users/user/Projects/CLion/final/Source/voronoi.cc:2:
In file included from /Users/user/Projects/CLion/final/Source/../Headers/controller.h:8:
In file included from /Users/user/Projects/CLion/final/Headers/spc.h:8:
In file included from /usr/local/include/boost/graph/adjacency_list.hpp:45:
In file included from /usr/local/include/boost/graph/named_graph.hpp:18:
/usr/local/include/boost/multi_index/hashed_index.hpp:886:8: error: field has incomplete type 'void'
void swap_(
^
/usr/local/include/boost/multi_index/hashed_index.hpp:890:15: error: C++ requires a type specifier for all declarations
std::swap(hash_,x.hash_);
^~~~~
/usr/local/include/boost/multi_index/hashed_index.hpp:890:21: error: unknown type name 'x'
std::swap(hash_,x.hash_);
^
/usr/local/include/boost/multi_index/hashed_index.hpp:890:22: error: expected ')'
std::swap(hash_,x.hash_);
^
/usr/local/include/boost/multi_index/hashed_index.hpp:890:14: note: to match this '('
std::swap(hash_,x.hash_);
^
/usr/local/include/boost/multi_index/hashed_index.hpp:890:10: error: non-friend class member 'swap' cannot have a qualified name
std::swap(hash_,x.hash_);
~~~~~^
/usr/local/include/boost/multi_index/hashed_index.hpp:890:10: error: C++ requires a type specifier for all declarations
std::swap(hash_,x.hash_);
~~~ ^
/usr/local/include/boost/multi_index/hashed_index.hpp:891:15: error: C++ requires a type specifier for all declarations
std::swap(eq_,x.eq_);
^~~


When I run the code in the way they have it, it runs just fine. I've tried messing with namespaces, I've verified there is no definition of anything else anywhere, I don't know what to do!


Help me stackoverflow, you're my only hope!


Aucun commentaire:

Enregistrer un commentaire