_Xlength_error("vector too long") while resize a vector<int> to 0

105 Views Asked by At

I'm using LEMON library for its net flow algorithms, here is the whole program.

#include<iostream>
#include<cstdio>
#include<lemon\list_graph.h>
#include<lemon\lgf_reader.h>
#include<lemon\lgf_writer.h>
#include<yaml-cpp\yaml.h>
#include<lemon\dim2.h>

using namespace std;
using namespace lemon;

int main() {
    ListDigraph g_origin;
    ListDigraph::NodeMap<string> g_model(g_origin);
    ListDigraph::NodeMap<string> g_name(g_origin);
    ListDigraph::NodeMap<int> g_volume(g_origin);
    ListDigraph::ArcMap<double> g_cost(g_origin);
    string g_title;
    /*digraphReader(g_origin, "origin_map.lgf")
        .nodeMap("model", g_model)
        .nodeMap("name", g_name)
        .nodeMap("volume", g_volume)
        .arcMap("cost", g_cost)
        .attribute("caption", g_title)
        .run();*/
}

But, it throws error while running "ListDigraph::NodeMap g_volume(g_origin);"

I've checked the source code of LEMON and find that the NodeMap finally lead to class "ArrayMap"(it works well), and NodeMap lead to class "VectorMap"(error occurs here).

Here is the constructor used in this case for VectorMap:

    VectorMap(const GraphType& graph) {
        Parent::attach(graph.notifier(Item()));
        container.resize(Parent::notifier()->maxId() + 1);
    } 

and container is a member of the class which defined as:

    typedef std::vector<_Value> Container;
    Container container;

Under debugging mode, I notice that the "Parent::notifier()->maxId()" returns -1 normally, so the parameter of "resize()" is actually 0. So why vector::resize(0) throw error "vector too long"?

0

There are 0 best solutions below