Is there an algorithm that gives me coordinates of vertices in a graph, when I give him a weighted graph and the edge weights between vertices points to the distance between vertices?
Something like:
public _ArrayOfCoordinatesForVertices_ **super_hyper_algorithm**(weighted_graph){
return _foo_;
}
This is in general not possible: Imagine a graph with 3 nodes n1, n2, and n3.
now consider the following distances:
n1-n2: 4
n1-n3: 1
n2-n3: 1
(This violates the triangle inquality).
What you are referring to is called Multidimensional scaling (MDS) and you should find plenty of implementations now you know how to search for it.
Like others said, to some extent, it is impossible to draw a perfect graph without violating some of your constraints (the distances between points). MDS algorithms are specifically targeted at minimizing such violations.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With