On the graph, how to find the nearest node for a group of nodes?

I have an undirected, unweighted graph that doesn't have to be flat. I also have a subset of graph nodes (a true subset), and I need to find a node that does not belong to the subset, with a minimum sum of distances to all nodes in the subset.

So far I have implemented a search in the first place, starting with each node in the subset, and the first intersection is the node I'm looking for. Unfortunately, it works too slowly because the graph contains a large number of nodes.

+3
source share
1 answer

O (V ^ 3), . Floyd-warshall. , , . , , , , .

+1

Source: https://habr.com/ru/post/1746384/


All Articles