I have a dataset in the following format:
UID Lat Long LocID
u1 lt1 lg1 l1
u1 lt2 lg2 l2
u1 lt3 lg3 l3
u2 lt4 lg4 l4
u3 lt1 lg1 l1
u3 lt4 lg4 l4
From here I need to generate a LocID-LocID un-directed graph. For this I need a weighted matrix in the following format.
0 d(l1,l2) 0 0
d(l2,1) 0 d(l2,l3) d(l2,l4)
0 d(l3,l2) 0 0
d(l4,l1) d(l4,l2) 0 0
Since, user-u1 is present at locations l1, l2 and l3, hence i consider them as visible edges in the graph. And hence, there exists edge from l1 -> l2 and l2->l3. From the given example, there exists 4 edges.
l1 -> l2 ; l2->l3 [For user u1]
l2->l4 [For user u2]
l1 -> l4 [For user u3]
here weight of each edge between two LocID is computed from the given Latitude and Longitude information. Like, d(l1,l2) = distance between LocID-1 and LocID-1 = distance between (lt1,lg1) and (lt2,lg2)
Distance calculation can be done by using haversine formula. So, that is not a problem. I need to perform this task in matlab. Can anyone please help me.... thanks in advance....