I need a really simple thing in LEMON but I cannot solve it.
I have a weighted graph. Weights on arcs. I need to use the graph as part of a class object. Therefore I have the graph and the ArcMap (needed for the weights) as object attributes. Now, I have a function that computes both the graph and the Map, and later I will need in other function to use both graph and Map.
But I cannot create the map in the first function and then assign it to an attribute of the class. I get the following:
'operator=' is a private member of 'lemon::DigraphExtender<lemon::ListDigraphBase>::ArcMap<int>'
In the documentation I did not find anything, but it really seems a normal stuff computing something on a function to then use it into another.
I have my declaration like:
ListDigraph::ArcMap<int>& length;
And the assignment I try to do after the computation is:
ListDigraph::ArcMap<double> ll(g);
this->length = ll;
where g is:
ListDigraph g;
declared as a public attribute of the class.
EDIT:
#include <algorithm>
#include <random>
#include <thread>
#include <lemon/list_graph.h>
#include <lemon/maps.h>
#include "VLR_Config.h"
#include "VLR_Feed.h"
#include "VLR_Tools.h"
using namespace lemon;
class GraphSolver {
public:
void compute_graph() {
for (auto const &t: seq_trips) {
auto tid = t[0].trip_id;
for (int i = 0; i < t.size() - 1; ++i) {
auto from_sid = t[i].stop_id;
auto to_sid = t[i + 1].stop_id;
auto from_time = t[i].arrival_time;
auto to_time = t[i + 1].arrival_time;
auto delta = to_time - from_time;
ListDigraph::NodeMap<int> node2stop(g);
ListDigraph::Node from_node;
ListDigraph::Node to_node;
if (stop2node.find(from_sid) != stop2node.end())
from_node = stop2node.at(from_sid);
else {
from_node = g.addNode();
stop2node[from_sid] = from_node;
node2stop[from_node] = from_sid;
}
if (stop2node.find(to_sid) != stop2node.end())
to_node = stop2node.at(to_sid);
else {
to_node = g.addNode();
stop2node[to_sid] = to_node;
node2stop[to_node] = to_sid;
}
ListDigraph::Arc old_arc = findArc(g, from_node, to_node);
if(old_arc == INVALID) {
ListDigraph::Arc new_arc = g.addArc(from_node, to_node);
length[new_arc] = delta;
}
else
if(length[old_arc] < delta)
length[old_arc] = delta;
}
}
}
// Collect StopTimes by trips
SeqTrips seq_trips;
MapStop2Idx stop2idx;
VecStops stops;
VecTrips trips;
VecRoutes routes;
ListDigraph g;
unordered_map<size_t, ListDigraph::Node> stop2node;
ListDigraph::ArcMap<int> length(g);
};
with an error on the last line, since I cannot passing g
in that context. But, if I do not pass g
I get an error in the main when declaring the object of class GraphSolver :
GraphSolver graph_solver;
gives the error
Call to implicitly-deleted default constructor of 'VLR::GraphSolver' default constructor of 'GraphSolver' is implicitly deleted because field 'length' has no default constructor