5

Given a graph with N nodes (thousands), I need to find K nodes so that the average path length between each pair (K1,K2) of K is maximized. So basically, I want to place them as far away as possible from eachother.

Which algorithm would I use for this / how could I program this without having to try out several single combination of K?

Also as an extension: if I now have N nodes and I need to place 2 groups of nodes K and L in the graph such that the average path length between each pair (L,K) is maximized, how would I do this?

My current attempt is to just do a couple of random placements and then calculate the average path length between the pairs of both K and L, but this calculation is starting to take a lot of time so I'd rather not spend that much time on just evaluating randomly chosen combinations. I'd rather spend time once on getting the REAL most spread combination.

Are there any algorithms out there for this?

user134589
  • 2,499
  • 2
  • 16
  • 12
  • I'm voting to close this question as off-topic because this is a question on a mathematical/geometrical algorithm, and should be on the mathematics forum – ControlAltDel Apr 23 '15 at 11:44
  • would that just be different tags or is there a different section of this website I'm not familiar with? – user134589 Apr 23 '15 at 11:47
  • http://math.stackexchange.com/ for math questions. Question is though if you have an algorithm you are unsure on how to implement or if you want to understand what algorithm can solve this? – Asthor Apr 23 '15 at 12:27
  • 4
    This is a question about an algorithm, which is not really the focus of the Mathematics SE. There is a computer science SE, which would be a good fit, but it's just fine here. The `algorithm` tag has over 50,000 questions. – j_random_hacker Apr 23 '15 at 12:33
  • Maybe you can adapt the spring algorithm that is being used to lay out graphs on a Euclidean plane. – biziclop Apr 23 '15 at 12:43
  • 2
    @j_random_hacker I agree, I don't like the (recent?) tendency that any question deeper than "which button I press to get pellet?" is voted as off-topic and suitable for maths boffins only. – biziclop Apr 23 '15 at 12:45
  • 2
    @biziclop It's not recent, but it did get a lot worse when the CS exchange started lobbying to make algorithm questions here off-topic. – David Eisenstat Apr 23 '15 at 12:49
  • In explaining my vote, I didn't downclick this question, I merely suggested that you might find better answers on another forum that was more closely aligned with your question. If you're happy with the NP-hard answer, then good. But I'd suggest there might be other solutions that folks here are not aware of. – ControlAltDel Apr 23 '15 at 13:15

1 Answers1

5

The bad news is that this problem is NP-hard, by a reduction from Independent Set. (Assume unit weights. Add a new vertex connected to all other vertices; then we're looking for a collection of K that have average distance 2.)

If you're determined to get an exact solution (and I'm not sure that you shouldn't be), then I'd try branch and bound, using node is/is not one of the K as the branching decision and a crude bound (given a subset of K, find the two nodes that maximize the appropriate combination of the distance between them and the distance to the subset, then set the bound to the appropriate weighted average incorporating the known inter-node distances).

If the exact algorithm above chokes on thousand-node graphs as Evgeny fears it will, then use a farthest-point clustering (link goes to the Wikipedia page on Facility Location, which describes FPC) to cut the graph to a manageable size, incurring a hopefully small approximation error.

David Eisenstat
  • 64,237
  • 7
  • 60
  • 120