atofigh / edmonds-alg

Implementation of maximum branching algorithm (max spanning tree in directed graphs)
MIT License
25 stars 4 forks source link

How to specify roots? #5

Open TryerGit opened 3 years ago

TryerGit commented 3 years ago

Hello,

The example provided at

https://github.com/atofigh/edmonds-alg/blob/master/doc/examples/sparse-example.cpp

calls the algorithm thus:

edmonds_optimum_branching<true, false, false>(G,
                                                  vertex_indices,
                                                  weights,
                                                  static_cast<Vertex *>(0), //Is this conversion to an empty iterator  ?
                                                  static_cast<Vertex *>(0),// or is this conversion to an iterator pointing to vertex 0, the first node?
                                                  std::back_inserter(branching));

If I understand correctly, roots_begin and roots_end are both NULL (?) and hence the problem is solved with no prespecified roots.

What would change suppose I have a graph with 50 vertices, and I want vertex 5 to serve as the root node?

Should the two arguments be:

edmonds_optimum_branching<true, false, false>(G,
                                                  vertex_indices,
                                                  weights,
                                                 static_cast<Vertex *>(5),
                                                  static_cast<Vertex *>(6)
                                                  std::back_inserter(branching));

This, however, shows a compile time error over the static_cast as an invalid type conversion of an int.

Should the two argument just be:

edmonds_optimum_branching<true, false, false>(G,
                                                  vertex_indices,
                                                  weights,
                                                 5,
                                                  6
                                                  std::back_inserter(branching));

This, however, does not compile either with the error:

../include/edmonds_optimum_branching_impl.hpp:247:41: error: invalid type argument of unary ‘*’ (have ‘int’)
  247 |                 is_specified_root[index[*roots_begin]] = true;

Any guidance is appreciated. Thanks.