A
A
artshelom2018-11-18 13:54:42
Algorithms
artshelom, 2018-11-18 13:54:42

How to balance graphs?

I have an undirected cyclic graph. For which I only know the difference between the heights of the edges, but it turns out that the sum is not equal to 0.
Are there ready-made libraries for equalizing in c # or how to write an algorithm if there are a lot of cycles in one graph?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
W
Wataru, 2018-11-19
@artshelom

I understand that the edges set the difference between the "heights" of the vertices. "it turns out that the sum is not equal to 0" means that there are no conflicts and you can assign some heights to the vertices so that all edges are correct. Did I understand the condition correctly?
Then the problem is solved by a simple traversal in depth or in breadth, as you like. Just fix one vertex at height 0, and going through all the edges, fix the heights of all other vertices. If the edge already leads to a fixed vertex, then you can check that the height remains the same, but in any case, the traversal no longer enters this vertex.
Finally, if you want all vertices to have a non-negative height, for example, find the vertex with the minimum height, and if it's negative, subtract it from the heights of all vertices.
The traversal must be called in a loop so that the entire graph can be traversed, even if it is disconnected.

V
Vladimir Olohtonov, 2018-11-19
@sgjurano

And why do you need to reduce the sum of the edges of the graph to zero? And what is "rib height"?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question