Ensuring edges of graph obey triangle inequality
I am generating graphs with edges being assigned random weights. How can I guarantee that the weights of edges obey the triangle inequality? I saw a similar question that has been asked but couldn't really follow the answer
Solution 1:
@Tau is right, there are a lot of ways to solve this problem.
- Assign random coordinates and take distances using any metric that satisfies the triangle inequality.
- Assign random weights, test whether the triangle inequality is satisfied, increase the weights of any edges that fail it.
- Assign random weights, test whether the triangle inequality is satisfied, redo if any edges fail it.
I can come up with more strategies as well. But the real question is why you are doing this, and whether there are any hidden requirements that make one solution better than another.