Use Graphviz to show two tables adjacent to each other with lines between cells












1















I would like to show the diagram below, except with the two tables on the same horizontal level. I would like the second table to be shown to the right of the first table and not below it like it is currently.



enter image description here



The current code for graphviz that I have is:



digraph G  {

node [shape=record, fontname="Arial"];

set1 [label = "{Blue Crosses | B1 | B2 | B3 | B4 }|{ Square |<b1> Left |<b2> Left |<b3> Right | Left }"];
set2 [label = "{Blue Crosses |<b1> B1 |<b2> B2 |<b3> B3 }|{ Coordinates | (1, 1) | (2, 2) | (4, 2) }"];

set1:b1 -> set2:b1;
set1:b2 -> set2:b2;
set1:b3 -> set2:b3;

}









share|improve this question



























    1















    I would like to show the diagram below, except with the two tables on the same horizontal level. I would like the second table to be shown to the right of the first table and not below it like it is currently.



    enter image description here



    The current code for graphviz that I have is:



    digraph G  {

    node [shape=record, fontname="Arial"];

    set1 [label = "{Blue Crosses | B1 | B2 | B3 | B4 }|{ Square |<b1> Left |<b2> Left |<b3> Right | Left }"];
    set2 [label = "{Blue Crosses |<b1> B1 |<b2> B2 |<b3> B3 }|{ Coordinates | (1, 1) | (2, 2) | (4, 2) }"];

    set1:b1 -> set2:b1;
    set1:b2 -> set2:b2;
    set1:b3 -> set2:b3;

    }









    share|improve this question

























      1












      1








      1








      I would like to show the diagram below, except with the two tables on the same horizontal level. I would like the second table to be shown to the right of the first table and not below it like it is currently.



      enter image description here



      The current code for graphviz that I have is:



      digraph G  {

      node [shape=record, fontname="Arial"];

      set1 [label = "{Blue Crosses | B1 | B2 | B3 | B4 }|{ Square |<b1> Left |<b2> Left |<b3> Right | Left }"];
      set2 [label = "{Blue Crosses |<b1> B1 |<b2> B2 |<b3> B3 }|{ Coordinates | (1, 1) | (2, 2) | (4, 2) }"];

      set1:b1 -> set2:b1;
      set1:b2 -> set2:b2;
      set1:b3 -> set2:b3;

      }









      share|improve this question














      I would like to show the diagram below, except with the two tables on the same horizontal level. I would like the second table to be shown to the right of the first table and not below it like it is currently.



      enter image description here



      The current code for graphviz that I have is:



      digraph G  {

      node [shape=record, fontname="Arial"];

      set1 [label = "{Blue Crosses | B1 | B2 | B3 | B4 }|{ Square |<b1> Left |<b2> Left |<b3> Right | Left }"];
      set2 [label = "{Blue Crosses |<b1> B1 |<b2> B2 |<b3> B3 }|{ Coordinates | (1, 1) | (2, 2) | (4, 2) }"];

      set1:b1 -> set2:b1;
      set1:b2 -> set2:b2;
      set1:b3 -> set2:b3;

      }






      graphviz






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 24 '18 at 21:30









      Philip WhittenPhilip Whitten

      15810




      15810
























          1 Answer
          1






          active

          oldest

          votes


















          0














          In order to achieve what you want, you need to add the line



          { rank = same; set1 set2 }


          to your code after you have created the nodes. However, in this situation, you will find that graphviz gets confused and doesn't recognise the ports anymore. So instead of using record = shape you will need to re-code your graph with HTML-like labels. I have done that for the example provided (thanks for a clear question with code and desired outcome, by the way):



          digraph G  
          {
          node[ shape = none, fontname = "Arial" ];

          set1[ label=<
          <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
          <TR>
          <TD>Blue Crosses</TD>
          <TD>Square</TD>
          </TR>
          <TR>
          <TD>B1</TD>
          <TD PORT="b1">Left</TD>
          </TR>
          <TR>
          <TD>B2</TD>
          <TD PORT="b2">Left</TD>
          </TR>
          <TR>
          <TD>Right</TD>
          <TD PORT="b3">Right</TD>
          </TR>
          <TR>
          <TD>B4</TD>
          <TD>Left</TD>
          </TR>
          </TABLE>>];

          set2[ label=<
          <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
          <TR>
          <TD>Blue Crosses</TD>
          <TD>Coordinates</TD>
          </TR>
          <TR>
          <TD PORT="b1">B1</TD>
          <TD>(1, 1)</TD>
          </TR>
          <TR>
          <TD PORT="b2">B2</TD>
          <TD>(2, 2)</TD>
          </TR>
          <TR>
          <TD PORT="b3">B3</TD>
          <TD>(4, 2)</TD>
          </TR>
          </TABLE>>];

          # layout
          nodesep = 2; /* increase distance between nodes */
          { rank = same; set1 set2 }

          set1:b1 -> set2:b1;
          set1:b2 -> set2:b2;
          set1:b3 -> set2:b3;
          }


          yields



          enter image description here






          share|improve this answer


























          • Thanks, I didn't try the html labels before and kept being stuck with Graphviz getting confused when I attempted to add ranking to my previous code.

            – Philip Whitten
            Nov 25 '18 at 4:52











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          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: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          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%2fstackoverflow.com%2fquestions%2f53462525%2fuse-graphviz-to-show-two-tables-adjacent-to-each-other-with-lines-between-cells%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









          0














          In order to achieve what you want, you need to add the line



          { rank = same; set1 set2 }


          to your code after you have created the nodes. However, in this situation, you will find that graphviz gets confused and doesn't recognise the ports anymore. So instead of using record = shape you will need to re-code your graph with HTML-like labels. I have done that for the example provided (thanks for a clear question with code and desired outcome, by the way):



          digraph G  
          {
          node[ shape = none, fontname = "Arial" ];

          set1[ label=<
          <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
          <TR>
          <TD>Blue Crosses</TD>
          <TD>Square</TD>
          </TR>
          <TR>
          <TD>B1</TD>
          <TD PORT="b1">Left</TD>
          </TR>
          <TR>
          <TD>B2</TD>
          <TD PORT="b2">Left</TD>
          </TR>
          <TR>
          <TD>Right</TD>
          <TD PORT="b3">Right</TD>
          </TR>
          <TR>
          <TD>B4</TD>
          <TD>Left</TD>
          </TR>
          </TABLE>>];

          set2[ label=<
          <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
          <TR>
          <TD>Blue Crosses</TD>
          <TD>Coordinates</TD>
          </TR>
          <TR>
          <TD PORT="b1">B1</TD>
          <TD>(1, 1)</TD>
          </TR>
          <TR>
          <TD PORT="b2">B2</TD>
          <TD>(2, 2)</TD>
          </TR>
          <TR>
          <TD PORT="b3">B3</TD>
          <TD>(4, 2)</TD>
          </TR>
          </TABLE>>];

          # layout
          nodesep = 2; /* increase distance between nodes */
          { rank = same; set1 set2 }

          set1:b1 -> set2:b1;
          set1:b2 -> set2:b2;
          set1:b3 -> set2:b3;
          }


          yields



          enter image description here






          share|improve this answer


























          • Thanks, I didn't try the html labels before and kept being stuck with Graphviz getting confused when I attempted to add ranking to my previous code.

            – Philip Whitten
            Nov 25 '18 at 4:52
















          0














          In order to achieve what you want, you need to add the line



          { rank = same; set1 set2 }


          to your code after you have created the nodes. However, in this situation, you will find that graphviz gets confused and doesn't recognise the ports anymore. So instead of using record = shape you will need to re-code your graph with HTML-like labels. I have done that for the example provided (thanks for a clear question with code and desired outcome, by the way):



          digraph G  
          {
          node[ shape = none, fontname = "Arial" ];

          set1[ label=<
          <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
          <TR>
          <TD>Blue Crosses</TD>
          <TD>Square</TD>
          </TR>
          <TR>
          <TD>B1</TD>
          <TD PORT="b1">Left</TD>
          </TR>
          <TR>
          <TD>B2</TD>
          <TD PORT="b2">Left</TD>
          </TR>
          <TR>
          <TD>Right</TD>
          <TD PORT="b3">Right</TD>
          </TR>
          <TR>
          <TD>B4</TD>
          <TD>Left</TD>
          </TR>
          </TABLE>>];

          set2[ label=<
          <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
          <TR>
          <TD>Blue Crosses</TD>
          <TD>Coordinates</TD>
          </TR>
          <TR>
          <TD PORT="b1">B1</TD>
          <TD>(1, 1)</TD>
          </TR>
          <TR>
          <TD PORT="b2">B2</TD>
          <TD>(2, 2)</TD>
          </TR>
          <TR>
          <TD PORT="b3">B3</TD>
          <TD>(4, 2)</TD>
          </TR>
          </TABLE>>];

          # layout
          nodesep = 2; /* increase distance between nodes */
          { rank = same; set1 set2 }

          set1:b1 -> set2:b1;
          set1:b2 -> set2:b2;
          set1:b3 -> set2:b3;
          }


          yields



          enter image description here






          share|improve this answer


























          • Thanks, I didn't try the html labels before and kept being stuck with Graphviz getting confused when I attempted to add ranking to my previous code.

            – Philip Whitten
            Nov 25 '18 at 4:52














          0












          0








          0







          In order to achieve what you want, you need to add the line



          { rank = same; set1 set2 }


          to your code after you have created the nodes. However, in this situation, you will find that graphviz gets confused and doesn't recognise the ports anymore. So instead of using record = shape you will need to re-code your graph with HTML-like labels. I have done that for the example provided (thanks for a clear question with code and desired outcome, by the way):



          digraph G  
          {
          node[ shape = none, fontname = "Arial" ];

          set1[ label=<
          <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
          <TR>
          <TD>Blue Crosses</TD>
          <TD>Square</TD>
          </TR>
          <TR>
          <TD>B1</TD>
          <TD PORT="b1">Left</TD>
          </TR>
          <TR>
          <TD>B2</TD>
          <TD PORT="b2">Left</TD>
          </TR>
          <TR>
          <TD>Right</TD>
          <TD PORT="b3">Right</TD>
          </TR>
          <TR>
          <TD>B4</TD>
          <TD>Left</TD>
          </TR>
          </TABLE>>];

          set2[ label=<
          <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
          <TR>
          <TD>Blue Crosses</TD>
          <TD>Coordinates</TD>
          </TR>
          <TR>
          <TD PORT="b1">B1</TD>
          <TD>(1, 1)</TD>
          </TR>
          <TR>
          <TD PORT="b2">B2</TD>
          <TD>(2, 2)</TD>
          </TR>
          <TR>
          <TD PORT="b3">B3</TD>
          <TD>(4, 2)</TD>
          </TR>
          </TABLE>>];

          # layout
          nodesep = 2; /* increase distance between nodes */
          { rank = same; set1 set2 }

          set1:b1 -> set2:b1;
          set1:b2 -> set2:b2;
          set1:b3 -> set2:b3;
          }


          yields



          enter image description here






          share|improve this answer















          In order to achieve what you want, you need to add the line



          { rank = same; set1 set2 }


          to your code after you have created the nodes. However, in this situation, you will find that graphviz gets confused and doesn't recognise the ports anymore. So instead of using record = shape you will need to re-code your graph with HTML-like labels. I have done that for the example provided (thanks for a clear question with code and desired outcome, by the way):



          digraph G  
          {
          node[ shape = none, fontname = "Arial" ];

          set1[ label=<
          <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
          <TR>
          <TD>Blue Crosses</TD>
          <TD>Square</TD>
          </TR>
          <TR>
          <TD>B1</TD>
          <TD PORT="b1">Left</TD>
          </TR>
          <TR>
          <TD>B2</TD>
          <TD PORT="b2">Left</TD>
          </TR>
          <TR>
          <TD>Right</TD>
          <TD PORT="b3">Right</TD>
          </TR>
          <TR>
          <TD>B4</TD>
          <TD>Left</TD>
          </TR>
          </TABLE>>];

          set2[ label=<
          <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
          <TR>
          <TD>Blue Crosses</TD>
          <TD>Coordinates</TD>
          </TR>
          <TR>
          <TD PORT="b1">B1</TD>
          <TD>(1, 1)</TD>
          </TR>
          <TR>
          <TD PORT="b2">B2</TD>
          <TD>(2, 2)</TD>
          </TR>
          <TR>
          <TD PORT="b3">B3</TD>
          <TD>(4, 2)</TD>
          </TR>
          </TABLE>>];

          # layout
          nodesep = 2; /* increase distance between nodes */
          { rank = same; set1 set2 }

          set1:b1 -> set2:b1;
          set1:b2 -> set2:b2;
          set1:b3 -> set2:b3;
          }


          yields



          enter image description here







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 25 '18 at 5:03

























          answered Nov 25 '18 at 1:53









          vaettchenvaettchen

          5,2551332




          5,2551332













          • Thanks, I didn't try the html labels before and kept being stuck with Graphviz getting confused when I attempted to add ranking to my previous code.

            – Philip Whitten
            Nov 25 '18 at 4:52



















          • Thanks, I didn't try the html labels before and kept being stuck with Graphviz getting confused when I attempted to add ranking to my previous code.

            – Philip Whitten
            Nov 25 '18 at 4:52

















          Thanks, I didn't try the html labels before and kept being stuck with Graphviz getting confused when I attempted to add ranking to my previous code.

          – Philip Whitten
          Nov 25 '18 at 4:52





          Thanks, I didn't try the html labels before and kept being stuck with Graphviz getting confused when I attempted to add ranking to my previous code.

          – Philip Whitten
          Nov 25 '18 at 4:52




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • 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.


          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%2fstackoverflow.com%2fquestions%2f53462525%2fuse-graphviz-to-show-two-tables-adjacent-to-each-other-with-lines-between-cells%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

          Futebolista

          Feedback on college project

          Albești (Vaslui)