Why Does GraphPlot mislabel Vertices from a Graph?












5












$begingroup$


A very peculiar thing is happening when I wrap a Graph with GraphPlot. The picture below shows the correct vertex labeling. However, GraphPlot changes the vertex labeling! Am I misusing this function or is this something I should report to Wolfram? I'm running version 11.0.1.0.



Below is some code to reproduce the issue (but with a simpler graph).



{gph = Graph[{2 -> 1, 5 -> 0, 7 -> 6, 8 -> 7, 10 -> 8, 0 -> 2, 2 -> 3,
3 -> 4, 5 -> 10, 8 -> 9}, VertexLabels -> "Name"],
GraphPlot[gph, VertexLabeling -> True]}


Interestingly enough, using a built-in function (like KaryTree) yields expected results:



{KaryTree[15, VertexLabels -> "Name"], 
GraphPlot[KaryTree[15], VertexLabeling -> True]}


My work-around is using Graph and formatting it exactly how I want, but I would like to understand why the vertex labeling is incorrect!



enter image description here



enter image description here










share|improve this question









$endgroup$

















    5












    $begingroup$


    A very peculiar thing is happening when I wrap a Graph with GraphPlot. The picture below shows the correct vertex labeling. However, GraphPlot changes the vertex labeling! Am I misusing this function or is this something I should report to Wolfram? I'm running version 11.0.1.0.



    Below is some code to reproduce the issue (but with a simpler graph).



    {gph = Graph[{2 -> 1, 5 -> 0, 7 -> 6, 8 -> 7, 10 -> 8, 0 -> 2, 2 -> 3,
    3 -> 4, 5 -> 10, 8 -> 9}, VertexLabels -> "Name"],
    GraphPlot[gph, VertexLabeling -> True]}


    Interestingly enough, using a built-in function (like KaryTree) yields expected results:



    {KaryTree[15, VertexLabels -> "Name"], 
    GraphPlot[KaryTree[15], VertexLabeling -> True]}


    My work-around is using Graph and formatting it exactly how I want, but I would like to understand why the vertex labeling is incorrect!



    enter image description here



    enter image description here










    share|improve this question









    $endgroup$















      5












      5








      5


      1



      $begingroup$


      A very peculiar thing is happening when I wrap a Graph with GraphPlot. The picture below shows the correct vertex labeling. However, GraphPlot changes the vertex labeling! Am I misusing this function or is this something I should report to Wolfram? I'm running version 11.0.1.0.



      Below is some code to reproduce the issue (but with a simpler graph).



      {gph = Graph[{2 -> 1, 5 -> 0, 7 -> 6, 8 -> 7, 10 -> 8, 0 -> 2, 2 -> 3,
      3 -> 4, 5 -> 10, 8 -> 9}, VertexLabels -> "Name"],
      GraphPlot[gph, VertexLabeling -> True]}


      Interestingly enough, using a built-in function (like KaryTree) yields expected results:



      {KaryTree[15, VertexLabels -> "Name"], 
      GraphPlot[KaryTree[15], VertexLabeling -> True]}


      My work-around is using Graph and formatting it exactly how I want, but I would like to understand why the vertex labeling is incorrect!



      enter image description here



      enter image description here










      share|improve this question









      $endgroup$




      A very peculiar thing is happening when I wrap a Graph with GraphPlot. The picture below shows the correct vertex labeling. However, GraphPlot changes the vertex labeling! Am I misusing this function or is this something I should report to Wolfram? I'm running version 11.0.1.0.



      Below is some code to reproduce the issue (but with a simpler graph).



      {gph = Graph[{2 -> 1, 5 -> 0, 7 -> 6, 8 -> 7, 10 -> 8, 0 -> 2, 2 -> 3,
      3 -> 4, 5 -> 10, 8 -> 9}, VertexLabels -> "Name"],
      GraphPlot[gph, VertexLabeling -> True]}


      Interestingly enough, using a built-in function (like KaryTree) yields expected results:



      {KaryTree[15, VertexLabels -> "Name"], 
      GraphPlot[KaryTree[15], VertexLabeling -> True]}


      My work-around is using Graph and formatting it exactly how I want, but I would like to understand why the vertex labeling is incorrect!



      enter image description here



      enter image description here







      graphs-and-networks






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jan 6 at 16:22









      tjm167ustjm167us

      506211




      506211






















          1 Answer
          1






          active

          oldest

          votes


















          7












          $begingroup$

          GraphPlot supports inputs in several different formats. Originally, it took either a list of Rules or an adjacency matrix. With a rule-list input, it displays the vertex labels you would expect. But the adjacency matrix does not contain information about vertex names. Thus with a matrix input, it uses vertex indices (not names) for labelling.



          In 11.3 (and probably all the way back to at least 10.0), GraphPlot also takes Graph expressions as input. But it handles Graphs by converting them to a matrix (not a rule list!) first. Thus the vertex names are lost, and it will use vertex indices instead.



          Workaround: convert the graph to a rule list yourself.



          GraphPlot[Rule @@@ EdgeList@gph, VertexLabeling -> True, 
          DirectedEdges -> True, Method -> "LayeredDrawing"]


          enter image description here






          share|improve this answer











          $endgroup$









          • 1




            $begingroup$
            One of SW's Twitch videos showed that GraphPlot is being updated for version 12.0, so you can expect this to be fixed.
            $endgroup$
            – Szabolcs
            Jan 6 at 16:35











          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',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          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%2f188941%2fwhy-does-graphplot-mislabel-vertices-from-a-graph%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          7












          $begingroup$

          GraphPlot supports inputs in several different formats. Originally, it took either a list of Rules or an adjacency matrix. With a rule-list input, it displays the vertex labels you would expect. But the adjacency matrix does not contain information about vertex names. Thus with a matrix input, it uses vertex indices (not names) for labelling.



          In 11.3 (and probably all the way back to at least 10.0), GraphPlot also takes Graph expressions as input. But it handles Graphs by converting them to a matrix (not a rule list!) first. Thus the vertex names are lost, and it will use vertex indices instead.



          Workaround: convert the graph to a rule list yourself.



          GraphPlot[Rule @@@ EdgeList@gph, VertexLabeling -> True, 
          DirectedEdges -> True, Method -> "LayeredDrawing"]


          enter image description here






          share|improve this answer











          $endgroup$









          • 1




            $begingroup$
            One of SW's Twitch videos showed that GraphPlot is being updated for version 12.0, so you can expect this to be fixed.
            $endgroup$
            – Szabolcs
            Jan 6 at 16:35
















          7












          $begingroup$

          GraphPlot supports inputs in several different formats. Originally, it took either a list of Rules or an adjacency matrix. With a rule-list input, it displays the vertex labels you would expect. But the adjacency matrix does not contain information about vertex names. Thus with a matrix input, it uses vertex indices (not names) for labelling.



          In 11.3 (and probably all the way back to at least 10.0), GraphPlot also takes Graph expressions as input. But it handles Graphs by converting them to a matrix (not a rule list!) first. Thus the vertex names are lost, and it will use vertex indices instead.



          Workaround: convert the graph to a rule list yourself.



          GraphPlot[Rule @@@ EdgeList@gph, VertexLabeling -> True, 
          DirectedEdges -> True, Method -> "LayeredDrawing"]


          enter image description here






          share|improve this answer











          $endgroup$









          • 1




            $begingroup$
            One of SW's Twitch videos showed that GraphPlot is being updated for version 12.0, so you can expect this to be fixed.
            $endgroup$
            – Szabolcs
            Jan 6 at 16:35














          7












          7








          7





          $begingroup$

          GraphPlot supports inputs in several different formats. Originally, it took either a list of Rules or an adjacency matrix. With a rule-list input, it displays the vertex labels you would expect. But the adjacency matrix does not contain information about vertex names. Thus with a matrix input, it uses vertex indices (not names) for labelling.



          In 11.3 (and probably all the way back to at least 10.0), GraphPlot also takes Graph expressions as input. But it handles Graphs by converting them to a matrix (not a rule list!) first. Thus the vertex names are lost, and it will use vertex indices instead.



          Workaround: convert the graph to a rule list yourself.



          GraphPlot[Rule @@@ EdgeList@gph, VertexLabeling -> True, 
          DirectedEdges -> True, Method -> "LayeredDrawing"]


          enter image description here






          share|improve this answer











          $endgroup$



          GraphPlot supports inputs in several different formats. Originally, it took either a list of Rules or an adjacency matrix. With a rule-list input, it displays the vertex labels you would expect. But the adjacency matrix does not contain information about vertex names. Thus with a matrix input, it uses vertex indices (not names) for labelling.



          In 11.3 (and probably all the way back to at least 10.0), GraphPlot also takes Graph expressions as input. But it handles Graphs by converting them to a matrix (not a rule list!) first. Thus the vertex names are lost, and it will use vertex indices instead.



          Workaround: convert the graph to a rule list yourself.



          GraphPlot[Rule @@@ EdgeList@gph, VertexLabeling -> True, 
          DirectedEdges -> True, Method -> "LayeredDrawing"]


          enter image description here







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Jan 6 at 18:59

























          answered Jan 6 at 16:35









          SzabolcsSzabolcs

          159k13435930




          159k13435930








          • 1




            $begingroup$
            One of SW's Twitch videos showed that GraphPlot is being updated for version 12.0, so you can expect this to be fixed.
            $endgroup$
            – Szabolcs
            Jan 6 at 16:35














          • 1




            $begingroup$
            One of SW's Twitch videos showed that GraphPlot is being updated for version 12.0, so you can expect this to be fixed.
            $endgroup$
            – Szabolcs
            Jan 6 at 16:35








          1




          1




          $begingroup$
          One of SW's Twitch videos showed that GraphPlot is being updated for version 12.0, so you can expect this to be fixed.
          $endgroup$
          – Szabolcs
          Jan 6 at 16:35




          $begingroup$
          One of SW's Twitch videos showed that GraphPlot is being updated for version 12.0, so you can expect this to be fixed.
          $endgroup$
          – Szabolcs
          Jan 6 at 16:35


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Mathematica Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          Use MathJax to format equations. MathJax reference.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f188941%2fwhy-does-graphplot-mislabel-vertices-from-a-graph%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Human spaceflight

          Can not write log (Is /dev/pts mounted?) - openpty in Ubuntu-on-Windows?

          張江高科駅