Questions tagged [distance-matrix]

A distance matrix is a matrix containing the pairwise distances between the elements of a set. The "distance" may rely on the concept of metric.

The distance matrix for an N-elements set is a NxN matrix in which entry (i,j) contains the distance between items i and j.
The distance might be related to the concept of metric (e.g. Euclidean distance, Mahlanobis distance, and so on) but there are also non-metric distance matrices: an adjacency matrix is an example of such non-metric distance matrices.

174 questions
1
vote
1 answer

How to display route with native google maps on Ionic 3

I'm building a project in Ionic 3, I'm using the native maps plugin for Ionic, I can show the map and I can add a marker in a selected address, but I have not managed to show the recommended route on the map. HTML:
1
vote
1 answer

Calculating just a single row of dissimilarity/distance matrix

I have a data-frame with 30k rows and 10 features. I would like to calculate distance matrix like below; gower_dist <- daisy(data-frame, metric = "gower"), This function returns whole dissimilarity matrix. I want to get just the first row. (Just…
A. Bek
  • 21
  • 1
1
vote
1 answer

Converting adjacency matrix into distance matrix in python

I transformed the following edgelist: Source Target Weight A B 12 A C 14 A D 56 B C 17 B F 14 B G 10 To the following adjaceny matrix: {'A': {'B': {'weight': 12}, 'C': {'weight': 14}, …
palacinak
  • 81
  • 1
  • 1
  • 5
1
vote
1 answer

An algorithm to overcome the elements limit posed by the distance matrix API

Firstly, I've done a StackOverflow search so I know this is new. Kindly read on: So I have a string array of 9 places and need to find the distance of them from each other to input into an algorithm. I used Google's Distance matrix API and pass…
1
vote
2 answers

Getting around memory error problem in python lists or a more clever way in Numpy

I am trying to calculate a DTW distance matrix which will look into 150,000 time series each having between 13 to 24 observations - that is the produced distance matrix will be a list of the size of approximately (150,000 x 150,000)/2=…
RomRom
  • 302
  • 1
  • 11
1
vote
2 answers

How to generate Newick tree output from pairwise distance matrix

I would like to produce phylogenetic trees from genetic data. I have found a few tree-drawing packages in R and python that look great, e.g. ggtree in R. But these require data inputs that are already in a tree format e.g. Newick. I think most…
Will Hamilton
  • 357
  • 2
  • 17
1
vote
2 answers

Running a matrix algorithm on how many cores?

I am running a program called dnadist from PHYLIP (http://evolution.genetics.washington.edu/phylip/doc/dnadist.html). This creates a dna distance matrix from the number of sequences you input. Currently, I want to create a matrix from 14,778…
Gina
  • 71
  • 9
1
vote
1 answer

Google Maps Distance Matrix API gives impossibly short duration_in_traffic results and also the results are different than Google Maps

I am making a request to Google Maps Distance Matrix API to get duration_in_traffic data for today's afternoon between two points -Besiktas and Bosphorus Bridge- in Istanbul and I've set the departure time to be 17:00:00 at Mar 06 2018. It returns…
1
vote
1 answer

Find closest 8-connected chessboard distance between multiple pairs of points: shortest m-path

I am working on binary images in Python using OpenCV. I have two sets of points: PNodes and FNodes. I want to find the closest PNode to each of the FNodes (shortest m-path); closest in terms of 8-connected chessboard distance. In the example below,…
Saania
  • 625
  • 1
  • 6
  • 26
1
vote
2 answers

Finding shortest mean distances per index from a distance matrix in R

I'm helping to put together a spatial R lab for a third year class, and one of the tasks will be to identify a specific site that is located the closest (i.e. mean shortest distance) to a set of multiple other sites. I have a distance matrix dist_m…
1
vote
3 answers

Converting into an appropriate distance matrix (for TSP)

I currently have a matrix like this: [[2, 6, 8, 9, 8, 6, 3], [4, 8, 10, 10, 7, 5], [5, 6, 8, 8, 9], [4, 6, 7, 8], [3, 5, 9], [3, 6], [4]] such that the first array is distances from city 1 to 2,3,4,5,6,7,8 the second is distances from city 2 to…
Sid Jones
  • 55
  • 1
  • 1
  • 10
1
vote
1 answer

how cluster with similarity matrix and contain indexes?

I have a pandas dataframe like this, where each ID is an observation with variables attr1, attr2 and attr3: ID attr1 attr2 attr3 20 2 1 2 10 1 3 1 5 2 2 …
Lytics
  • 25
  • 4
1
vote
0 answers

How to find Google Map API usage programmatically?

I'm working on an Application, where I make use of the free version of the Distance Matrix API provided by Google Maps. I'm familiar with the usage limits of the same as well. Is there any method available to check the Google Map API usage…
1
vote
0 answers

More efficient way to compute squared distance in R

I am trying to write code (using R) that returns a matrix that contains the squared distance between all pairs of rows. Below is an implementation that I have written. It works as expected but can get very slow as the number of rows gets large. From…
1
vote
2 answers

Average xy points with conditional distance

I have xy coordinates of points and I want to make use distance for averaging points. My data is named qq and I obtain the distance matrix using dist function qq X Y 2 4237.5 4411.5 3 4326.5 4444.5 4 4382.0 4418.0 5 4204.0 4487.5 6…
Matias Andina
  • 4,029
  • 4
  • 26
  • 58