E
E
Ernesto Guevara2015-03-28 13:07:43
Algorithms
Ernesto Guevara, 2015-03-28 13:07:43

How to reduce the number of arcs in a digraph while maintaining the "degree" of the vertices?

Let us introduce the notion of the "degree" of a vertex d(x) of a directed graph as the difference between the outdegree and the indegree. In simple words: d(x) = sum_of_weights_of_outgoing_arcs - sum_of_weights_of_incoming_arcs
It turns out that the sum of "degrees" of all vertices is equal to zero.
a5603b447b3c4c74a165166c4a83b462.jpg
Task: based on the given graph, build a new graph with the same set of vertices with the same d(x) , but with the minimum number of arcs and with the minimum possible weights of these arcs. You can build a disconnected graph.
Example:
d6283b257ad74306ae063e60d0338e57.jpg
I have studied discrete mathematics for a relatively long time and have already forgotten a lot. This problem came up in my project. I couldn’t solve it myself right away, but I can’t find something similar, but I have a feeling that this is some kind of classic task. I apologize if I did not use the established terminology.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
E
Ernesto Guevara, 2015-03-28
@guevara

It seems I have found the answer to the question. There is a similar problem here:
stackoverflow.com/questions/15723165/algorithm-to-...
The answers give a post about this problem, which seems to be NP-complete. I will study.

M
mamkaololosha, 2015-03-28
@mamkaololosha

1) Build a minimum spanning tree, ignoring weights
en.wikipedia.org/wiki/Minimum_spanning_tree
2) Put weights

M
Mrrl, 2015-03-28
@Mrl

The easiest way is to find an arbitrary cycle, in which there is an edge of the least weight, and subtract this weight from all edges. Continue until there are no cycles left. But the result can be very suboptimal.
You can search for a cycle in which the smallest weight of an edge is maximum (add edges starting from the heaviest until a cycle appears in the graph). Then the result should be noticeably better (by the sum of the weights). But the number of edges may not be minimal.
By the way, is it possible to increase the weights of the arcs (from the graph (1,2,w=1), (2,3,w=2), (1,3,w=4) to get (2,3,w=1), (1,3,w=5))? If yes, then after the cycles in the directed graph are over, you will have to look for cycles in the undirected graph, and add to all edges the least edge weight in absolute value, taking into account the direction of the edges (subtract from passing and add to counter).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question