Commit f74de6f6 authored by Tiago Peixoto's avatar Tiago Peixoto
Browse files

Change Graph.max_edge_index to Graph.edge_index_range

parent 5c872d16
...@@ -143,7 +143,7 @@ void betweenness(GraphInterface& g, boost::any weight, ...@@ -143,7 +143,7 @@ void betweenness(GraphInterface& g, boost::any weight,
std::placeholders::_1, g.get_vertex_index(), std::placeholders::_1, g.get_vertex_index(),
std::placeholders::_2, std::placeholders::_2,
std::placeholders::_3, weight, normalize, std::placeholders::_3, weight, normalize,
g.get_num_vertices(), g.get_max_edge_index()), g.get_num_vertices(), g.get_edge_index_range()),
edge_floating_properties(), edge_floating_properties(),
vertex_floating_properties()) vertex_floating_properties())
(edge_betweenness, vertex_betweenness); (edge_betweenness, vertex_betweenness);
......
...@@ -240,7 +240,7 @@ struct move_sweep_dispatch ...@@ -240,7 +240,7 @@ struct move_sweep_dispatch
vector<int64_t>& target_list, bool deg_corr, bool dense, vector<int64_t>& target_list, bool deg_corr, bool dense,
bool multigraph, double beta, bool sequential, bool multigraph, double beta, bool sequential,
bool parallel, bool random_move, double c, bool verbose, bool parallel, bool random_move, double c, bool verbose,
size_t max_edge_index, size_t nmerges, size_t niter, size_t edge_index_range, size_t nmerges, size_t niter,
Vprop merge_map, partition_stats_t& partition_stats, Vprop merge_map, partition_stats_t& partition_stats,
rng_t& rng, double& S, size_t& nmoves, rng_t& rng, double& S, size_t& nmoves,
GraphInterface& bgi) GraphInterface& bgi)
...@@ -250,7 +250,7 @@ struct move_sweep_dispatch ...@@ -250,7 +250,7 @@ struct move_sweep_dispatch
target_list(target_list), deg_corr(deg_corr), dense(dense), target_list(target_list), deg_corr(deg_corr), dense(dense),
multigraph(multigraph), beta(beta), sequential(sequential), multigraph(multigraph), beta(beta), sequential(sequential),
parallel(parallel), random_move(random_move), parallel(parallel), random_move(random_move),
c(c), verbose(verbose), max_edge_index(max_edge_index), c(c), verbose(verbose), edge_index_range(edge_index_range),
nmerges(nmerges), niter(niter), merge_map(merge_map), nmerges(nmerges), niter(niter), merge_map(merge_map),
partition_stats(partition_stats), rng(rng), S(S), partition_stats(partition_stats), rng(rng), S(S),
nmoves(nmoves), bgi(bgi) nmoves(nmoves), bgi(bgi)
...@@ -275,7 +275,7 @@ struct move_sweep_dispatch ...@@ -275,7 +275,7 @@ struct move_sweep_dispatch
bool random_move; bool random_move;
double c; double c;
bool verbose; bool verbose;
size_t max_edge_index; size_t edge_index_range;
size_t nmerges; size_t nmerges;
size_t niter; size_t niter;
Vprop merge_map; Vprop merge_map;
...@@ -367,7 +367,7 @@ struct move_sweep_dispatch ...@@ -367,7 +367,7 @@ struct move_sweep_dispatch
{ {
typedef typename graph_traits<Graph>::vertex_descriptor vertex_t; typedef typename graph_traits<Graph>::vertex_descriptor vertex_t;
size_t eidx = random_move ? 1 : max_edge_index; size_t eidx = random_move ? 1 : edge_index_range;
typedef typename property_map<Graph, vertex_index_t>::type vindex_map_t; typedef typename property_map<Graph, vertex_index_t>::type vindex_map_t;
typedef typename property_map_type::apply<Sampler<vertex_t, boost::mpl::false_>, typedef typename property_map_type::apply<Sampler<vertex_t, boost::mpl::false_>,
...@@ -386,7 +386,7 @@ struct move_sweep_dispatch ...@@ -386,7 +386,7 @@ struct move_sweep_dispatch
overlap_stats_t ostats; overlap_stats_t ostats;
vector<size_t> free_blocks; vector<size_t> free_blocks;
auto state = make_block_state(g, eweight.get_unchecked(max_edge_index), auto state = make_block_state(g, eweight.get_unchecked(edge_index_range),
vweight.get_unchecked(num_vertices(g)), vweight.get_unchecked(num_vertices(g)),
b.get_unchecked(num_vertices(g)), bg, b.get_unchecked(num_vertices(g)), bg,
emat, mrs, emat, mrs,
...@@ -412,7 +412,7 @@ struct move_sweep_dispatch ...@@ -412,7 +412,7 @@ struct move_sweep_dispatch
label.get_unchecked(num_vertices(bg)), label.get_unchecked(num_vertices(bg)),
vlist, block_list, vlist, block_list,
deg_corr, dense, multigraph, beta, deg_corr, dense, multigraph, beta,
eweight.get_unchecked(max_edge_index), eweight.get_unchecked(edge_index_range),
vweight.get_unchecked(num_vertices(g)), vweight.get_unchecked(num_vertices(g)),
g, sequential, parallel, random_move, c, g, sequential, parallel, random_move, c,
nmerges, nmerges,
...@@ -490,7 +490,7 @@ boost::python::object do_move_sweep(GraphInterface& gi, GraphInterface& bgi, ...@@ -490,7 +490,7 @@ boost::python::object do_move_sweep(GraphInterface& gi, GraphInterface& bgi,
label, vlist, block_list, label, vlist, block_list,
target_list, deg_corr, dense, multigraph, target_list, deg_corr, dense, multigraph,
beta, sequential, parallel, random_move, c, verbose, beta, sequential, parallel, random_move, c, verbose,
gi.get_max_edge_index(), nmerges, niter, merge_map, gi.get_edge_index_range(), nmerges, niter, merge_map,
partition_stats, rng, S, nmoves, bgi), partition_stats, rng, S, nmoves, bgi),
mrs, mrp, mrm, wr, b, placeholders::_1, mrs, mrp, mrm, wr, b, placeholders::_1,
std::ref(emat), sampler, cavity_sampler, weighted))(); std::ref(emat), sampler, cavity_sampler, weighted))();
...@@ -532,9 +532,9 @@ boost::any do_build_egroups(GraphInterface& gi, GraphInterface& bgi, ...@@ -532,9 +532,9 @@ boost::any do_build_egroups(GraphInterface& gi, GraphInterface& bgi,
boost::any oegroups; boost::any oegroups;
run_action<graph_tool::detail::all_graph_views, boost::mpl::true_>() run_action<graph_tool::detail::all_graph_views, boost::mpl::true_>()
(gi, std::bind<void>(build_egroups(), b, std::ref(oegroups), (gi, std::bind<void>(build_egroups(), b, std::ref(oegroups),
esrcpos.get_unchecked(gi.get_max_edge_index()), esrcpos.get_unchecked(gi.get_edge_index_range()),
etgtpos.get_unchecked(gi.get_max_edge_index()), etgtpos.get_unchecked(gi.get_edge_index_range()),
eweights.get_unchecked(gi.get_max_edge_index()), eweights.get_unchecked(gi.get_edge_index_range()),
placeholders::_1, bgi.get_vertex_index(), placeholders::_1, bgi.get_vertex_index(),
bgi.get_num_vertices(), weighted, empty))(); bgi.get_num_vertices(), weighted, empty))();
return oegroups; return oegroups;
......
...@@ -62,7 +62,7 @@ struct cov_move_sweep_dispatch ...@@ -62,7 +62,7 @@ struct cov_move_sweep_dispatch
bool sequential, bool parallel, bool random_move, bool sequential, bool parallel, bool random_move,
bool node_coherent, bool confine_layers, double c, bool node_coherent, bool confine_layers, double c,
bool verbose, size_t meindex, bool verbose, size_t meindex,
vector<size_t> max_edge_index, size_t nmerges, vector<size_t> edge_index_range, size_t nmerges,
size_t niter, Vprop merge_map, size_t niter, Vprop merge_map,
vector<std::reference_wrapper<partition_stats_t>>& partition_stats, vector<std::reference_wrapper<partition_stats_t>>& partition_stats,
vector<std::reference_wrapper<overlap_partition_stats_t>>& overlap_partition_stats, vector<std::reference_wrapper<overlap_partition_stats_t>>& overlap_partition_stats,
...@@ -82,7 +82,7 @@ struct cov_move_sweep_dispatch ...@@ -82,7 +82,7 @@ struct cov_move_sweep_dispatch
sequential(sequential), parallel(parallel), random_move(random_move), sequential(sequential), parallel(parallel), random_move(random_move),
node_coherent(node_coherent), confine_layers(confine_layers), node_coherent(node_coherent), confine_layers(confine_layers),
c(c), verbose(verbose), meindex(meindex), c(c), verbose(verbose), meindex(meindex),
max_edge_index(max_edge_index), edge_index_range(edge_index_range),
nmerges(nmerges), niter(niter), merge_map(merge_map), nmerges(nmerges), niter(niter), merge_map(merge_map),
partition_stats(partition_stats), partition_stats(partition_stats),
overlap_partition_stats(overlap_partition_stats), overlap_partition_stats(overlap_partition_stats),
...@@ -117,7 +117,7 @@ struct cov_move_sweep_dispatch ...@@ -117,7 +117,7 @@ struct cov_move_sweep_dispatch
double c; double c;
bool verbose; bool verbose;
size_t meindex; size_t meindex;
vector<size_t> max_edge_index; vector<size_t> edge_index_range;
size_t nmerges; size_t nmerges;
size_t niter; size_t niter;
Vprop merge_map; Vprop merge_map;
...@@ -300,10 +300,10 @@ struct cov_move_sweep_dispatch ...@@ -300,10 +300,10 @@ struct cov_move_sweep_dispatch
for (size_t i = 0; i < mrs.size(); ++i) for (size_t i = 0; i < mrs.size(); ++i)
{ {
size_t eidx = random_move ? 1 : max_edge_index[i]; size_t eidx = random_move ? 1 : edge_index_range[i];
state_t state = make_block_state(gs[i].get(), state_t state = make_block_state(gs[i].get(),
eweight[i].get().get_unchecked(max_edge_index[i]), eweight[i].get().get_unchecked(edge_index_range[i]),
vweight[i].get().get_unchecked(num_vertices(gs[i].get())), vweight[i].get().get_unchecked(num_vertices(gs[i].get())),
bs[i].get().get_unchecked(num_vertices(gs[i].get())), bs[i].get().get_unchecked(num_vertices(gs[i].get())),
bgs[i].get(), bgs[i].get(),
...@@ -337,7 +337,7 @@ struct cov_move_sweep_dispatch ...@@ -337,7 +337,7 @@ struct cov_move_sweep_dispatch
label.get_unchecked(B), label.get_unchecked(B),
vlist, block_list, deg_corr, vlist, block_list, deg_corr,
dense, multigraph, beta, dense, multigraph, beta,
eweight[0].get().get_unchecked(max_edge_index[0]), eweight[0].get().get_unchecked(edge_index_range[0]),
vweight[0].get().get_unchecked(num_vertices(g)), vweight[0].get().get_unchecked(num_vertices(g)),
g, sequential, parallel, random_move, c, g, sequential, parallel, random_move, c,
nmerges, nmerges,
...@@ -375,10 +375,10 @@ struct cov_move_sweep_dispatch ...@@ -375,10 +375,10 @@ struct cov_move_sweep_dispatch
vector<state_t> states; vector<state_t> states;
for (size_t i = 0; i < mrs.size(); ++i) for (size_t i = 0; i < mrs.size(); ++i)
{ {
size_t eidx = random_move ? 1 : max_edge_index[i]; size_t eidx = random_move ? 1 : edge_index_range[i];
state_t state = make_block_state(gs[i].get(), state_t state = make_block_state(gs[i].get(),
eweight[i].get().get_unchecked(max_edge_index[i]), eweight[i].get().get_unchecked(edge_index_range[i]),
vweight[i].get().get_unchecked(num_vertices(gs[i].get())), vweight[i].get().get_unchecked(num_vertices(gs[i].get())),
bs[i].get().get_unchecked(num_vertices(gs[i].get())), bs[i].get().get_unchecked(num_vertices(gs[i].get())),
bgs[i].get(), bgs[i].get(),
...@@ -577,7 +577,7 @@ boost::python::object do_cov_move_sweep(GraphInterface& gi, ...@@ -577,7 +577,7 @@ boost::python::object do_cov_move_sweep(GraphInterface& gi,
vector<size_t> eidx; vector<size_t> eidx;
for (GraphInterface& g : gis) for (GraphInterface& g : gis)
eidx.push_back(g.get_max_edge_index()); eidx.push_back(g.get_edge_index_range());
auto bgi = from_rlist<GraphInterface>(obgi); auto bgi = from_rlist<GraphInterface>(obgi);
...@@ -606,7 +606,7 @@ boost::python::object do_cov_move_sweep(GraphInterface& gi, ...@@ -606,7 +606,7 @@ boost::python::object do_cov_move_sweep(GraphInterface& gi,
label, vlist, block_list, target_blocks, deg_corr, dense, label, vlist, block_list, target_blocks, deg_corr, dense,
multigraph, beta, sequential, parallel, random_move, multigraph, beta, sequential, parallel, random_move,
node_coherent, confine_layers, c, verbose, node_coherent, confine_layers, c, verbose,
gi.get_max_edge_index(), eidx, nmerges, niter, merge_map, gi.get_edge_index_range(), eidx, nmerges, niter, merge_map,
partition_stats, overlap_partition_stats, overlap_stats, partition_stats, overlap_partition_stats, overlap_stats,
master, slave, rng, S, nmoves, bgi, bmap, brmap, free_blocks, B), master, slave, rng, S, nmoves, bgi, bmap, brmap, free_blocks, B),
std::ref(mrs), std::ref(mrp), std::ref(mrm), std::ref(wr), std::ref(mrs), std::ref(mrp), std::ref(mrm), std::ref(wr),
...@@ -653,7 +653,7 @@ void do_ec_hist(GraphInterface& gi, boost::any& aevc, boost::any& aec) ...@@ -653,7 +653,7 @@ void do_ec_hist(GraphInterface& gi, boost::any& aevc, boost::any& aec)
GraphInterface::edge_index_map_t>::type GraphInterface::edge_index_map_t>::type
emap_t; emap_t;
typename emap_t::unchecked_t ec = typename emap_t::unchecked_t ec =
any_cast<emap_t&>(aec).get_unchecked(gi.get_max_edge_index()); any_cast<emap_t&>(aec).get_unchecked(gi.get_edge_index_range());
run_action<>()(gi, std::bind<void>(ec_hist(), placeholders::_1, run_action<>()(gi, std::bind<void>(ec_hist(), placeholders::_1,
placeholders::_2, std::ref(ec)), placeholders::_2, std::ref(ec)),
edge_properties())(aevc); edge_properties())(aevc);
......
...@@ -58,7 +58,7 @@ struct move_sweep_overlap_dispatch ...@@ -58,7 +58,7 @@ struct move_sweep_overlap_dispatch
bool parallel_edges, double beta, bool parallel_edges, double beta,
bool sequential, bool parallel, bool sequential, bool parallel,
bool random_move, double c, bool node_coherent, bool random_move, double c, bool node_coherent,
bool verbose, size_t max_edge_index, bool verbose, size_t edge_index_range,
size_t nmerges, size_t niter, Vprop merge_map, size_t nmerges, size_t niter, Vprop merge_map,
overlap_stats_t& overlap_stats, overlap_stats_t& overlap_stats,
overlap_partition_stats_t& partition_stats, overlap_partition_stats_t& partition_stats,
...@@ -71,7 +71,7 @@ struct move_sweep_overlap_dispatch ...@@ -71,7 +71,7 @@ struct move_sweep_overlap_dispatch
multigraph(multigraph), parallel_edges(parallel_edges), beta(beta), multigraph(multigraph), parallel_edges(parallel_edges), beta(beta),
sequential(sequential), parallel(parallel), random_move(random_move), sequential(sequential), parallel(parallel), random_move(random_move),
c(c), node_coherent(node_coherent), verbose(verbose), c(c), node_coherent(node_coherent), verbose(verbose),
max_edge_index(max_edge_index), nmerges(nmerges), edge_index_range(edge_index_range), nmerges(nmerges),
niter(niter), merge_map(merge_map), overlap_stats(overlap_stats), niter(niter), merge_map(merge_map), overlap_stats(overlap_stats),
partition_stats(partition_stats), rng(rng), S(S), nmoves(nmoves), bgi(bgi) partition_stats(partition_stats), rng(rng), S(S), nmoves(nmoves), bgi(bgi)
{} {}
...@@ -97,7 +97,7 @@ struct move_sweep_overlap_dispatch ...@@ -97,7 +97,7 @@ struct move_sweep_overlap_dispatch
double c; double c;
bool node_coherent; bool node_coherent;
bool verbose; bool verbose;
size_t max_edge_index; size_t edge_index_range;
size_t nmerges; size_t nmerges;
size_t niter; size_t niter;
Vprop merge_map; Vprop merge_map;
...@@ -180,7 +180,7 @@ struct move_sweep_overlap_dispatch ...@@ -180,7 +180,7 @@ struct move_sweep_overlap_dispatch
{ {
typedef typename graph_traits<Graph>::vertex_descriptor vertex_t; typedef typename graph_traits<Graph>::vertex_descriptor vertex_t;
size_t eidx = random_move ? 1 : max_edge_index; size_t eidx = random_move ? 1 : edge_index_range;
typedef typename property_map<Graph, vertex_index_t>::type vindex_map_t; typedef typename property_map<Graph, vertex_index_t>::type vindex_map_t;
typedef typename property_map_type::apply<Sampler<vertex_t, boost::mpl::false_>, typedef typename property_map_type::apply<Sampler<vertex_t, boost::mpl::false_>,
...@@ -197,7 +197,7 @@ struct move_sweep_overlap_dispatch ...@@ -197,7 +197,7 @@ struct move_sweep_overlap_dispatch
vector<size_t> free_blocks; vector<size_t> free_blocks;
auto state = make_block_state(g, auto state = make_block_state(g,
eweight.get_unchecked(max_edge_index), eweight.get_unchecked(edge_index_range),
vweight.get_unchecked(num_vertices(g)), vweight.get_unchecked(num_vertices(g)),
b.get_unchecked(num_vertices(g)), b.get_unchecked(num_vertices(g)),
bg, emat, mrs, bg, emat, mrs,
...@@ -325,7 +325,7 @@ do_move_sweep_overlap(GraphInterface& gi, GraphInterface& bgi, boost::any& emat, ...@@ -325,7 +325,7 @@ do_move_sweep_overlap(GraphInterface& gi, GraphInterface& bgi, boost::any& emat,
(eweight, vweight, oegroups, esrcpos, etgtpos, (eweight, vweight, oegroups, esrcpos, etgtpos,
label, vlist, block_list, target_blocks, deg_corr, dense, label, vlist, block_list, target_blocks, deg_corr, dense,
multigraph, parallel_edges, beta, sequential, parallel, multigraph, parallel_edges, beta, sequential, parallel,
random_move, c, node_coherent, verbose, gi.get_max_edge_index(), random_move, c, node_coherent, verbose, gi.get_edge_index_range(),
nmerges, niter, merge_map, overlap_stats, partition_stats, nmerges, niter, merge_map, overlap_stats, partition_stats,
rng, S, nmoves, bgi), rng, S, nmoves, bgi),
mrs, mrp, mrm, wr, b, placeholders::_1, mrs, mrp, mrm, wr, b, placeholders::_1,
......
...@@ -71,7 +71,7 @@ void edmonds_karp_max_flow(GraphInterface& gi, size_t src, size_t sink, ...@@ -71,7 +71,7 @@ void edmonds_karp_max_flow(GraphInterface& gi, size_t src, size_t sink,
run_action<graph_tool::detail::always_directed>() run_action<graph_tool::detail::always_directed>()
(gi, std::bind(get_edmonds_karp_max_flow(), (gi, std::bind(get_edmonds_karp_max_flow(),
placeholders::_1, gi.get_vertex_index(), gi.get_edge_index(), placeholders::_1, gi.get_vertex_index(), gi.get_edge_index(),
gi.get_max_edge_index(), gi.get_edge_index_range(),
src, sink, placeholders::_2, placeholders::_3), src, sink, placeholders::_2, placeholders::_3),
writable_edge_scalar_properties(), writable_edge_scalar_properties()) writable_edge_scalar_properties(), writable_edge_scalar_properties())
(capacity,res); (capacity,res);
......
...@@ -97,7 +97,7 @@ void kolmogorov_max_flow(GraphInterface& gi, size_t src, size_t sink, ...@@ -97,7 +97,7 @@ void kolmogorov_max_flow(GraphInterface& gi, size_t src, size_t sink,
{ {
run_action<graph_tool::detail::always_directed, boost::mpl::true_>() run_action<graph_tool::detail::always_directed, boost::mpl::true_>()
(gi, std::bind(get_kolmogorov_max_flow(), (gi, std::bind(get_kolmogorov_max_flow(),
placeholders::_1, gi.get_edge_index(), gi.get_max_edge_index(), placeholders::_1, gi.get_edge_index(), gi.get_edge_index_range(),
gi.get_vertex_index(), src, sink, placeholders::_2, gi.get_vertex_index(), src, sink, placeholders::_2,
placeholders::_3), placeholders::_3),
writable_edge_scalar_properties(), writable_edge_scalar_properties()) writable_edge_scalar_properties(), writable_edge_scalar_properties())
......
...@@ -88,7 +88,7 @@ void push_relabel_max_flow(GraphInterface& gi, size_t src, size_t sink, ...@@ -88,7 +88,7 @@ void push_relabel_max_flow(GraphInterface& gi, size_t src, size_t sink,
run_action<graph_tool::detail::always_directed, boost::mpl::true_>() run_action<graph_tool::detail::always_directed, boost::mpl::true_>()
(gi, std::bind(get_push_relabel_max_flow(), (gi, std::bind(get_push_relabel_max_flow(),
placeholders::_1, gi.get_vertex_index(), gi.get_edge_index(), placeholders::_1, gi.get_vertex_index(), gi.get_edge_index(),
gi.get_max_edge_index(), gi.get_edge_index_range(),
src, sink, placeholders::_2, placeholders::_3), src, sink, placeholders::_2, placeholders::_3),
writable_edge_scalar_properties(), writable_edge_scalar_properties()) writable_edge_scalar_properties(), writable_edge_scalar_properties())
(capacity,res); (capacity,res);
......
...@@ -139,7 +139,7 @@ size_t random_rewire(GraphInterface& gi, string strat, size_t niter, ...@@ -139,7 +139,7 @@ size_t random_rewire(GraphInterface& gi, string strat, size_t niter,
emap_t; emap_t;
emap_t::unchecked_t pin = emap_t::unchecked_t pin =
any_cast<emap_t>(apin).get_unchecked(gi.get_max_edge_index()); any_cast<emap_t>(apin).get_unchecked(gi.get_edge_index_range());
if (strat == "erdos") if (strat == "erdos")
......
...@@ -145,7 +145,7 @@ public: ...@@ -145,7 +145,7 @@ public:
std::shared_ptr<multigraph_t> get_graph_ptr() {return _mg;} std::shared_ptr<multigraph_t> get_graph_ptr() {return _mg;}
vertex_index_map_t get_vertex_index() {return _vertex_index;} vertex_index_map_t get_vertex_index() {return _vertex_index;}
edge_index_map_t get_edge_index() {return _edge_index;} edge_index_map_t get_edge_index() {return _edge_index;}
size_t get_max_edge_index() {return _mg->get_last_index();} size_t get_edge_index_range() {return _mg->get_edge_index_range();}
graph_index_map_t get_graph_index() {return graph_index_map_t(0);} graph_index_map_t get_graph_index() {return graph_index_map_t(0);}
......
...@@ -164,7 +164,7 @@ public: ...@@ -164,7 +164,7 @@ public:
typedef std::vector<std::pair<vertex_t, vertex_t> > edge_list_t; typedef std::vector<std::pair<vertex_t, vertex_t> > edge_list_t;
typedef typename integer_range<Vertex>::iterator vertex_iterator; typedef typename integer_range<Vertex>::iterator vertex_iterator;
adj_list(): _n_edges(0), _last_idx(0), _keep_epos(false) {} adj_list(): _n_edges(0), _edge_index_range(0), _keep_epos(false) {}
struct get_vertex struct get_vertex
{ {
...@@ -262,7 +262,7 @@ public: ...@@ -262,7 +262,7 @@ public:
void reindex_edges() void reindex_edges()
{ {
_free_indexes.clear(); _free_indexes.clear();
_last_idx = 0; _edge_index_range = 0;
_in_edges.clear(); _in_edges.clear();
_in_edges.resize(_out_edges.size()); _in_edges.resize(_out_edges.size());
for (size_t i = 0; i < _out_edges.size(); ++i) for (size_t i = 0; i < _out_edges.size(); ++i)
...@@ -272,9 +272,9 @@ public: ...@@ -272,9 +272,9 @@ public:
{ {
auto& oe = oes[j]; auto& oe = oes[j];
Vertex v = oe.first; Vertex v = oe.first;
oe.second = _last_idx; oe.second = _edge_index_range;
_in_edges[v].emplace_back(i, _last_idx); _in_edges[v].emplace_back(i, _edge_index_range);
_last_idx++; _edge_index_range++;
} }
} }
...@@ -301,7 +301,7 @@ public: ...@@ -301,7 +301,7 @@ public:
return _keep_epos; return _keep_epos;
} }
size_t get_last_index() const { return _last_idx; } size_t get_edge_index_range() const { return _edge_index_range; }
static Vertex null_vertex() { return std::numeric_limits<Vertex>::max(); } static Vertex null_vertex() { return std::numeric_limits<Vertex>::max(); }
...@@ -318,17 +318,17 @@ public: ...@@ -318,17 +318,17 @@ public:
[](const auto &a, const auto& b) -> bool [](const auto &a, const auto& b) -> bool
{return a.idx < b.idx;}); {return a.idx < b.idx;});
if (iter == erange.second) if (iter == erange.second)
_last_idx = 0; _edge_index_range = 0;
else else
_last_idx = iter->idx + 1; _edge_index_range = iter->idx + 1;
auto iter_idx = std::remove_if(_free_indexes.begin(), auto iter_idx = std::remove_if(_free_indexes.begin(),
_free_indexes.end(), _free_indexes.end(),
[&](auto idx) -> bool [&](auto idx) -> bool
{return idx > _last_idx;}); {return idx > _edge_index_range;});
_free_indexes.erase(iter_idx, _free_indexes.end()); _free_indexes.erase(iter_idx, _free_indexes.end());
_free_indexes.shrink_to_fit(); _free_indexes.shrink_to_fit();
if (_keep_epos) if (_keep_epos)
_epos.resize(_last_idx); _epos.resize(_edge_index_range);
_epos.shrink_to_fit(); _epos.shrink_to_fit();
} }
...@@ -337,7 +337,7 @@ private: ...@@ -337,7 +337,7 @@ private:
vertex_list_t _out_edges; vertex_list_t _out_edges;
vertex_list_t _in_edges; vertex_list_t _in_edges;
size_t _n_edges; size_t _n_edges;
size_t _last_idx; size_t _edge_index_range;
std::deque<size_t> _free_indexes; // indexes of deleted edges to be used up std::deque<size_t> _free_indexes; // indexes of deleted edges to be used up
// for new edges to avoid very large // for new edges to avoid very large
// indexes, and unnecessary property map // indexes, and unnecessary property map
...@@ -347,7 +347,7 @@ private: ...@@ -347,7 +347,7 @@ private:
void rebuild_epos() void rebuild_epos()
{ {
_epos.resize(_last_idx); _epos.resize(_edge_index_range);
for (size_t i = 0; i < _out_edges.size(); ++i) for (size_t i = 0; i < _out_edges.size(); ++i)
{ {
auto& oes = _out_edges[i]; auto& oes = _out_edges[i];
...@@ -771,7 +771,7 @@ add_edge(Vertex s, Vertex t, adj_list<Vertex>& g) ...@@ -771,7 +771,7 @@ add_edge(Vertex s, Vertex t, adj_list<Vertex>& g)
Vertex idx; Vertex idx;
if (g._free_indexes.empty()) if (g._free_indexes.empty())
{ {
idx = g._last_idx++; idx = g._edge_index_range++;
} }
else else
{ {
......
...@@ -470,7 +470,7 @@ BOOST_PYTHON_MODULE(libgraph_tool_core) ...@@ -470,7 +470,7 @@ BOOST_PYTHON_MODULE(libgraph_tool_core)
.def("clear_edges", &GraphInterface::clear_edges) .def("clear_edges", &GraphInterface::clear_edges)
.def("get_vertex_index", &GraphInterface::get_vertex_index) .def("get_vertex_index", &GraphInterface::get_vertex_index)
.def("get_edge_index", &GraphInterface::get_edge_index) .def("get_edge_index", &GraphInterface::get_edge_index)
.def("get_max_edge_index", &GraphInterface::get_max_edge_index) .def("get_edge_index_range", &GraphInterface::get_edge_index_range)
.def("re_index_edges", &GraphInterface::re_index_edges) .def("re_index_edges", &GraphInterface::re_index_edges)
.def("shrink_to_fit", &GraphInterface::shrink_to_fit) .def("shrink_to_fit", &GraphInterface::shrink_to_fit)
.def("get_graph_index", &GraphInterface::get_graph_index) .def("get_graph_index", &GraphInterface::get_graph_index)
......
...@@ -279,7 +279,7 @@ GraphInterface::GraphInterface(const GraphInterface& gi, bool keep_ref, ...@@ -279,7 +279,7 @@ GraphInterface::GraphInterface(const GraphInterface& gi, bool keep_ref,
boost::any avorder = python::extract<boost::any>(vorder)(); boost::any avorder = python::extract<boost::any>(vorder)();
run_action<>() run_action<>()
(const_cast<GraphInterface&>(gi), (const_cast<GraphInterface&>(gi),
std::bind(do_graph_copy(gi._mg->get_last_index()), std::bind(do_graph_copy(gi._mg->get_edge_index_range()),
std::placeholders::_1, std::ref(*_mg), std::placeholders::_1, std::ref(*_mg),
gi._vertex_index, _vertex_index, gi._edge_index, gi._vertex_index, _vertex_index, gi._edge_index,
_edge_index, std::placeholders::_2, std::ref(vprops), _edge_index, std::placeholders::_2, std::ref(vprops),
......
...@@ -151,7 +151,7 @@ boost::any GraphInterface::get_graph_view() const ...@@ -151,7 +151,7 @@ boost::any GraphInterface::get_graph_view() const
{ {
boost::any graph =