1
$\begingroup$

I have an undirected grid graph, nxm, where each vertex has a value (positive or negative) and I need to find the tree rooted at vertex (1,1) that maximizes the sum of these values with a minimal number vertices.

The tree do not have to go through all nodes, although the tree can pick a negative vertex so it can pick a positive one.

Edges have no value.

I will appreciate any advice.

$\endgroup$
12
  • $\begingroup$ What do you mean by "spanning" here? Clearly, the standard meaning makes your question nonsensical... $\endgroup$
    – fedja
    Commented Apr 18, 2018 at 3:55
  • $\begingroup$ I think that a simple reformulation could make the question interesting albeit not very hard to answer: ask for finding the connected subgraph with maximal sum of vertex weights and minimal number of vertices. $\endgroup$ Commented Apr 18, 2018 at 4:14
  • $\begingroup$ @fedja something like this en.m.wikipedia.org/wiki/Spanning_tree $\endgroup$
    – Sghat
    Commented Apr 18, 2018 at 9:15
  • $\begingroup$ @ManfredWeis Thanks. I will think about it. But I was trying to make it clear that I can not have subtours. $\endgroup$
    – Sghat
    Commented Apr 18, 2018 at 9:20
  • $\begingroup$ Once the minimal connected component with maximal sum of vertex weight is found, you can construct a spanning tree of that component; the sum of weights will not change because the set of vertices is the same. $\endgroup$ Commented Apr 18, 2018 at 10:54

1 Answer 1

0
$\begingroup$

The optimal solution can be found as follows:

  • repeatedly delete from the vertices with negative weight the one, that has minimal weight and whose removal doesn't disconnect the graph, i.e. that isn't an articulation vertex.
  • replace each connected component of the subgraph induced by edges, that are ajacent to two vertices with positive weight, by a single vertex and assign to it the sum of all vertex weights in that component.
  • replace the paths between two vertices with positive weight by an edge, whose weight equals the sum of negative vertex weights on that path.
  • in the resulting tree-graph define the vertex that "contains" $(1,1)$ as the root
  • start a depth-first search from the root node:

    • after returning from descending into each of the children of a vertex $v$, either

      • add the sum of the weights $\omega(v)$ and $\omega(e)$ of $v$ and of the edge $e$ adjacent to $v$ and to $v$'s father-vertex $u$ if $\omega(v)+\omega(e)\gt 0$, i.e $\ \omega(u)=\omega(u)+\omega(e)+\omega(v)$ in that case

      • otherwise add nothing to the father-node weight and mark $e$ and $v$ as deleted

  • finally replace the tree-nodes and edges that aren't marked as deleted, by the corresponding vertices and edges of the original graph to obtain the optimal solution.
$\endgroup$
2
  • $\begingroup$ You could have not helped more. Thank you again. I also share a Java solver that I found: arxiv.org/abs/1605.02168 github.com/ctlab/gmwcs-solver $\endgroup$
    – Sghat
    Commented Apr 24, 2018 at 1:43
  • $\begingroup$ @Sghat I am happy to hear that could help you; it was a nice problem I enjoyed. $\endgroup$ Commented Apr 24, 2018 at 4:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .