Generating adjacency matrices from isomorphic graphsTikz foreach inside matrixHow to make tikz center the...
Divine apple island
Global amount of publications over time
Folder comparison
How do I implement a file system driver driver in Linux?
When quoting, must I also copy hyphens used to divide words that continue on the next line?
How to align and center standalone amsmath equations?
A social experiment. What is the worst that can happen?
Does the Mind Blank spell prevent the target from being frightened?
Can a significant change in incentives void an employment contract?
Has Darkwing Duck ever met Scrooge McDuck?
Greco-Roman egalitarianism
Did arcade monitors have same pixel aspect ratio as TV sets?
Proving a function is onto where f(x)=|x|.
Should I stop contributing to retirement accounts?
My friend sent me a screenshot of a transaction hash, but when I search for it I find divergent data. What happened?
Why in book's example is used 言葉(ことば) instead of 言語(げんご)?
Could the E-bike drivetrain wear down till needing replacement after 400 km?
We have a love-hate relationship
Proof of Lemma: Every nonzero integer can be written as a product of primes
In Star Trek IV, why did the Bounty go back to a time when whales were already rare?
Customize circled numbers
Visiting the UK as unmarried couple
How to color a curve
How should I respond when I lied about my education and the company finds out through background check?
Generating adjacency matrices from isomorphic graphs
Tikz foreach inside matrixHow to make tikz center the cells of a matrix?Bipartite graphsDrawing graphs in LaTeXGenerating dozens of graphsTo wrap the external lines so that it can touch the perimeterDrawing rectilinear curves in Tikz, aka an Etch-a-Sketch drawingExporting graphs from Mathematica to LaTex document?Line up nested tikz enviroments or how to get rid of themGenerating graphs with smooth edges?How to draw animated isomorphic graphs?
Here are some isomorphic graphs and their corresponding adjacency matrices. I can draw the graphs with tikz. But I'm not sure the best way to draw the matrices. Is it possible to generate one from the other? What's the right way to approach it?
Here's an example of the code to generate a graph:
documentclass{standalone}
usepackage{tikz}
begin{document}
begin{tikzpicture}
tikzset{Bullet/.style={circle,draw,fill=black,scale=0.75}}
node[Bullet,label=left :{$e_1$}] (E1) at (0,2) {} ;
node[Bullet,label=above:{$e_2$}] (E2) at (1,3) {} ;
node[Bullet,label=right:{$e_3$}] (E3) at (2,2) {} ;
node[Bullet,label=right:{$e_4$}] (E4) at (2,0) {} ;
node[Bullet,label=left :{$e_5$}] (E5) at (0,0) {} ;
draw[thick] (E1)--(E2)--(E3)--(E4)--(E5)--(E1) {} ;
end{tikzpicture}
end{document}
diagrams matrices graphs tikz-pic
add a comment |
Here are some isomorphic graphs and their corresponding adjacency matrices. I can draw the graphs with tikz. But I'm not sure the best way to draw the matrices. Is it possible to generate one from the other? What's the right way to approach it?
Here's an example of the code to generate a graph:
documentclass{standalone}
usepackage{tikz}
begin{document}
begin{tikzpicture}
tikzset{Bullet/.style={circle,draw,fill=black,scale=0.75}}
node[Bullet,label=left :{$e_1$}] (E1) at (0,2) {} ;
node[Bullet,label=above:{$e_2$}] (E2) at (1,3) {} ;
node[Bullet,label=right:{$e_3$}] (E3) at (2,2) {} ;
node[Bullet,label=right:{$e_4$}] (E4) at (2,0) {} ;
node[Bullet,label=left :{$e_5$}] (E5) at (0,0) {} ;
draw[thick] (E1)--(E2)--(E3)--(E4)--(E5)--(E1) {} ;
end{tikzpicture}
end{document}
diagrams matrices graphs tikz-pic
Shouldn't it be the other way around: you construct the diagrams from the adjacency matrices?
– marmot
2 hours ago
@marmot Probably, normally. Actually I don't think so. I mean.. Either way is probably good. But I have some graphs drawn up, and I want to draw the matrices to suit them. If I can't figure it out programmatically, I'll just draw them up separately. Either with LaTeX somehow or with Adobe Illustrator, or some spreadsheet/word processor. LaTeX would be nice though.
– tjt263
1 hour ago
add a comment |
Here are some isomorphic graphs and their corresponding adjacency matrices. I can draw the graphs with tikz. But I'm not sure the best way to draw the matrices. Is it possible to generate one from the other? What's the right way to approach it?
Here's an example of the code to generate a graph:
documentclass{standalone}
usepackage{tikz}
begin{document}
begin{tikzpicture}
tikzset{Bullet/.style={circle,draw,fill=black,scale=0.75}}
node[Bullet,label=left :{$e_1$}] (E1) at (0,2) {} ;
node[Bullet,label=above:{$e_2$}] (E2) at (1,3) {} ;
node[Bullet,label=right:{$e_3$}] (E3) at (2,2) {} ;
node[Bullet,label=right:{$e_4$}] (E4) at (2,0) {} ;
node[Bullet,label=left :{$e_5$}] (E5) at (0,0) {} ;
draw[thick] (E1)--(E2)--(E3)--(E4)--(E5)--(E1) {} ;
end{tikzpicture}
end{document}
diagrams matrices graphs tikz-pic
Here are some isomorphic graphs and their corresponding adjacency matrices. I can draw the graphs with tikz. But I'm not sure the best way to draw the matrices. Is it possible to generate one from the other? What's the right way to approach it?
Here's an example of the code to generate a graph:
documentclass{standalone}
usepackage{tikz}
begin{document}
begin{tikzpicture}
tikzset{Bullet/.style={circle,draw,fill=black,scale=0.75}}
node[Bullet,label=left :{$e_1$}] (E1) at (0,2) {} ;
node[Bullet,label=above:{$e_2$}] (E2) at (1,3) {} ;
node[Bullet,label=right:{$e_3$}] (E3) at (2,2) {} ;
node[Bullet,label=right:{$e_4$}] (E4) at (2,0) {} ;
node[Bullet,label=left :{$e_5$}] (E5) at (0,0) {} ;
draw[thick] (E1)--(E2)--(E3)--(E4)--(E5)--(E1) {} ;
end{tikzpicture}
end{document}
diagrams matrices graphs tikz-pic
diagrams matrices graphs tikz-pic
edited 3 hours ago
tjt263
asked 3 hours ago
tjt263tjt263
1826
1826
Shouldn't it be the other way around: you construct the diagrams from the adjacency matrices?
– marmot
2 hours ago
@marmot Probably, normally. Actually I don't think so. I mean.. Either way is probably good. But I have some graphs drawn up, and I want to draw the matrices to suit them. If I can't figure it out programmatically, I'll just draw them up separately. Either with LaTeX somehow or with Adobe Illustrator, or some spreadsheet/word processor. LaTeX would be nice though.
– tjt263
1 hour ago
add a comment |
Shouldn't it be the other way around: you construct the diagrams from the adjacency matrices?
– marmot
2 hours ago
@marmot Probably, normally. Actually I don't think so. I mean.. Either way is probably good. But I have some graphs drawn up, and I want to draw the matrices to suit them. If I can't figure it out programmatically, I'll just draw them up separately. Either with LaTeX somehow or with Adobe Illustrator, or some spreadsheet/word processor. LaTeX would be nice though.
– tjt263
1 hour ago
Shouldn't it be the other way around: you construct the diagrams from the adjacency matrices?
– marmot
2 hours ago
Shouldn't it be the other way around: you construct the diagrams from the adjacency matrices?
– marmot
2 hours ago
@marmot Probably, normally. Actually I don't think so. I mean.. Either way is probably good. But I have some graphs drawn up, and I want to draw the matrices to suit them. If I can't figure it out programmatically, I'll just draw them up separately. Either with LaTeX somehow or with Adobe Illustrator, or some spreadsheet/word processor. LaTeX would be nice though.
– tjt263
1 hour ago
@marmot Probably, normally. Actually I don't think so. I mean.. Either way is probably good. But I have some graphs drawn up, and I want to draw the matrices to suit them. If I can't figure it out programmatically, I'll just draw them up separately. Either with LaTeX somehow or with Adobe Illustrator, or some spreadsheet/word processor. LaTeX would be nice though.
– tjt263
1 hour ago
add a comment |
1 Answer
1
active
oldest
votes
This is in case you change your mind and use the adjacency matrices to draw the graphs. TikZ allows you to define arrays, see p. 999 of the pgfmanual. And these arrays can be converted to tables using this nice answer. And these matrices/arrays can also be used to define the graphs.
documentclass[tikz,border=3.14mm]{standalone}
usepackage{etoolbox}
usetikzlibrary{matrix,positioning}
% building the table in a foreach loop from https://tex.stackexchange.com/a/60400/121799
begin{document}
begin{tikzpicture}[Bullet/.style={circle,draw,fill=black,inner sep=1.5pt},
adjacency matrix/.style={ampersand replacement=&,matrix of math nodes,
row 1/.append style={nodes={font=boldmath}},
column 1/.append style={nodes={font=boldmath}},nodes in empty cells,
nodes={draw,minimum width=1.5em,text height=1.8ex},column sep=-pgflinewidth,row
sep=-pgflinewidth}]
% first matrix
defadjancymatrix{%
{{0,0,1,1,0},%
{0,0,0,1,1},%
{1,0,0,0,1},%
{1,1,0,0,0},%
{0,1,1,0,0}}}
letmymatrixcontentempty
defmymatrixcontent{|[draw=none]|& 1 & 2 & 3 & 4 & 5\}
begin{scope}[local bounding box=left]
foreach X in {1,...,5}
{node[Bullet,label=90+72-X*72:{$e_X$}] (EX) at (90+72-X*72:2) {} ;}
foreach X in {1,...,5}
{begingroupedefx{endgroup
noexpandgapptonoexpandmymatrixcontent{X }}x
foreach Y in {1,...,5}
{pgfmathtruncatemacro{itest}{adjancymatrix[X-1][Y-1]}
ifnumitest=1
draw (EX) -- (EY);
begingroupedefx{endgroup
noexpandgapptonoexpandmymatrixcontent{& 1 }}x
else
begingroupedefx{endgroup
noexpandgapptonoexpandmymatrixcontent{ &}}x
fi
}
gapptomymatrixcontent{\}
}
end{scope}
matrix (leftmat) [below=of left,adjacency matrix]{
mymatrixcontent
};
%
% second matrix
defadjancymatrix{%
{{0,1,0,0,1},%
{1,0,1,0,0},%
{0,1,0,1,0},%
{0,0,1,0,1},%
{1,0,0,1,0}}}
letmymatrixcontentempty
defmymatrixcontent{|[draw=none]|& 1 & 2 & 3 & 4 & 5\}
begin{scope}[local bounding box=middle,xshift=5cm]
foreach X in {1,...,5}
{node[Bullet,label=90+72-X*72:{$e_X$}] (EX) at (90+72-X*72:2) {} ;}
foreach X in {1,...,5}
{begingroupedefx{endgroup
noexpandgapptonoexpandmymatrixcontent{X }}x
foreach Y in {1,...,5}
{pgfmathtruncatemacro{itest}{adjancymatrix[X-1][Y-1]}
ifnumitest=1
draw (EX) -- (EY);
begingroupedefx{endgroup
noexpandgapptonoexpandmymatrixcontent{& 1 }}x
else
begingroupedefx{endgroup
noexpandgapptonoexpandmymatrixcontent{ &}}x
fi
}
gapptomymatrixcontent{\}
}
end{scope}
matrix (midmat) [below=of middle,adjacency matrix]{
mymatrixcontent
};
% third matrix
defadjancymatrix{%
{{0,1,0,1,0},%
{1,0,0,0,1},%
{0,0,0,1,1},%
{1,0,1,0,0},%
{0,1,1,0,0}}}
letmymatrixcontentempty
defmymatrixcontent{|[draw=none]|& 1 & 2 & 3 & 4 & 5\}
begin{scope}[local bounding box=right,xshift=10cm]
foreach X in {1,...,3}
{node[Bullet,label=90+72-X*72:{$e_X$}] (EX) at (90+72-X*72:2) {} ;}
node[Bullet,label=90+72-4*72:{$e_5$}] (E5) at (90+72-4*72:2) {} ;
node[Bullet,label=90+72-5*72:{$e_4$}] (E4) at (90+72-5*72:2) {} ;
foreach X in {1,...,5}
{begingroupedefx{endgroup
noexpandgapptonoexpandmymatrixcontent{X }}x
foreach Y in {1,...,5}
{pgfmathtruncatemacro{itest}{adjancymatrix[X-1][Y-1]}
ifnumitest=1
draw (EX) -- (EY);
begingroupedefx{endgroup
noexpandgapptonoexpandmymatrixcontent{& 1 }}x
else
begingroupedefx{endgroup
noexpandgapptonoexpandmymatrixcontent{ &}}x
fi
}
gapptomymatrixcontent{\}
}
end{scope}
matrix (rightmat) [below=of right,adjacency matrix]{
mymatrixcontent
};
end{tikzpicture}
end{document}
Not bad, can we get the matrix lines drawn in or is it just like that
– tjt263
13 mins ago
@tjt263 Yes, sure.
– marmot
5 mins ago
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "85"
};
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
});
}
});
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%2ftex.stackexchange.com%2fquestions%2f481289%2fgenerating-adjacency-matrices-from-isomorphic-graphs%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
This is in case you change your mind and use the adjacency matrices to draw the graphs. TikZ allows you to define arrays, see p. 999 of the pgfmanual. And these arrays can be converted to tables using this nice answer. And these matrices/arrays can also be used to define the graphs.
documentclass[tikz,border=3.14mm]{standalone}
usepackage{etoolbox}
usetikzlibrary{matrix,positioning}
% building the table in a foreach loop from https://tex.stackexchange.com/a/60400/121799
begin{document}
begin{tikzpicture}[Bullet/.style={circle,draw,fill=black,inner sep=1.5pt},
adjacency matrix/.style={ampersand replacement=&,matrix of math nodes,
row 1/.append style={nodes={font=boldmath}},
column 1/.append style={nodes={font=boldmath}},nodes in empty cells,
nodes={draw,minimum width=1.5em,text height=1.8ex},column sep=-pgflinewidth,row
sep=-pgflinewidth}]
% first matrix
defadjancymatrix{%
{{0,0,1,1,0},%
{0,0,0,1,1},%
{1,0,0,0,1},%
{1,1,0,0,0},%
{0,1,1,0,0}}}
letmymatrixcontentempty
defmymatrixcontent{|[draw=none]|& 1 & 2 & 3 & 4 & 5\}
begin{scope}[local bounding box=left]
foreach X in {1,...,5}
{node[Bullet,label=90+72-X*72:{$e_X$}] (EX) at (90+72-X*72:2) {} ;}
foreach X in {1,...,5}
{begingroupedefx{endgroup
noexpandgapptonoexpandmymatrixcontent{X }}x
foreach Y in {1,...,5}
{pgfmathtruncatemacro{itest}{adjancymatrix[X-1][Y-1]}
ifnumitest=1
draw (EX) -- (EY);
begingroupedefx{endgroup
noexpandgapptonoexpandmymatrixcontent{& 1 }}x
else
begingroupedefx{endgroup
noexpandgapptonoexpandmymatrixcontent{ &}}x
fi
}
gapptomymatrixcontent{\}
}
end{scope}
matrix (leftmat) [below=of left,adjacency matrix]{
mymatrixcontent
};
%
% second matrix
defadjancymatrix{%
{{0,1,0,0,1},%
{1,0,1,0,0},%
{0,1,0,1,0},%
{0,0,1,0,1},%
{1,0,0,1,0}}}
letmymatrixcontentempty
defmymatrixcontent{|[draw=none]|& 1 & 2 & 3 & 4 & 5\}
begin{scope}[local bounding box=middle,xshift=5cm]
foreach X in {1,...,5}
{node[Bullet,label=90+72-X*72:{$e_X$}] (EX) at (90+72-X*72:2) {} ;}
foreach X in {1,...,5}
{begingroupedefx{endgroup
noexpandgapptonoexpandmymatrixcontent{X }}x
foreach Y in {1,...,5}
{pgfmathtruncatemacro{itest}{adjancymatrix[X-1][Y-1]}
ifnumitest=1
draw (EX) -- (EY);
begingroupedefx{endgroup
noexpandgapptonoexpandmymatrixcontent{& 1 }}x
else
begingroupedefx{endgroup
noexpandgapptonoexpandmymatrixcontent{ &}}x
fi
}
gapptomymatrixcontent{\}
}
end{scope}
matrix (midmat) [below=of middle,adjacency matrix]{
mymatrixcontent
};
% third matrix
defadjancymatrix{%
{{0,1,0,1,0},%
{1,0,0,0,1},%
{0,0,0,1,1},%
{1,0,1,0,0},%
{0,1,1,0,0}}}
letmymatrixcontentempty
defmymatrixcontent{|[draw=none]|& 1 & 2 & 3 & 4 & 5\}
begin{scope}[local bounding box=right,xshift=10cm]
foreach X in {1,...,3}
{node[Bullet,label=90+72-X*72:{$e_X$}] (EX) at (90+72-X*72:2) {} ;}
node[Bullet,label=90+72-4*72:{$e_5$}] (E5) at (90+72-4*72:2) {} ;
node[Bullet,label=90+72-5*72:{$e_4$}] (E4) at (90+72-5*72:2) {} ;
foreach X in {1,...,5}
{begingroupedefx{endgroup
noexpandgapptonoexpandmymatrixcontent{X }}x
foreach Y in {1,...,5}
{pgfmathtruncatemacro{itest}{adjancymatrix[X-1][Y-1]}
ifnumitest=1
draw (EX) -- (EY);
begingroupedefx{endgroup
noexpandgapptonoexpandmymatrixcontent{& 1 }}x
else
begingroupedefx{endgroup
noexpandgapptonoexpandmymatrixcontent{ &}}x
fi
}
gapptomymatrixcontent{\}
}
end{scope}
matrix (rightmat) [below=of right,adjacency matrix]{
mymatrixcontent
};
end{tikzpicture}
end{document}
Not bad, can we get the matrix lines drawn in or is it just like that
– tjt263
13 mins ago
@tjt263 Yes, sure.
– marmot
5 mins ago
add a comment |
This is in case you change your mind and use the adjacency matrices to draw the graphs. TikZ allows you to define arrays, see p. 999 of the pgfmanual. And these arrays can be converted to tables using this nice answer. And these matrices/arrays can also be used to define the graphs.
documentclass[tikz,border=3.14mm]{standalone}
usepackage{etoolbox}
usetikzlibrary{matrix,positioning}
% building the table in a foreach loop from https://tex.stackexchange.com/a/60400/121799
begin{document}
begin{tikzpicture}[Bullet/.style={circle,draw,fill=black,inner sep=1.5pt},
adjacency matrix/.style={ampersand replacement=&,matrix of math nodes,
row 1/.append style={nodes={font=boldmath}},
column 1/.append style={nodes={font=boldmath}},nodes in empty cells,
nodes={draw,minimum width=1.5em,text height=1.8ex},column sep=-pgflinewidth,row
sep=-pgflinewidth}]
% first matrix
defadjancymatrix{%
{{0,0,1,1,0},%
{0,0,0,1,1},%
{1,0,0,0,1},%
{1,1,0,0,0},%
{0,1,1,0,0}}}
letmymatrixcontentempty
defmymatrixcontent{|[draw=none]|& 1 & 2 & 3 & 4 & 5\}
begin{scope}[local bounding box=left]
foreach X in {1,...,5}
{node[Bullet,label=90+72-X*72:{$e_X$}] (EX) at (90+72-X*72:2) {} ;}
foreach X in {1,...,5}
{begingroupedefx{endgroup
noexpandgapptonoexpandmymatrixcontent{X }}x
foreach Y in {1,...,5}
{pgfmathtruncatemacro{itest}{adjancymatrix[X-1][Y-1]}
ifnumitest=1
draw (EX) -- (EY);
begingroupedefx{endgroup
noexpandgapptonoexpandmymatrixcontent{& 1 }}x
else
begingroupedefx{endgroup
noexpandgapptonoexpandmymatrixcontent{ &}}x
fi
}
gapptomymatrixcontent{\}
}
end{scope}
matrix (leftmat) [below=of left,adjacency matrix]{
mymatrixcontent
};
%
% second matrix
defadjancymatrix{%
{{0,1,0,0,1},%
{1,0,1,0,0},%
{0,1,0,1,0},%
{0,0,1,0,1},%
{1,0,0,1,0}}}
letmymatrixcontentempty
defmymatrixcontent{|[draw=none]|& 1 & 2 & 3 & 4 & 5\}
begin{scope}[local bounding box=middle,xshift=5cm]
foreach X in {1,...,5}
{node[Bullet,label=90+72-X*72:{$e_X$}] (EX) at (90+72-X*72:2) {} ;}
foreach X in {1,...,5}
{begingroupedefx{endgroup
noexpandgapptonoexpandmymatrixcontent{X }}x
foreach Y in {1,...,5}
{pgfmathtruncatemacro{itest}{adjancymatrix[X-1][Y-1]}
ifnumitest=1
draw (EX) -- (EY);
begingroupedefx{endgroup
noexpandgapptonoexpandmymatrixcontent{& 1 }}x
else
begingroupedefx{endgroup
noexpandgapptonoexpandmymatrixcontent{ &}}x
fi
}
gapptomymatrixcontent{\}
}
end{scope}
matrix (midmat) [below=of middle,adjacency matrix]{
mymatrixcontent
};
% third matrix
defadjancymatrix{%
{{0,1,0,1,0},%
{1,0,0,0,1},%
{0,0,0,1,1},%
{1,0,1,0,0},%
{0,1,1,0,0}}}
letmymatrixcontentempty
defmymatrixcontent{|[draw=none]|& 1 & 2 & 3 & 4 & 5\}
begin{scope}[local bounding box=right,xshift=10cm]
foreach X in {1,...,3}
{node[Bullet,label=90+72-X*72:{$e_X$}] (EX) at (90+72-X*72:2) {} ;}
node[Bullet,label=90+72-4*72:{$e_5$}] (E5) at (90+72-4*72:2) {} ;
node[Bullet,label=90+72-5*72:{$e_4$}] (E4) at (90+72-5*72:2) {} ;
foreach X in {1,...,5}
{begingroupedefx{endgroup
noexpandgapptonoexpandmymatrixcontent{X }}x
foreach Y in {1,...,5}
{pgfmathtruncatemacro{itest}{adjancymatrix[X-1][Y-1]}
ifnumitest=1
draw (EX) -- (EY);
begingroupedefx{endgroup
noexpandgapptonoexpandmymatrixcontent{& 1 }}x
else
begingroupedefx{endgroup
noexpandgapptonoexpandmymatrixcontent{ &}}x
fi
}
gapptomymatrixcontent{\}
}
end{scope}
matrix (rightmat) [below=of right,adjacency matrix]{
mymatrixcontent
};
end{tikzpicture}
end{document}
Not bad, can we get the matrix lines drawn in or is it just like that
– tjt263
13 mins ago
@tjt263 Yes, sure.
– marmot
5 mins ago
add a comment |
This is in case you change your mind and use the adjacency matrices to draw the graphs. TikZ allows you to define arrays, see p. 999 of the pgfmanual. And these arrays can be converted to tables using this nice answer. And these matrices/arrays can also be used to define the graphs.
documentclass[tikz,border=3.14mm]{standalone}
usepackage{etoolbox}
usetikzlibrary{matrix,positioning}
% building the table in a foreach loop from https://tex.stackexchange.com/a/60400/121799
begin{document}
begin{tikzpicture}[Bullet/.style={circle,draw,fill=black,inner sep=1.5pt},
adjacency matrix/.style={ampersand replacement=&,matrix of math nodes,
row 1/.append style={nodes={font=boldmath}},
column 1/.append style={nodes={font=boldmath}},nodes in empty cells,
nodes={draw,minimum width=1.5em,text height=1.8ex},column sep=-pgflinewidth,row
sep=-pgflinewidth}]
% first matrix
defadjancymatrix{%
{{0,0,1,1,0},%
{0,0,0,1,1},%
{1,0,0,0,1},%
{1,1,0,0,0},%
{0,1,1,0,0}}}
letmymatrixcontentempty
defmymatrixcontent{|[draw=none]|& 1 & 2 & 3 & 4 & 5\}
begin{scope}[local bounding box=left]
foreach X in {1,...,5}
{node[Bullet,label=90+72-X*72:{$e_X$}] (EX) at (90+72-X*72:2) {} ;}
foreach X in {1,...,5}
{begingroupedefx{endgroup
noexpandgapptonoexpandmymatrixcontent{X }}x
foreach Y in {1,...,5}
{pgfmathtruncatemacro{itest}{adjancymatrix[X-1][Y-1]}
ifnumitest=1
draw (EX) -- (EY);
begingroupedefx{endgroup
noexpandgapptonoexpandmymatrixcontent{& 1 }}x
else
begingroupedefx{endgroup
noexpandgapptonoexpandmymatrixcontent{ &}}x
fi
}
gapptomymatrixcontent{\}
}
end{scope}
matrix (leftmat) [below=of left,adjacency matrix]{
mymatrixcontent
};
%
% second matrix
defadjancymatrix{%
{{0,1,0,0,1},%
{1,0,1,0,0},%
{0,1,0,1,0},%
{0,0,1,0,1},%
{1,0,0,1,0}}}
letmymatrixcontentempty
defmymatrixcontent{|[draw=none]|& 1 & 2 & 3 & 4 & 5\}
begin{scope}[local bounding box=middle,xshift=5cm]
foreach X in {1,...,5}
{node[Bullet,label=90+72-X*72:{$e_X$}] (EX) at (90+72-X*72:2) {} ;}
foreach X in {1,...,5}
{begingroupedefx{endgroup
noexpandgapptonoexpandmymatrixcontent{X }}x
foreach Y in {1,...,5}
{pgfmathtruncatemacro{itest}{adjancymatrix[X-1][Y-1]}
ifnumitest=1
draw (EX) -- (EY);
begingroupedefx{endgroup
noexpandgapptonoexpandmymatrixcontent{& 1 }}x
else
begingroupedefx{endgroup
noexpandgapptonoexpandmymatrixcontent{ &}}x
fi
}
gapptomymatrixcontent{\}
}
end{scope}
matrix (midmat) [below=of middle,adjacency matrix]{
mymatrixcontent
};
% third matrix
defadjancymatrix{%
{{0,1,0,1,0},%
{1,0,0,0,1},%
{0,0,0,1,1},%
{1,0,1,0,0},%
{0,1,1,0,0}}}
letmymatrixcontentempty
defmymatrixcontent{|[draw=none]|& 1 & 2 & 3 & 4 & 5\}
begin{scope}[local bounding box=right,xshift=10cm]
foreach X in {1,...,3}
{node[Bullet,label=90+72-X*72:{$e_X$}] (EX) at (90+72-X*72:2) {} ;}
node[Bullet,label=90+72-4*72:{$e_5$}] (E5) at (90+72-4*72:2) {} ;
node[Bullet,label=90+72-5*72:{$e_4$}] (E4) at (90+72-5*72:2) {} ;
foreach X in {1,...,5}
{begingroupedefx{endgroup
noexpandgapptonoexpandmymatrixcontent{X }}x
foreach Y in {1,...,5}
{pgfmathtruncatemacro{itest}{adjancymatrix[X-1][Y-1]}
ifnumitest=1
draw (EX) -- (EY);
begingroupedefx{endgroup
noexpandgapptonoexpandmymatrixcontent{& 1 }}x
else
begingroupedefx{endgroup
noexpandgapptonoexpandmymatrixcontent{ &}}x
fi
}
gapptomymatrixcontent{\}
}
end{scope}
matrix (rightmat) [below=of right,adjacency matrix]{
mymatrixcontent
};
end{tikzpicture}
end{document}
This is in case you change your mind and use the adjacency matrices to draw the graphs. TikZ allows you to define arrays, see p. 999 of the pgfmanual. And these arrays can be converted to tables using this nice answer. And these matrices/arrays can also be used to define the graphs.
documentclass[tikz,border=3.14mm]{standalone}
usepackage{etoolbox}
usetikzlibrary{matrix,positioning}
% building the table in a foreach loop from https://tex.stackexchange.com/a/60400/121799
begin{document}
begin{tikzpicture}[Bullet/.style={circle,draw,fill=black,inner sep=1.5pt},
adjacency matrix/.style={ampersand replacement=&,matrix of math nodes,
row 1/.append style={nodes={font=boldmath}},
column 1/.append style={nodes={font=boldmath}},nodes in empty cells,
nodes={draw,minimum width=1.5em,text height=1.8ex},column sep=-pgflinewidth,row
sep=-pgflinewidth}]
% first matrix
defadjancymatrix{%
{{0,0,1,1,0},%
{0,0,0,1,1},%
{1,0,0,0,1},%
{1,1,0,0,0},%
{0,1,1,0,0}}}
letmymatrixcontentempty
defmymatrixcontent{|[draw=none]|& 1 & 2 & 3 & 4 & 5\}
begin{scope}[local bounding box=left]
foreach X in {1,...,5}
{node[Bullet,label=90+72-X*72:{$e_X$}] (EX) at (90+72-X*72:2) {} ;}
foreach X in {1,...,5}
{begingroupedefx{endgroup
noexpandgapptonoexpandmymatrixcontent{X }}x
foreach Y in {1,...,5}
{pgfmathtruncatemacro{itest}{adjancymatrix[X-1][Y-1]}
ifnumitest=1
draw (EX) -- (EY);
begingroupedefx{endgroup
noexpandgapptonoexpandmymatrixcontent{& 1 }}x
else
begingroupedefx{endgroup
noexpandgapptonoexpandmymatrixcontent{ &}}x
fi
}
gapptomymatrixcontent{\}
}
end{scope}
matrix (leftmat) [below=of left,adjacency matrix]{
mymatrixcontent
};
%
% second matrix
defadjancymatrix{%
{{0,1,0,0,1},%
{1,0,1,0,0},%
{0,1,0,1,0},%
{0,0,1,0,1},%
{1,0,0,1,0}}}
letmymatrixcontentempty
defmymatrixcontent{|[draw=none]|& 1 & 2 & 3 & 4 & 5\}
begin{scope}[local bounding box=middle,xshift=5cm]
foreach X in {1,...,5}
{node[Bullet,label=90+72-X*72:{$e_X$}] (EX) at (90+72-X*72:2) {} ;}
foreach X in {1,...,5}
{begingroupedefx{endgroup
noexpandgapptonoexpandmymatrixcontent{X }}x
foreach Y in {1,...,5}
{pgfmathtruncatemacro{itest}{adjancymatrix[X-1][Y-1]}
ifnumitest=1
draw (EX) -- (EY);
begingroupedefx{endgroup
noexpandgapptonoexpandmymatrixcontent{& 1 }}x
else
begingroupedefx{endgroup
noexpandgapptonoexpandmymatrixcontent{ &}}x
fi
}
gapptomymatrixcontent{\}
}
end{scope}
matrix (midmat) [below=of middle,adjacency matrix]{
mymatrixcontent
};
% third matrix
defadjancymatrix{%
{{0,1,0,1,0},%
{1,0,0,0,1},%
{0,0,0,1,1},%
{1,0,1,0,0},%
{0,1,1,0,0}}}
letmymatrixcontentempty
defmymatrixcontent{|[draw=none]|& 1 & 2 & 3 & 4 & 5\}
begin{scope}[local bounding box=right,xshift=10cm]
foreach X in {1,...,3}
{node[Bullet,label=90+72-X*72:{$e_X$}] (EX) at (90+72-X*72:2) {} ;}
node[Bullet,label=90+72-4*72:{$e_5$}] (E5) at (90+72-4*72:2) {} ;
node[Bullet,label=90+72-5*72:{$e_4$}] (E4) at (90+72-5*72:2) {} ;
foreach X in {1,...,5}
{begingroupedefx{endgroup
noexpandgapptonoexpandmymatrixcontent{X }}x
foreach Y in {1,...,5}
{pgfmathtruncatemacro{itest}{adjancymatrix[X-1][Y-1]}
ifnumitest=1
draw (EX) -- (EY);
begingroupedefx{endgroup
noexpandgapptonoexpandmymatrixcontent{& 1 }}x
else
begingroupedefx{endgroup
noexpandgapptonoexpandmymatrixcontent{ &}}x
fi
}
gapptomymatrixcontent{\}
}
end{scope}
matrix (rightmat) [below=of right,adjacency matrix]{
mymatrixcontent
};
end{tikzpicture}
end{document}
edited 6 mins ago
answered 1 hour ago
marmotmarmot
111k5140264
111k5140264
Not bad, can we get the matrix lines drawn in or is it just like that
– tjt263
13 mins ago
@tjt263 Yes, sure.
– marmot
5 mins ago
add a comment |
Not bad, can we get the matrix lines drawn in or is it just like that
– tjt263
13 mins ago
@tjt263 Yes, sure.
– marmot
5 mins ago
Not bad, can we get the matrix lines drawn in or is it just like that
– tjt263
13 mins ago
Not bad, can we get the matrix lines drawn in or is it just like that
– tjt263
13 mins ago
@tjt263 Yes, sure.
– marmot
5 mins ago
@tjt263 Yes, sure.
– marmot
5 mins ago
add a comment |
Thanks for contributing an answer to TeX - LaTeX 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.
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%2ftex.stackexchange.com%2fquestions%2f481289%2fgenerating-adjacency-matrices-from-isomorphic-graphs%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
Shouldn't it be the other way around: you construct the diagrams from the adjacency matrices?
– marmot
2 hours ago
@marmot Probably, normally. Actually I don't think so. I mean.. Either way is probably good. But I have some graphs drawn up, and I want to draw the matrices to suit them. If I can't figure it out programmatically, I'll just draw them up separately. Either with LaTeX somehow or with Adobe Illustrator, or some spreadsheet/word processor. LaTeX would be nice though.
– tjt263
1 hour ago