I've implimented this snippet of code

dijkstra_shortest_paths(
            g, name2v[tempName1], 
            get(&VertexProperty::predecessor, g),
            get(&VertexProperty::distance, g),
            get(&EdgeProperty::weight, g),
            boost::identity_property_map(), // index-map
            std::less<double>(), // compare
            std::plus<double>(), // combine 
            std::numeric_limits<double>::infinity(), // infinity
            0.0, // zero
            do_nothing_dijkstra_visitor(),
            get(&VertexProperty::color, g));

to use dijkstra's on a map created from a text file, but I have no idea how to output the vertex I start at to the next one required to be visited and the distance between them repeatedly followed by the total distance traveled.

I can post any part of the code to assists with this.

I think this may be required, this is what I used to build the graph:

    std::map<std::string, Vertex> name2v;
    std::getline(fin, tempString); //Vertices:
    std::getline(fin, tempString); //Location1, Location2, ...
    std::stringstream tempSS(tempString);
    while (std::getline(tempSS,tempName1, ',')){
        name2v[tempName1] = add_vertex(VertexProperty(tempName1), g);
    }

    std::getline(fin,tempString); //Edges:
    while (std::getline(fin,tempString)){ // (Location1, Location2, 6)
        //remove parentheses
        tempString.erase( tempString.begin(), tempString.begin() + tempString.find('(') + 1 );
        tempString.erase( tempString.begin() + tempString.find(')'), tempString.end() );
        std::stringstream temp_ss(tempString);
        std::getline(temp_ss, tempName1, ',');
        std::getline(temp_ss, tempName2, ',');
        temp_ss >> weight;
        add_edge(name2v[tempName1],name2v[tempName2],EdgeProperty(weight), g);

    }

and if for some reason this is required to help me these are all of the things I've had to build to try to get this program working:

typedef boost::adjacency_list_traits<
    boost::vecS, boost::vecS, boost::undirectedS, boost::listS> GraphTraits;
typedef GraphTraits::vertex_descriptor Vertex;
struct VertexProperty {
    std::string name;
    Vertex predecessor;
    double distance;
    boost::default_color_type color;
    VertexProperty(const std::string& aName = "") : name(aName) { };
};

struct EdgeProperty {
    double weight;
    EdgeProperty(double aWeight = 0.0) : weight(aWeight) { };
};

typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::undirectedS, VertexProperty, EdgeProperty> Graph;
Graph g;
typedef float Weight;
typedef boost::adjacency_list_traits<
    boost::vecS, boost::vecS, boost::undirectedS, boost::listS> GraphTraits;
typedef boost::property<boost::edge_weight_t, Weight> WeightProperty;
typedef boost::property<boost::vertex_name_t, std::string> NameProperty;
  std::vector<Vertex> predecessors(boost::num_vertices(g)); // To store parents
  std::vector<Weight> distances(boost::num_vertices(g)); // To store distances

struct do_nothing_dijkstra_visitor {
    template <typename Vertex, typename Graph>
    void initialize_vertex(Vertex u, const Graph& g) const { };
    template <typename Vertex, typename Graph>
    void examine_vertex(Vertex u, const Graph& g) const { };
    template <typename Edge, typename Graph>
    void examine_edge(Edge e, const Graph& g) const { };
    template <typename Vertex, typename Graph>
    void discover_vertex(Vertex u, const Graph& g) const { };
    template <typename Edge, typename Graph>
    void edge_relaxed(Edge e, const Graph& g) const { };
    template <typename Edge, typename Graph>
    void edge_not_relaxed(Edge e, const Graph& g) const { };
    template <typename Vertex, typename Graph>
    void finish_vertex(Vertex u, const Graph& g) const { };
};

I have four hours before I have to turn this is and I am totally lost. if anyone wants to tell me what to do to get it to print the data found by dijkstra_shortest_paths that would be awesome, other wise I'll just fail, I don't really care anymore. here is my huge mess of a code, with commented out part of me doing my best trying to print it.

#include <iostream>
#include <fstream>
#include <map>
#include <vector>
#include <string>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/visitors.hpp>
#include <boost/graph/breadth_first_search.hpp>
#include <boost/graph/dijkstra_shortest_paths.hpp>
#include <boost/graph/metis.hpp>

typedef boost::adjacency_list_traits<
    boost::vecS, boost::vecS, boost::undirectedS, boost::listS> GraphTraits;
typedef GraphTraits::vertex_descriptor Vertex;
struct VertexProperty {
    std::string name;
    Vertex predecessor;
    double distance;
    boost::default_color_type color;
    VertexProperty(const std::string& aName = "") : name(aName) { };
};

struct EdgeProperty {
    double weight;
    EdgeProperty(double aWeight = 0.0) : weight(aWeight) { };
};

typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::undirectedS, VertexProperty, EdgeProperty> Graph;
Graph g;
typedef float Weight;
typedef boost::adjacency_list_traits<
    boost::vecS, boost::vecS, boost::undirectedS, boost::listS> GraphTraits;
typedef boost::property<boost::edge_weight_t, Weight> WeightProperty;
typedef boost::property<boost::vertex_name_t, std::string> NameProperty;
  std::vector<Vertex> predecessors(boost::num_vertices(g)); // To store parents
  std::vector<Weight> distances(boost::num_vertices(g)); // To store distances
        /*  std::vector< boost::graph_traits< graph_t >::vertex_descriptor > path;
boost::graph_traits< graph_t >::vertex_descriptor current = goal;
std::vector< boost::graph_traits< graph_t >::vertex_descriptor >::iterator it;*/

struct do_nothing_dijkstra_visitor {
    template <typename Vertex, typename Graph>
    void initialize_vertex(Vertex u, const Graph& g) const { };
    template <typename Vertex, typename Graph>
    void examine_vertex(Vertex u, const Graph& g) const { };
    template <typename Edge, typename Graph>
    void examine_edge(Edge e, const Graph& g) const { };
    template <typename Vertex, typename Graph>
    void discover_vertex(Vertex u, const Graph& g) const { };
    template <typename Edge, typename Graph>
    void edge_relaxed(Edge e, const Graph& g) const { };
    template <typename Edge, typename Graph>
    void edge_not_relaxed(Edge e, const Graph& g) const { };
    template <typename Vertex, typename Graph>
    void finish_vertex(Vertex u, const Graph& g) const { };
};

int main() {
    std::string tempName1;
    std::string tempName2;
    std::string tempString;
    std::string data2;
    double weight;
    std::cout <<"please enter the data file name: ";
    char strFileName[256];
    std::cin >> strFileName;

    // preparing the data
    std::ifstream fin;
    fin.open(strFileName);
    if(!fin) {
        std::cerr << "Can't open data file, leaving...\n";
        return EXIT_FAILURE;
    }
    else{
        std::cout<< "file loaded."<< std::endl << std::endl;
    }

    std::map<std::string, Vertex> name2v;
    std::getline(fin, tempString); //Vertices:
    std::getline(fin, tempString); //Location1, Location2, ...
    std::stringstream tempSS(tempString);
    while (std::getline(tempSS,tempName1, ',')){
        name2v[tempName1] = add_vertex(VertexProperty(tempName1), g);
    }

    std::getline(fin,tempString); //Edges:
    while (std::getline(fin,tempString)){ // (Location1, Location2, 6)
        //remove parentheses
        tempString.erase( tempString.begin(), tempString.begin() + tempString.find('(') + 1 );
        tempString.erase( tempString.begin() + tempString.find(')'), tempString.end() );
        std::stringstream temp_ss(tempString);
        std::getline(temp_ss, tempName1, ',');
        std::getline(temp_ss, tempName2, ',');
        temp_ss >> weight;
        add_edge(name2v[tempName1],name2v[tempName2],EdgeProperty(weight), g);

    }
        /*  std::vector< boost::graph_traits< graph_t >::vertex_descriptor > path;
boost::graph_traits< graph_t >::vertex_descriptor current = goal;
std::vector< graph_traits< graph_t >::vertex_descriptor >::iterator it;*/
    char x;
    std::cout<<std::endl << "How would you like to process your data file?"<<std::endl;
    std::cout << "1.) shortest path"<<std::endl;
    std::cout << "2.) minimum spanning tree" << std::endl;
    std::cout << "3.) Travelling Salesman" <<std::endl << std::endl;
returnQuestion:
    std::cout << "please enter 1,2,3 or Q to quit: ";
    std::cin >>x;


    switch (x){
    case '1': //do the work for shortest path
        std::cout<<std::endl << "please enter the location name to start from:";
        std::cin >>tempName1;
        std::cout<<std::endl << "please enter the location name for the destination:";
        std::cin >>tempName2;

        dijkstra_shortest_paths(
            g, name2v[tempName1], 
            get(&VertexProperty::predecessor, g),
            get(&VertexProperty::distance, g),
            get(&EdgeProperty::weight, g),
            boost::identity_property_map(), // index-map
            std::less<double>(), // compare
            std::plus<double>(), // combine 
            std::numeric_limits<double>::infinity(), // infinity
            0.0, // zero
            do_nothing_dijkstra_visitor(),
            get(&VertexProperty::color, g));
        std::cout << "distances and parents:" << std::endl;

/*

while(current!=start) {
    path.push_back(current);
    current=p[current];
}
path.push_back(start);

//This prints the path reversed use reverse_iterator and rbegin/rend

for (it=path.begin(); it != path.end(); ++it) {

    std::cout << name[*it] << " ";
}
std::cout << std::endl; */


        break;
    case '2': //do the work for minimum spanning

        break;
    case '3': //do the work for travelling salesman

        break;
    case 'q':
    case 'Q':
        return EXIT_SUCCESS;
        break;
    default :
        goto returnQuestion;
    }

    std::system("pause");
} 

found this online:

  std::vector< boost::graph_traits< Graph >::vertex_descriptor > path;
boost::graph_traits< Graph >::vertex_descriptor current;
std::vector< boost::graph_traits< Graph >::vertex_descriptor >::iterator it;

and edited it to work with my codes names and got this:

while(current!=start) {
    path.push_back(current);
    current=name2v[current];
}
path.push_back(start); //error here at the '.'

//This prints the path reversed use reverse_iterator and rbegin/rend

for (it=path.begin(); it != path.end(); ++it) {

    std::cout << name2v[*it] << " "; //error here on calling *it into name2v
}
std::cout << std::endl;

As I gave you the method to walk along the solution path on the other thread, here is the complete code (also removed some unnecessary junk, it is generally not a good idea to put together random pieces of code, you have to understand what you are doing):

#include <iostream>
#include <fstream>
#include <map>
#include <vector>
#include <string>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/visitors.hpp>
#include <boost/graph/breadth_first_search.hpp>
#include <boost/graph/dijkstra_shortest_paths.hpp>
#include <boost/graph/metis.hpp>

typedef boost::adjacency_list_traits<
    boost::vecS, boost::vecS, boost::undirectedS, boost::listS> GraphTraits;
// type 'Vertex' identifies each vertex uniquely:
typedef GraphTraits::vertex_descriptor Vertex;

// Property type associated to each vertex:
struct VertexProperty {
    std::string name;  // Name of vertex (i.e., "location")
    Vertex predecessor; // Predecessor along optimal path.
    double distance; // Distance to the goal, along shortest path.
    boost::default_color_type color; // for use by dijkstra.

    VertexProperty(const std::string& aName = "") : name(aName) { };
};

// Property type associated to each edge:
struct EdgeProperty {
    double weight; // distance to travel along this edge.

    EdgeProperty(double aWeight = 0.0) : weight(aWeight) { };
};

// Type of the graph used:
typedef boost::adjacency_list<
  boost::vecS, // out-edges stored in vector 
  boost::vecS, // vertices stored in vector
  boost::undirectedS, // undirected graph (edge don't have a specific direction)
  VertexProperty, // properties associated to each vertex.
  EdgeProperty // properties associated to each edge.
  > Graph;
// Create a global graph object 'g'
Graph g;

// This is a visitor for the dijkstra algorithm. This visitor does nothing special.
struct do_nothing_dijkstra_visitor {
    template <typename Vertex, typename Graph>
    void initialize_vertex(Vertex u, const Graph& g) const { };
    template <typename Vertex, typename Graph>
    void examine_vertex(Vertex u, const Graph& g) const { };
    template <typename Edge, typename Graph>
    void examine_edge(Edge e, const Graph& g) const { };
    template <typename Vertex, typename Graph>
    void discover_vertex(Vertex u, const Graph& g) const { };
    template <typename Edge, typename Graph>
    void edge_relaxed(Edge e, const Graph& g) const { };
    template <typename Edge, typename Graph>
    void edge_not_relaxed(Edge e, const Graph& g) const { };
    template <typename Vertex, typename Graph>
    void finish_vertex(Vertex u, const Graph& g) const { };
};

int main() {
    std::string tempName1;
    std::string tempName2;
    std::string tempString;
    std::string data2;
    double weight;
    std::cout <<"please enter the data file name: ";
    char strFileName[256];
    std::cin >> strFileName;

    // preparing the data
    std::ifstream fin;
    fin.open(strFileName);
    if(!fin) {
        std::cerr << "Can't open data file, leaving...\n";
        return EXIT_FAILURE;
    }
    else{
        std::cout<< "file loaded."<< std::endl << std::endl;
    }

    // Create a map to associate names to vertices of the graph:
    std::map<std::string, Vertex> name2v;

    std::getline(fin, tempString); //Vertices:
    std::getline(fin, tempString); //Location1, Location2, ...
    std::stringstream tempSS(tempString);
    while (std::getline(tempSS,tempName1, ',')) {
        // Add vertex to graph, with name 'tempName1' and 
        //  record the associated Vertex in the name2v map:
        name2v[tempName1] = add_vertex(VertexProperty(tempName1), g);
    }

    std::getline(fin,tempString); //Edges:
    while (std::getline(fin,tempString)){ // (Location1, Location2, 6)
        //remove parentheses
        tempString.erase( tempString.begin(), tempString.begin() + tempString.find('(') + 1 );
        tempString.erase( tempString.begin() + tempString.find(')'), tempString.end() );
        std::stringstream temp_ss(tempString);
        std::getline(temp_ss, tempName1, ',');
        std::getline(temp_ss, tempName2, ',');
        temp_ss >> weight;

        // Add edge to graph, by finding vertices associated 
        //  to tempName1 and tempName2:
        add_edge(name2v[tempName1], name2v[tempName2], EdgeProperty(weight), g);

    }

    char x;
    std::cout<<std::endl << "How would you like to process your data file?"<<std::endl;
    std::cout << "1.) shortest path"<<std::endl;
    std::cout << "2.) minimum spanning tree" << std::endl;
    std::cout << "3.) Travelling Salesman" <<std::endl << std::endl;
returnQuestion:
    std::cout << "please enter 1,2,3 or Q to quit: ";
    std::cin >> x;


    switch (x) {
    case '1': //do the work for shortest path
        std::cout<<std::endl << "please enter the location name to start from:";
        std::cin >>tempName1;

        std::cout<<std::endl << "please enter the location name for the destination:";
        std::cin >>tempName2;

        // Retrieve the vertices for the start and goal:
        Vertex start_v = name2v[tempName1];
        Vertex goal_v  = name2v[tempName2];

        dijkstra_shortest_paths(
            g, goal_v, // <-- solve to goal!
            get(&VertexProperty::predecessor, g),
            get(&VertexProperty::distance, g),
            get(&EdgeProperty::weight, g),
            boost::identity_property_map(), // index-map
            std::less<double>(), // compare
            std::plus<double>(), // combine 
            std::numeric_limits<double>::infinity(), // infinity
            0.0, // zero
            do_nothing_dijkstra_visitor(),
            get(&VertexProperty::color, g));
        std::cout << "distances and parents:" << std::endl;

        // Traverse the vertices from the start to goal,
        //  through the "predecessor" links:
        Vertex cur_v = start_v;
        while( cur_v != goal_v ) {
          std::cout << g[cur_v].name << " ";
          cur_v = g[cur_v].predecessor;
        };
        std::cout << g[goal_v].name << std::endl;

        break;
    case '2': //do the work for minimum spanning

        break;
    case '3': //do the work for travelling salesman

        break;
    case 'q':
    case 'Q':
        return EXIT_SUCCESS;
        break;
    default :
        goto returnQuestion;
    }

    std::system("pause");
} 

alright I am pretty sure I put all of those changes in right, but when I go through the menu and it asks me what node for start and finish, no what what nodes I enter it prints Location1.
it seems Vertex goal_v = name2v[tempName2]; is not editing goal_v, and it seems to always think cur_v = goal_v because of that and not enter the while loop.

I think that you are entering the wrong names, or something like that. If the names are not in name2v, the output will be 0, which is Location1, and if both are not found, then both the start and goal will be 0.

You should check again that the names are correct.

printed out tempnames, and they are getting the strings fine, did a std::cout << g[start_v].name << g[goal_v].name; and got Location1Location1, so the problem is in start_v = name2v[tempName1]; goal_v = name2v[tempName2];

Hey man. You're lost too? 2 hours 10 minutes man. I doubt we'll get past level 1

oh yeah, no way in hell. Only reason I have anything at all is because of Mike here. I emailed him already and told him he should make level 1 the project and level 2 and 3 extra credit. he didn't respond.

Of course he didn't. We're fucked. I've been looking at Mike's suggestions, and they've helped me a lot. But still...

std::cout << name2v[tempName1] << name2v[tempName2];

returns 00 so I'm wondering if name2v is even getting the names in the while loop. or if that is the wrong way to call them...or what

I mean, Even copying and pasting Mike's solution, I can't get cur_v, start_v, or goal_v to initialize.

yeah mike is awesome, he is the only reason I've not failed this class already. if you need more help (I doubt it that last post was pretty great) I had another thread earlier of trying to fix things earlier in the problem.

std::cout << g[name2v[tempName1]].name << g[name2v[tempName2]].name;also returns 00

you have to do it like this:

char x;
    Vertex cur_v;
    Vertex start_v;
    Vertex goal_v;
    std::cout<<std::endl << "How would you like to process your data file?"<<std::endl;
    std::cout << "1.) shortest path"<<std::endl;
    std::cout << "2.) minimum spanning tree" << std::endl;
    std::cout << "3.) Travelling Salesman" <<std::endl << std::endl;
returnQuestion:
    std::cout << "please enter 1,2,3 or Q to quit: ";
    std::cin >>x;


    switch (x){
    case '1': //do the work for shortest path
        std::cout<<std::endl << "please enter the location name to start from: ";
        std::cin >>tempName1;
        std::cout<<std::endl << "please enter the location name for the destination: ";
        std::cin >>tempName2;
        // Retrieve the vertices for the start and goal:
        start_v = name2v[tempName1];
        goal_v  = name2v[tempName2];
        std::cout << g[name2v[tempName1]].name << g[name2v[tempName2]].name;

        dijkstra_shortest_paths(
            g, goal_v, //<-- solve to goal 
            get(&VertexProperty::predecessor, g),
            get(&VertexProperty::distance, g),
            get(&EdgeProperty::weight, g),
            boost::identity_property_map(), // index-map
            std::less<double>(), // compare
            std::plus<double>(), // combine 
            std::numeric_limits<double>::infinity(), // infinity
            0.0, // zero
            do_nothing_dijkstra_visitor(),
            get(&VertexProperty::color, g));

        std::cout << "distances and parents:" << std::endl;
        // Traverse the vertices from the start to goal,
        //  through the "predecessor" links:
        cur_v = start_v;
        while( cur_v != goal_v ) {
          std::cout << g[cur_v].name << " " << g[cur_v].distance;
          cur_v = g[cur_v].predecessor;
        };
        std::cout << g[goal_v].name << " " << g[goal_v].distance<< std::endl;
        break;
    case '2': //do the work for minimum spanning

        break;
    case '3': //do the work for travelling salesman

        break;
    case 'q':
    case 'Q':
        return EXIT_SUCCESS;
        break;
    default :
        goto returnQuestion;
    }

    std::system("pause");
} 

that is how the end of the code needs to be because you can't instantiate what a varible is inside of a switch.

The program that I have posted last works correctly on my end. I tried using the following file:

Vertices:
Location1,Location2,Location3,Location4,Location5
Edges:
(Location1,Location2,5)
(Location2,Location3,1)
(Location2,Location4,2)
(Location3,Location5,3)
(Location1,Location4,1)

And I ran the program (exactly as posted a few posts back), and I got the following output:

$ ./dijkstra_solver 
please enter the data file name: dijkstra_solver.txt
file loaded.


How would you like to process your data file?
1.) shortest path
2.) minimum spanning tree
3.) Travelling Salesman

please enter 1,2,3 or Q to quit: 1

please enter the location name to start from:Location1

please enter the location name for the destination:Location5
distances and parents:
Location1 Location4 Location2 Location3 Location5

And you can verify yourself from the weights of the edges that this is indeed the shortest path from 1 to 5.

I think the problem might be related to having spaces between the names in the file. So, you might want to add some code to remove the leading or trailing space characters from the names you get from the file. You can do this the same way as with the removal of the parentheses.

I get a debug error when the file loads.

String iterator + offset out of range.

Any ideas?

that does seem to be the problem, this is the problem with working on things too long, I had wondered if that would cause issues about 20 hours ago, and had forgotten about the spaces. so now when I do std::cout << g[goal_v].name << " " << g[goal_v].distance<< std::endl; I get the track and the total counting distance as it goes, but it's backwards.

so now I need to figure out how to display it in the propper order, he says is needs to look like this.
Edge1
Edge2

EdgeN
Total Weight: integer

yeah mike is awesome, he is the only reason I've not failed this class already.

I sympathize with you guys. I think your prof really threw you in the deep end with this assignment. If you were to do this without BGL, you would have to implement an adjacency-list data structure and a Dijkstra algorithm, both of which can be a big challenge for any programmer, let alone beginners. If you use the BGL, you don't have to implement all that, but you have to use a library that is definitely not meant for beginners to use (i.e., although, as an expert, I love the BGL for its flexibility, it is often criticised for being too difficult to use). It is a bit unreasonable for a prof to expect you to pick-up on being able to use the BGL just like that, he should have given you at least a whole lecture (e.g., 3 hours) on how the BGL works and how to use it.

This is why I'm helping you far more than I usually would.

Alright, now I just need to write the code to remove the space if it is there, and Then I can get up to 70% on this project! lol

Any idea on the debug assertion error?

Yeah I really appreciate your help on all three of these projects.

squoosh you are running into "Can't open data file, leaving..."? is your data.txt inside your project folder like this. "C:\Users\Evan\Documents\Visual Studio 2012\Projects\BOOST_TSP\BOOST_TSP\data.txt" because that is where it will look by default, and you need to add the .txt to the end of the file name for it to work.

so inside the edge while loop I need to remove spaces in a few spots if they are found and how to go about doing that is tricky, so a call of tempString.erase() that you have in this program looks like it takes two locations in the string a removes everything between those two palces. is that right?

Yes that's right.

I'm trying to figure out how to set up an if statment for finding spaces, but if(tempString.find(' ')) is used it doesn't go into the loop even though there are spaces for it to find...

only another hour, I gotta say I didn't think this project would be that hard when he gave us the write up (in theory this should have only taken an hour), but the sytax is so daunting I'm not sure how we were expected to have time to do all three tiers of this project.

No, it opens just fine. after it asserts that the file is loaded, it has a debug error, stating that

string iterator + offset out of range.

I'm confused.

The find function finds the index of the first character specified. Just read the docs for string. If there are no characters equal to that one, it will return the index at the end of the string.

Actually, the easiest way to just remove all the spaces is this:

tempName1.erase(std::remove(tempName1.begin(), tempName1.end(), ' '), tempName1.end());

But that will also remove spaces in the middle of the name.

To extract only the string in the middle (between leading and trailing spaces), you can use this:

std::size_t first_c = tempName1.find_first_not_of(' ');
std::size_t last_c = tempName1.find_last_not_of(' ');
tempName1 = tempName1.substr(first_c, last_c - first_c + 1);

which looks for the first non-space character and the last non-space character, and then extract the sub-string between those two indices (the + 1 is to get the length between the indices to include the last non-space character).

so I found this: std::remove_if(tempString.begin(), tempString.end(), isspace); and that gets rid of the spaces, but rather than:
Location1,Location2,5
Location2,Location3,1
Location2,Location4,2
Location3,Location5,3
Location1,Location4,1

which is what this program requires I for some reason get
Location1,Location2,52 , 5
Location2,Location3,13 , 1
Location2,Location4,24 , 2
Location3,Location5,35 , 3
Location1,Location4,14 , 1

and I have no idea why, remove if is the only thing I added, why would that add the number from the second location a space a cama a space and the weight again after what I need?

while (std::getline(fin,tempString)){ // (Location1, Location2, 6)
        //remove parentheses
        tempString.erase( tempString.begin(), tempString.begin() + tempString.find('(') + 1 );
        tempString.erase( tempString.begin() + tempString.find(')'), tempString.end() );

        std::size_t first_c = tempName1.find_first_not_of(' ');
        std::size_t last_c = tempName1.find_last_not_of(' ');
        tempName1 = tempName1.substr(first_c, last_c - first_c + 1);
        std::cout<<std::endl<<tempString;

        std::stringstream temp_ss(tempString);
        std::getline(temp_ss, tempName1, ',');
        std::getline(temp_ss, tempName2, ',');
        temp_ss >> weight;
        // Add edge to graph, by finding vertices associated 
        //  to tempName1 and tempName2:
        add_edge(name2v[tempName1],name2v[tempName2],EdgeProperty(weight), g);
    }

complies but does nothing and I still have:
Location1 , Location2 , 5
Location2 , Location3 , 1
Location2 , Location4 , 2
Location3 , Location5 , 3
Location1 , Location4 , 1

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.