0

Take this node weighted graph for example :

https://i.stack.imgur.com/DEYJD.png

  • The maximum subgraph containing exactly 1 node (and the 'entry point') would be 14.
  • The maximum subgraph containing exactly 2 nodes (and the 'entry point') would be 14 / 9.
  • The maximum subgraph containing exactly 3 nodes (and the 'entry point') would be 3 / 19 / 15.
  • The maximum subgraph containing exactly 4 nodes (and the 'entry point') would be 14 / 1 / 7 / 240.

I can't manage to think of a better method than a bruteforce to get the maximum subgraph.
And if there is no known efficient algorithm, would a genetic algorithm be find in that case (the crossovers seem tricky) ?

Linus Caldwell
  • 10,908
  • 12
  • 46
  • 58

1 Answers1

0

I think you can modify Dijkstra's algorithm to solve this problem.

With Dijkstra's algorithm, you are solving the shortest path. Just change that to find the maximum path. To restrict it to only 1, 2, 3 nodes in a graph, keep track of the number of nodes it takes to get to each node when you "visit it". Stop when there are no other nodes with a count less than the number of nodes you are looking for.

Johnny Z
  • 14,329
  • 4
  • 28
  • 35
  • 1
    Since it's not a path but a subgraph, I don't see how could a modified Dijkrasta be possible. For a 4 nodes subgraph for example the solution could be the points 14 / 1 / 15 / 7. Am I missing something ? – Joran Bigalet Nov 26 '13 at 03:10