To recap, we are considering the question of whether the minor key theme in Mahler's Sixth Symphony, Andante Moderato movement, is similar to the subsequent composition of either or both of the two melodic themes in Rodrigo's Concierto de Aranjuez, Adagio (the second movement in this work), so similar as to support a hypothesis that Rodrigo unconsciously relied on Mahler's 1903 phrase in his 1939 composition.
Can an average listener hear so much similarity as to suggest these segments reflect copying of some kind? Stripping the compositions under consideration down to just the bare primary melody sequences and transposing Rodrigo from D/Bm to Eb/Cm to facilitate comparison with Mahler's theme in the same key (and adjusting the timing to put them in about the same rhythm) we can display the musical score and highlight the notes as they are sounded in the following videos. In the first YouTube video we present the minor theme from Mahler's Sixth (“MAH”) followed by Rodrigo's first theme (“ROD-I”), followed by Mahler again as it seems most people immediately want a second hearing:
MAH V ROD-I youtube comparison
In the second video we present the same minor theme from Mahler's Sixth (“MAH”) followed by Rodrigo's second theme (“ROD-II”), followed by Mahler again:
MAH V ROD-II youtube comparison
Many people will probably hear some similarity in these segments, musically and in the emotion they invoke, but can we make a more objective comparison? For cases of outright replication of one song by another it is enough to present them in the fashion above (or running concurrently, when there is literal copying), but this is not the case here.
As a first step in a more technical analysis, it might be useful to examine the way the two composers developed their melodies, i.e., did the notes leap large pitch distances between successive notes, did they use similar transitions, etc. In music theory you will be familiar with the distance between two successive pitches (notes) as intervals in the diatonic scale and they will be defined by the number of semitones in the step. I assume the reader has a basic education in music theory, but if not (or if you want to check definitions, I found the 1914 textbook by Gehrkens to be an excellent resource; freely available at Project Gutenberg) Gehrkens Music Notation and Terminology
I used Matplotlib, an open source Python-based plotting library widely used in the scientific computing community (see the interesting article by the creators of Matplotlib at article by the creators of Matplotlib
to create a stacked histogram (a bar chart) with bins equal to the intervals appearing in the melodies under examination and the frequencies the number of occurrences of that particular interval, e.g., -3 semitones on the x-axis is a falling minor 3rd interval. The three melody sequences are color coded and the respective frequency of occurrence in their melodies is stacked (so the length of a particular color segment within a histogram bar indicates the number of occurrences of that interval in the melody coded with that color):

Looking at that stacked histogram of the frequency of occurrence of ascending and descending melodic intervals in MAH and ROD-I and ROD-II it appears that if you discard the repetitive notes (the “0” bin which indicates repeated notes, which are used only by Rodrigo) there is a close correspondence between Mahler and Rodrigo, closer perhaps between Mahler and ROD-II where they each have added a unique outlier, otherwise making similar use of interval motion.
But interval motion presented in a histogram doesn't give a gestalt impression of the actual flow of the melody, so let us look at a contour graph, a line plot of the actual notes of these melody segments as they appear one after another in time. This can be done by hand, sketching up and down line segments above the musical score to show the rough contour of the melody, but I will instead use Matplotlib again.
Here is the line plot of MAH, which gives you an idea of the shape of the melody, the types of changes in slope sign (up or down movement of the notes) and whether the notes leap or make step-wise movement to the next note:
you can see more or less a descent of the melody in several groups to the terminating note. This helps me somewhat to understand the emotion associated with this segment (the affect), somewhat of a continuing descending lament, being notes from the melodic minor scale. The sequence begins on the dominant and briefly touches the tonic once before sinking in melancholy musing to the dominant again, leaving an unsettled feeling (of not resolving to the tonic). Mahler (I note that I have only studied Mahler's Andante of the Sixth, the Adagietto of the Fifth and the First movement of his unfinished Tenth) seems often to communicate through his music that we savor the peaks in human existence only to the extent we must climb from the dark valleys and that there eventually will come to us all a time when we are unable to make the ascent again.
Looking at ROD-I:
and ROD-II:
We immediately find the same pattern of stepped descent we saw in the Mahler segment, perhaps more so in ROD-II. Rodrigo stays within the Primitive/Aeolian minor scale, not using the natural on the sixth that Mahler adds (Mahler freely using this feature of the melodic minor scale on ascent and descent and otherwise mixes from the primitive/aeolian scale). However, this does not distinguish the emotional effect of the segments appreciably to my hearing. Unlike Mahler, Rodrigo closes his descending melancholy introspection on the tonic, providing somewhat more of a termination to the feeling (one still has the impression that there was some resistance to that final descent though).
I wondered what another theme in a minor key might look like in comparison to these three, i.e., is this a relatively distinctive shape (the continued descent), so I graphed the basic theme of Mozart's Requiem Aeternam (transposed to Eb/Cm): 
Quite a difference in shape! Mozart's theme climbs in sad majesty as befitting one leaving this life and ascending to eternity.
One could examine the relationship of notes of a melody with the accompanying chords, i.e., harmonic analysis, but I don't believe that is necessary in the present context. Mahler's and Rodrigo's themes here seem to suggest harmony to me rather than to acquire essential character from it (an opinion I arrived at after doing this work).
There has been an ongoing effort for some years now, driven in large part by the business of content-based music retrieval (or the possibilities of that capability), to define similarity measures between pieces of music. A simple approach to computing melodic similarity might be to represent the melodic profile of pieces using three classes of pitch intervals, i.e., ascending, descending, and same, much as we did earlier by constructing a histogram based on this data structure.
More complex representations may use finer quantization of the intervals, add analysis of the relationship of harmony (melody note relation to accompanying chord) and metric weight (position and duration of the note in the sequence). Software implementing melodic similarity analysis may use a sliding window, looking for the best match between successive portions of one melody while holding the query segment constant, aligning elements of one sequence with an element of another (or with a gap). [see A Measure Of Melodic Similarity Based On A Graph
Representation Of The Music Structure; Orio and Roda 2009 ] The implication/realization model looks at three note sequences constituting two intervals, categorizing experimentally determined expectations by listeners on how the melody will continue. Once categorized as sequential data, general methods for comparing sequential data, e.g., edit distance, can be used to evaluate similarity of one sequence with another. [see Melody Retrieval using the Implication/Realization Model; Grachten, Arcos and Mantaras].
The Répertoire International des Sources Musicales or RISM maintains a comprehensive database of music, including a music incipit search, which makes it possible to search (using melodic similarity software) a database of about one million incipits for works that are musically similar, based on the progression of the beginning notes of a composition (the note names can be typed or entered with an onscreen piano keyboard). These seem to be primarily works prior to 1800, however, this is still a valuable database for testing melody similarity software, among other purposes. I found the online search provided by Ultrecht University at Online RISM incipit search
to be more useful as a hook into the RISM incipits. With that facility I found incipits by Domenico Gallo "Dixit Dominus" (18th century) that were considered to be most similar to Rodrigo in part and Antonio Cesti "Bella Clori" (17th century) most similar to a portion of Mahler (keep in mind that this simply means for the million or so incipits, the returned segments had the highest computed similarity scores, i.e., it doesn't mean that they matched exactly the query, but I could hear brief similarity of significance).
I thought it might be interesting to use melody similarity software, MelodyShape, developed by Julian Urbano [available atUrbano MelodyShape program
using algorithms he achieved best results with in the MIREX Symbolic Melodic Similarity task competition 2010 – 2015, to run some comparisons on the Mahler and Rodrigo segments, as well as incidental pieces for comparison.
Urbano's MelodyShape Java software accepts MIDI files for comparison and “transforms note trigrams to a series of B-spline interpolations, which are curves fitted to the contours of the note trigrams. The resulting series of B-splines of two melodies are then compared through alignment,” quoting from A Comparison Of Symbolic Similarity Measures For Finding Occurrences Of Melodic Segments; Janssen et al, 16th International Society for Music Information Retrieval Conference 2015. In other words, MelodyShape does something similar to what we did earlier in plotting lines connecting the notes of the melodies in order to get a feel for the shape of the resulting contour. Each group of three notes in succession has a smooth curve calculated to connect them; that mathematical function is then a “spline” defined for that section. Another spline is calculated for the next group of three notes, designed to connect smoothly with the previous spline also. In this way a piecewise smooth numerical characterization of the shape of each melody segment is obtained and then compared in successive alignment to find the areas where the shape matches in the two melodies under comparison. Good matches should return a high value, bad matches a low, possibly negative value.
Running MelodyShape (installed locally on my computer) with Mahler as the query I obtained the following results:
Mahler compared to itself: 6.55140000
compared to Antonio Cesti "Bella Clori" (17th century): 3.54120893
compared to Domenico Gallo "Dixit Dominus" (18th century) -0.14140608
compared to Rodrigo's second theme: -0.16697577
compared to Rodrigo's first theme: -0.16697577
Running MelodyShape with Rodrigo's first theme as the query gave:
compared to itself: 6.55140000
compared to Rodrigo's second theme: 0.34103238
compared to Domenico Gallo "Dixit Dominus" (18th century): 0.17138156
compared to Mahler theme: -0.16697577
compared to Antonio Cesti "Bella Clori" (17th century): -0.38888889
Running MelodyShape with Mozart's Requiem Aeternum theme as the query:
compared to Antonio Cesti "Bella Clori" (17th century): 0.87988889
compared to Mahler theme: 0.23808437
compared to Domenico Gallo "Dixit Dominus" (18th century): -0.02564103
compared to Rodrigo's second theme: -0.04861111
compared to Rodrigo's first theme: -0.04861111
MelodyShape rightly suggests Rodrigo's themes I and II are somewhat similar, agrees with the RISM incipits similarity (Dixit Dominus somewhat similar to Rodrigo themes; Bella Clori very similar to Mahler's theme), suggests Mahler is not very similar to either Rodrigo theme, and Mozart is not similar to any of them.
My work here suggests that we may not conclude that Rodrigo unconsciously (or otherwise) used Mahler's phrase in the composition of his own work, though we see technical reasons why these three melodic segments feel similar, e.g., melody shape/contour, use of same melodic interval motion. It is only possible that Rodrigo had Mahler's work in his mind on the level of musical memory (whatever level that is), a tantalizing hint being Rodrigo's long silence on where he got his inspiration for the Adagio, finally commenting that he heard a voice singing it inside him.