Reputation: 11
I have adjacency matrix,I don't know the location of the points only I know the adjacency matrix and distance between neighbors are equal.
so how I get the distance between points??:
is there any algorithm do that
Upvotes: 0
Views: 1638
Reputation: 16821
so how I get the distance between points??
In general, you can't, assuming you're using Euclidean distance as tagged. With the information you have given, you can't come up with a unique layout (embedding) of the graph.
As a small counter-example, take the adjacency matrix:
[0 1 1]
[1 0 0]
[1 0 0]
Vertex 1 is connected to Vertex 2 and Vertex 3 forming an angle. The angle between segments (1,2) and (1,3) can be anything we want from 0 ° to 180° making the distance between Vertices 2 and 3 between 0 and 2 units.
To come up with anything reasonable you'll have to impose some sort of layout on the graph first.
Upvotes: 1
Reputation: 29099
Since the adjacency matrix represents a graph, you need to traverse the graph to find the possible paths. You can do that using breadth-first search, since the graph is not weighted. keep in mind that the distance between some points might be infinite, since there might not be a path from one to another
Upvotes: 0