Is there a built in Mathematica function I can use to compare unequally dimensioned lists?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
3
down vote

favorite












This is a higher level question, and I don't expect a full answer, but maybe a nudge in the right direction would help, or maybe there is a built in Mathematica function that does something very similar to this already.



I have a list A of lists. The lists in A are of different length, and can even have different levels. One example of these is, using TreeForm:
enter image description here



Another example would be:
enter image description here



So there are obviously a lot of differences between them.



I have written a function which extracts the elements at each level, so that I can then compare the lists level by level. However, I wonder - is there a built in function in Mathematica that does something similar to this, and generates a number representing how far apart they are? I have looked, but not found anything yet that works on lists of different dimensions.



Or even, could there be a way to convert these to graphs, and then, maybe there would be a built in function that compares the similarity of graphs?



Any hints on the best way to find the similarity between any two of the lists in list A would be very appreciated! Again, I don't expect any hand-outs, but a point in the right direction would be great!



Thanks!










share|improve this question

























    up vote
    3
    down vote

    favorite












    This is a higher level question, and I don't expect a full answer, but maybe a nudge in the right direction would help, or maybe there is a built in Mathematica function that does something very similar to this already.



    I have a list A of lists. The lists in A are of different length, and can even have different levels. One example of these is, using TreeForm:
    enter image description here



    Another example would be:
    enter image description here



    So there are obviously a lot of differences between them.



    I have written a function which extracts the elements at each level, so that I can then compare the lists level by level. However, I wonder - is there a built in function in Mathematica that does something similar to this, and generates a number representing how far apart they are? I have looked, but not found anything yet that works on lists of different dimensions.



    Or even, could there be a way to convert these to graphs, and then, maybe there would be a built in function that compares the similarity of graphs?



    Any hints on the best way to find the similarity between any two of the lists in list A would be very appreciated! Again, I don't expect any hand-outs, but a point in the right direction would be great!



    Thanks!










    share|improve this question























      up vote
      3
      down vote

      favorite









      up vote
      3
      down vote

      favorite











      This is a higher level question, and I don't expect a full answer, but maybe a nudge in the right direction would help, or maybe there is a built in Mathematica function that does something very similar to this already.



      I have a list A of lists. The lists in A are of different length, and can even have different levels. One example of these is, using TreeForm:
      enter image description here



      Another example would be:
      enter image description here



      So there are obviously a lot of differences between them.



      I have written a function which extracts the elements at each level, so that I can then compare the lists level by level. However, I wonder - is there a built in function in Mathematica that does something similar to this, and generates a number representing how far apart they are? I have looked, but not found anything yet that works on lists of different dimensions.



      Or even, could there be a way to convert these to graphs, and then, maybe there would be a built in function that compares the similarity of graphs?



      Any hints on the best way to find the similarity between any two of the lists in list A would be very appreciated! Again, I don't expect any hand-outs, but a point in the right direction would be great!



      Thanks!










      share|improve this question













      This is a higher level question, and I don't expect a full answer, but maybe a nudge in the right direction would help, or maybe there is a built in Mathematica function that does something very similar to this already.



      I have a list A of lists. The lists in A are of different length, and can even have different levels. One example of these is, using TreeForm:
      enter image description here



      Another example would be:
      enter image description here



      So there are obviously a lot of differences between them.



      I have written a function which extracts the elements at each level, so that I can then compare the lists level by level. However, I wonder - is there a built in function in Mathematica that does something similar to this, and generates a number representing how far apart they are? I have looked, but not found anything yet that works on lists of different dimensions.



      Or even, could there be a way to convert these to graphs, and then, maybe there would be a built in function that compares the similarity of graphs?



      Any hints on the best way to find the similarity between any two of the lists in list A would be very appreciated! Again, I don't expect any hand-outs, but a point in the right direction would be great!



      Thanks!







      list-manipulation function-comparison distance nearest






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 3 hours ago









      Jmeeks29ig

      48428




      48428




















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          3
          down vote



          accepted










          One approach is with Level. If your expression is called struct,



          Level[struct, 0, Infinity]


          or perhaps



          Level[struct, 0, Infinity, Heads -> True]


          or even



          Level[struct, #] & /@ Range[Depth[struct]]


          You can also pick individual levels at will. As for measuring how far apart the levels are, you could do something as simple as length, or some function of length and depth. Crudely, this might be similar to



          LeafCount[struct]





          share|improve this answer






















          • Great, thanks, I will give that a go!
            – Jmeeks29ig
            6 mins ago

















          up vote
          1
          down vote













          There's no unique measure, so I would use GraphPropertyDistribution on as many graph properties as you can imagine.






          share|improve this answer




















          • Alright, thanks, I'll look into that!
            – Jmeeks29ig
            5 mins ago










          Your Answer




          StackExchange.ifUsing("editor", function ()
          return StackExchange.using("mathjaxEditing", function ()
          StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
          StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
          );
          );
          , "mathjax-editing");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "387"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f182274%2fis-there-a-built-in-mathematica-function-i-can-use-to-compare-unequally-dimensio%23new-answer', 'question_page');

          );

          Post as a guest






























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          3
          down vote



          accepted










          One approach is with Level. If your expression is called struct,



          Level[struct, 0, Infinity]


          or perhaps



          Level[struct, 0, Infinity, Heads -> True]


          or even



          Level[struct, #] & /@ Range[Depth[struct]]


          You can also pick individual levels at will. As for measuring how far apart the levels are, you could do something as simple as length, or some function of length and depth. Crudely, this might be similar to



          LeafCount[struct]





          share|improve this answer






















          • Great, thanks, I will give that a go!
            – Jmeeks29ig
            6 mins ago














          up vote
          3
          down vote



          accepted










          One approach is with Level. If your expression is called struct,



          Level[struct, 0, Infinity]


          or perhaps



          Level[struct, 0, Infinity, Heads -> True]


          or even



          Level[struct, #] & /@ Range[Depth[struct]]


          You can also pick individual levels at will. As for measuring how far apart the levels are, you could do something as simple as length, or some function of length and depth. Crudely, this might be similar to



          LeafCount[struct]





          share|improve this answer






















          • Great, thanks, I will give that a go!
            – Jmeeks29ig
            6 mins ago












          up vote
          3
          down vote



          accepted







          up vote
          3
          down vote



          accepted






          One approach is with Level. If your expression is called struct,



          Level[struct, 0, Infinity]


          or perhaps



          Level[struct, 0, Infinity, Heads -> True]


          or even



          Level[struct, #] & /@ Range[Depth[struct]]


          You can also pick individual levels at will. As for measuring how far apart the levels are, you could do something as simple as length, or some function of length and depth. Crudely, this might be similar to



          LeafCount[struct]





          share|improve this answer














          One approach is with Level. If your expression is called struct,



          Level[struct, 0, Infinity]


          or perhaps



          Level[struct, 0, Infinity, Heads -> True]


          or even



          Level[struct, #] & /@ Range[Depth[struct]]


          You can also pick individual levels at will. As for measuring how far apart the levels are, you could do something as simple as length, or some function of length and depth. Crudely, this might be similar to



          LeafCount[struct]






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 58 mins ago

























          answered 2 hours ago









          bill s

          51.1k373145




          51.1k373145











          • Great, thanks, I will give that a go!
            – Jmeeks29ig
            6 mins ago
















          • Great, thanks, I will give that a go!
            – Jmeeks29ig
            6 mins ago















          Great, thanks, I will give that a go!
          – Jmeeks29ig
          6 mins ago




          Great, thanks, I will give that a go!
          – Jmeeks29ig
          6 mins ago










          up vote
          1
          down vote













          There's no unique measure, so I would use GraphPropertyDistribution on as many graph properties as you can imagine.






          share|improve this answer




















          • Alright, thanks, I'll look into that!
            – Jmeeks29ig
            5 mins ago














          up vote
          1
          down vote













          There's no unique measure, so I would use GraphPropertyDistribution on as many graph properties as you can imagine.






          share|improve this answer




















          • Alright, thanks, I'll look into that!
            – Jmeeks29ig
            5 mins ago












          up vote
          1
          down vote










          up vote
          1
          down vote









          There's no unique measure, so I would use GraphPropertyDistribution on as many graph properties as you can imagine.






          share|improve this answer












          There's no unique measure, so I would use GraphPropertyDistribution on as many graph properties as you can imagine.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 1 hour ago









          David G. Stork

          21.5k11646




          21.5k11646











          • Alright, thanks, I'll look into that!
            – Jmeeks29ig
            5 mins ago
















          • Alright, thanks, I'll look into that!
            – Jmeeks29ig
            5 mins ago















          Alright, thanks, I'll look into that!
          – Jmeeks29ig
          5 mins ago




          Alright, thanks, I'll look into that!
          – Jmeeks29ig
          5 mins ago

















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f182274%2fis-there-a-built-in-mathematica-function-i-can-use-to-compare-unequally-dimensio%23new-answer', 'question_page');

          );

          Post as a guest













































































          Comments

          Popular posts from this blog

          Long meetings (6-7 hours a day): Being “babysat” by supervisor

          What does second last employer means? [closed]

          One-line joke