Use Graphviz to show two tables adjacent to each other with lines between cells
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.

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
add a comment |
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.

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
add a comment |
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.

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

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
graphviz
asked Nov 24 '18 at 21:30
Philip WhittenPhilip Whitten
15810
15810
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
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

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
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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

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
add a comment |
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

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
add a comment |
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

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

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
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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