It would seem that I'm having a bit of trouble nailing down the scope of a typedef of the adjacency_list type in a class I'm writing. For some reason, I keep getting the error "error: 'directed_graph' does not name a type" when trying to compile the following code using XCode 2.4 with the boost library installed via DarwinPorts and the appropriate library and search paths (/opt/local/lib/ and /opt/local/ include/) set. If someone could help me out with this, I would very much appreciate it. Thanks for your time! Gratefully, a. /* * GARN.h * GA_RuleNetwork * * Created by Alec Resnick on 1/8/07. * Copyright 2007 dror. All rights reserved. * */ #ifndef GRAPH_AUTOMATA_RULE_NETWORK_CLASS_HEADER_FILE #define GRAPH_AUTOMATA_RULE_NETWORK_CLASS_HEADER_FILE #include <iostream> #include <vector> #include <string> #include <math.h> #include <boost/graph/adjacency_list.hpp> #include "GARN_helpers.h" #include "GARN_neighborhood.h" using namespace std; using namespace boost; class GARN{ typedef property<edge_name_t, int> edge_property; typedef property<vertex_name_t, GARN_neighborhood> vertex_property; typedef adjacency_list<vecS, vecS, directedS, vertex_property, edge_property> directed_graph; typedef graph_traits<directed_graph>::vertex_descriptor vertex; typedef graph_traits<directed_graph>::edge_descriptor edge; private: vector<int> lookupTable; int neighborhoodSize; int numStates; int ruleNumber; directed_graph ruleNetwork; vector<GARN_neighborhood> neighborhoodSpace; public: // Constructors------------------------------------------------------------ -> GARN(); GARN(int,int,int); // Destructors------------------------------------------------------------- -> ~GARN(); // Accessors--------------------------------------------------------------- -> directed_graph get_ruleNetwork(); // Mutators---------------------------------------------------------------- -> }; // Constructors------------------------------------------------------------ -----> GARN::GARN(){ } GARN::GARN(int _ruleNumber, int _numStates, int _neighborhoodSize){ ruleNumber = _ruleNumber; numStates = _numStates; neighborhoodSize = _neighborhoodSize; int neighborhoodSpaceSize = int(pow(numStates,neighborhoodSize)); lookupTable = intToNary(ruleNumber, numStates, neighborhoodSpaceSize); typedef property_map<directed_graph, vertex_name_t>::type vertex_map; typedef property_map<directed_graph, edge_name_t>::type edge_map; vertex_map vertexState = get(vertex_name, ruleNetwork); edge_map edgeState = get(edge_name, ruleNetwork); vertex parent, child; for(int i = 0 ; i < neighborhoodSpaceSize; ++i){ parent = add_vertex(ruleNetwork); child = add_vertex(ruleNetwork); GARN_neighborhood firstGeneration(intToNary (i,numStates,neighborhoodSize)); GARN_neighborhood secondGeneration(firstGeneration.stepTo (lookupTable.at(i))); vertexState[parent] = firstGeneration; vertexState[child] = secondGeneration; } } // Destructors------------------------------------------------------------- -----> GARN::~GARN(){ } // Accessors--------------------------------------------------------------- -----> directed_graph GARN::get_ruleNetwork(){ return ruleNetwork; } // Mutators---------------------------------------------------------------- -----> #endif
Hi!
From your code I can assume that directed_graph does not name a type is not the only error you receive.
You write: typedef adjacency_list<vecS, vecS, directedS, vertex_property, edge_property> directed_graph; If compiler does not know vecS, directedS, vertex_property, edge_property it also can't produce the template instantiation. Ok, vertex_property, edge_property are defined upon, but where are vecS, directedS? If these are in some other includes, ensure that they are visible at the point of instantiation. Sorry, if I am wrong. This is what I can conclude from viewing your code. Best Regards, Ovanes On Tue, January 9, 2007 21:13, Alec Resnick wrote:
It would seem that I'm having a bit of trouble nailing down the scope of a typedef of the adjacency_list type in a class I'm writing. For some reason, I keep getting the error "error: 'directed_graph' does not name a type" when trying to compile the following code using XCode 2.4 with the boost library installed via DarwinPorts and the appropriate library and search paths (/opt/local/lib/ and /opt/local/ include/) set.
If someone could help me out with this, I would very much appreciate it. Thanks for your time!
Gratefully, a.
/* * GARN.h * GA_RuleNetwork * * Created by Alec Resnick on 1/8/07. * Copyright 2007 dror. All rights reserved. * */
#ifndef GRAPH_AUTOMATA_RULE_NETWORK_CLASS_HEADER_FILE #define GRAPH_AUTOMATA_RULE_NETWORK_CLASS_HEADER_FILE
#include <iostream> #include <vector> #include <string> #include <math.h> #include <boost/graph/adjacency_list.hpp>
#include "GARN_helpers.h" #include "GARN_neighborhood.h"
using namespace std; using namespace boost;
class GARN{ typedef property<edge_name_t, int> edge_property; typedef property<vertex_name_t, GARN_neighborhood> vertex_property; typedef adjacency_list<vecS, vecS, directedS, vertex_property, edge_property> directed_graph; typedef graph_traits<directed_graph>::vertex_descriptor vertex; typedef graph_traits<directed_graph>::edge_descriptor edge;
private: vector<int> lookupTable; int neighborhoodSize; int numStates; int ruleNumber; directed_graph ruleNetwork; vector<GARN_neighborhood> neighborhoodSpace;
public: // Constructors------------------------------------------------------------ -> GARN(); GARN(int,int,int);
// Destructors------------------------------------------------------------- -> ~GARN();
// Accessors--------------------------------------------------------------- -> directed_graph get_ruleNetwork();
// Mutators---------------------------------------------------------------- -> };
// Constructors------------------------------------------------------------ -----> GARN::GARN(){
}
GARN::GARN(int _ruleNumber, int _numStates, int _neighborhoodSize){ ruleNumber = _ruleNumber; numStates = _numStates; neighborhoodSize = _neighborhoodSize;
int neighborhoodSpaceSize = int(pow(numStates,neighborhoodSize));
lookupTable = intToNary(ruleNumber, numStates, neighborhoodSpaceSize);
typedef property_map<directed_graph, vertex_name_t>::type vertex_map; typedef property_map<directed_graph, edge_name_t>::type edge_map;
vertex_map vertexState = get(vertex_name, ruleNetwork); edge_map edgeState = get(edge_name, ruleNetwork);
vertex parent, child;
for(int i = 0 ; i < neighborhoodSpaceSize; ++i){ parent = add_vertex(ruleNetwork); child = add_vertex(ruleNetwork);
GARN_neighborhood firstGeneration(intToNary (i,numStates,neighborhoodSize)); GARN_neighborhood secondGeneration(firstGeneration.stepTo (lookupTable.at(i)));
vertexState[parent] = firstGeneration; vertexState[child] = secondGeneration; } }
// Destructors------------------------------------------------------------- -----> GARN::~GARN(){
}
// Accessors--------------------------------------------------------------- -----> directed_graph GARN::get_ruleNetwork(){ return ruleNetwork; }
// Mutators---------------------------------------------------------------- -----> #endif
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Hi Alec, just in case this isn't solved for you yet... On 1/9/07, Alec Resnick <aresnick@mit.edu> wrote:
It would seem that I'm having a bit of trouble nailing down the scope of a typedef of the adjacency_list type in a class I'm writing. For some reason, I keep getting the error "error: 'directed_graph' does not name a type" when trying to compile the following code using XCode 2.4 with the boost library installed via DarwinPorts and the appropriate library and search paths (/opt/local/lib/ and /opt/local/ include/) set. [snip]
directed_graph GARN::get_ruleNetwork(){ return ruleNetwork; }
The error seems to be here. You've missed the scope for your directed_graph type here. I think this should read GARN::directed_graph GARN::get_ruleNerwork(); Cheers, Stephan
participants (3)
-
Alec Resnick
-
Ovanes Markarian
-
Stephan Diederich