Drawing a polygon











up vote
5
down vote

favorite












How to use the tikz package to achieve the following. I looked at but still couldn't get it done. Any help is much appreciated.



enter image description here










share|improve this question






















  • +1: Nice question and figure, though it's not really a polygon, I think
    – Dũng Vũ
    yesterday















up vote
5
down vote

favorite












How to use the tikz package to achieve the following. I looked at but still couldn't get it done. Any help is much appreciated.



enter image description here










share|improve this question






















  • +1: Nice question and figure, though it's not really a polygon, I think
    – Dũng Vũ
    yesterday













up vote
5
down vote

favorite









up vote
5
down vote

favorite











How to use the tikz package to achieve the following. I looked at but still couldn't get it done. Any help is much appreciated.



enter image description here










share|improve this question













How to use the tikz package to achieve the following. I looked at but still couldn't get it done. Any help is much appreciated.



enter image description here







tikz-graphdrawing tkz-graph






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked yesterday









Fib1123

37138




37138












  • +1: Nice question and figure, though it's not really a polygon, I think
    – Dũng Vũ
    yesterday


















  • +1: Nice question and figure, though it's not really a polygon, I think
    – Dũng Vũ
    yesterday
















+1: Nice question and figure, though it's not really a polygon, I think
– Dũng Vũ
yesterday




+1: Nice question and figure, though it's not really a polygon, I think
– Dũng Vũ
yesterday










1 Answer
1






active

oldest

votes

















up vote
3
down vote



accepted










There are many possible ways to draw this, here is one of them.



documentclass[tikz,border=3.14mm]{standalone}
usetikzlibrary{matrix,backgrounds}
begin{document}
begin{tikzpicture}
matrix[matrix of nodes,nodes={circle,draw,fill=white},column sep=3mm,row sep=3mm] (mat) { 2 & 7 & 6 \
9 & 5 & 1\
4 & 3 & 8\
};
foreach X in {1,2,3}
{foreach Y [evaluate=Y as Z using {int(10*X+Y)}]in {1,2,3}
{ifnumZ=22
else
draw (mat-X-Y) -- (mat-2-2);
fi}}
begin{scope}[on background layer]
draw (mat-3-1) rectangle (mat-1-3);
end{scope}
end{tikzpicture}
end{document}


enter image description here



Alternatively, if you do not want to fill the nodes, you could use



documentclass[tikz,border=3.14mm]{standalone}
usetikzlibrary{matrix}
begin{document}
begin{tikzpicture}
matrix[matrix of nodes,nodes={circle,draw},column sep=3mm,row sep=3mm] (mat) { 2 & 7 & 6 \
9 & 5 & 1\
4 & 3 & 8\
};
foreach X [count=XX starting from 0] in {1,2,3}
{foreach Y [evaluate=Y as Z using {int(10*X+Y)},count=YY starting from 0]in {1,2,3}
{ifnumZ=22
else
draw (mat-X-Y) -- (mat-2-2);
fi
ifnumX=1
else
draw (mat-XX-Y) -- (mat-X-Y);
fi
ifnumY=1
else
draw (mat-X-YY) -- (mat-X-Y);
fi
}}
end{tikzpicture}
end{document}





share|improve this answer























  • I see. Thank you.
    – Fib1123
    yesterday











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',
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%2ftex.stackexchange.com%2fquestions%2f460231%2fdrawing-a-polygon%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








up vote
3
down vote



accepted










There are many possible ways to draw this, here is one of them.



documentclass[tikz,border=3.14mm]{standalone}
usetikzlibrary{matrix,backgrounds}
begin{document}
begin{tikzpicture}
matrix[matrix of nodes,nodes={circle,draw,fill=white},column sep=3mm,row sep=3mm] (mat) { 2 & 7 & 6 \
9 & 5 & 1\
4 & 3 & 8\
};
foreach X in {1,2,3}
{foreach Y [evaluate=Y as Z using {int(10*X+Y)}]in {1,2,3}
{ifnumZ=22
else
draw (mat-X-Y) -- (mat-2-2);
fi}}
begin{scope}[on background layer]
draw (mat-3-1) rectangle (mat-1-3);
end{scope}
end{tikzpicture}
end{document}


enter image description here



Alternatively, if you do not want to fill the nodes, you could use



documentclass[tikz,border=3.14mm]{standalone}
usetikzlibrary{matrix}
begin{document}
begin{tikzpicture}
matrix[matrix of nodes,nodes={circle,draw},column sep=3mm,row sep=3mm] (mat) { 2 & 7 & 6 \
9 & 5 & 1\
4 & 3 & 8\
};
foreach X [count=XX starting from 0] in {1,2,3}
{foreach Y [evaluate=Y as Z using {int(10*X+Y)},count=YY starting from 0]in {1,2,3}
{ifnumZ=22
else
draw (mat-X-Y) -- (mat-2-2);
fi
ifnumX=1
else
draw (mat-XX-Y) -- (mat-X-Y);
fi
ifnumY=1
else
draw (mat-X-YY) -- (mat-X-Y);
fi
}}
end{tikzpicture}
end{document}





share|improve this answer























  • I see. Thank you.
    – Fib1123
    yesterday















up vote
3
down vote



accepted










There are many possible ways to draw this, here is one of them.



documentclass[tikz,border=3.14mm]{standalone}
usetikzlibrary{matrix,backgrounds}
begin{document}
begin{tikzpicture}
matrix[matrix of nodes,nodes={circle,draw,fill=white},column sep=3mm,row sep=3mm] (mat) { 2 & 7 & 6 \
9 & 5 & 1\
4 & 3 & 8\
};
foreach X in {1,2,3}
{foreach Y [evaluate=Y as Z using {int(10*X+Y)}]in {1,2,3}
{ifnumZ=22
else
draw (mat-X-Y) -- (mat-2-2);
fi}}
begin{scope}[on background layer]
draw (mat-3-1) rectangle (mat-1-3);
end{scope}
end{tikzpicture}
end{document}


enter image description here



Alternatively, if you do not want to fill the nodes, you could use



documentclass[tikz,border=3.14mm]{standalone}
usetikzlibrary{matrix}
begin{document}
begin{tikzpicture}
matrix[matrix of nodes,nodes={circle,draw},column sep=3mm,row sep=3mm] (mat) { 2 & 7 & 6 \
9 & 5 & 1\
4 & 3 & 8\
};
foreach X [count=XX starting from 0] in {1,2,3}
{foreach Y [evaluate=Y as Z using {int(10*X+Y)},count=YY starting from 0]in {1,2,3}
{ifnumZ=22
else
draw (mat-X-Y) -- (mat-2-2);
fi
ifnumX=1
else
draw (mat-XX-Y) -- (mat-X-Y);
fi
ifnumY=1
else
draw (mat-X-YY) -- (mat-X-Y);
fi
}}
end{tikzpicture}
end{document}





share|improve this answer























  • I see. Thank you.
    – Fib1123
    yesterday













up vote
3
down vote



accepted







up vote
3
down vote



accepted






There are many possible ways to draw this, here is one of them.



documentclass[tikz,border=3.14mm]{standalone}
usetikzlibrary{matrix,backgrounds}
begin{document}
begin{tikzpicture}
matrix[matrix of nodes,nodes={circle,draw,fill=white},column sep=3mm,row sep=3mm] (mat) { 2 & 7 & 6 \
9 & 5 & 1\
4 & 3 & 8\
};
foreach X in {1,2,3}
{foreach Y [evaluate=Y as Z using {int(10*X+Y)}]in {1,2,3}
{ifnumZ=22
else
draw (mat-X-Y) -- (mat-2-2);
fi}}
begin{scope}[on background layer]
draw (mat-3-1) rectangle (mat-1-3);
end{scope}
end{tikzpicture}
end{document}


enter image description here



Alternatively, if you do not want to fill the nodes, you could use



documentclass[tikz,border=3.14mm]{standalone}
usetikzlibrary{matrix}
begin{document}
begin{tikzpicture}
matrix[matrix of nodes,nodes={circle,draw},column sep=3mm,row sep=3mm] (mat) { 2 & 7 & 6 \
9 & 5 & 1\
4 & 3 & 8\
};
foreach X [count=XX starting from 0] in {1,2,3}
{foreach Y [evaluate=Y as Z using {int(10*X+Y)},count=YY starting from 0]in {1,2,3}
{ifnumZ=22
else
draw (mat-X-Y) -- (mat-2-2);
fi
ifnumX=1
else
draw (mat-XX-Y) -- (mat-X-Y);
fi
ifnumY=1
else
draw (mat-X-YY) -- (mat-X-Y);
fi
}}
end{tikzpicture}
end{document}





share|improve this answer














There are many possible ways to draw this, here is one of them.



documentclass[tikz,border=3.14mm]{standalone}
usetikzlibrary{matrix,backgrounds}
begin{document}
begin{tikzpicture}
matrix[matrix of nodes,nodes={circle,draw,fill=white},column sep=3mm,row sep=3mm] (mat) { 2 & 7 & 6 \
9 & 5 & 1\
4 & 3 & 8\
};
foreach X in {1,2,3}
{foreach Y [evaluate=Y as Z using {int(10*X+Y)}]in {1,2,3}
{ifnumZ=22
else
draw (mat-X-Y) -- (mat-2-2);
fi}}
begin{scope}[on background layer]
draw (mat-3-1) rectangle (mat-1-3);
end{scope}
end{tikzpicture}
end{document}


enter image description here



Alternatively, if you do not want to fill the nodes, you could use



documentclass[tikz,border=3.14mm]{standalone}
usetikzlibrary{matrix}
begin{document}
begin{tikzpicture}
matrix[matrix of nodes,nodes={circle,draw},column sep=3mm,row sep=3mm] (mat) { 2 & 7 & 6 \
9 & 5 & 1\
4 & 3 & 8\
};
foreach X [count=XX starting from 0] in {1,2,3}
{foreach Y [evaluate=Y as Z using {int(10*X+Y)},count=YY starting from 0]in {1,2,3}
{ifnumZ=22
else
draw (mat-X-Y) -- (mat-2-2);
fi
ifnumX=1
else
draw (mat-XX-Y) -- (mat-X-Y);
fi
ifnumY=1
else
draw (mat-X-YY) -- (mat-X-Y);
fi
}}
end{tikzpicture}
end{document}






share|improve this answer














share|improve this answer



share|improve this answer








edited yesterday

























answered yesterday









marmot

75.6k486160




75.6k486160












  • I see. Thank you.
    – Fib1123
    yesterday


















  • I see. Thank you.
    – Fib1123
    yesterday
















I see. Thank you.
– Fib1123
yesterday




I see. Thank you.
– Fib1123
yesterday


















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f460231%2fdrawing-a-polygon%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

Accessing regular linux commands in Huawei's Dopra Linux

Can't connect RFCOMM socket: Host is down

Kernel panic - not syncing: Fatal Exception in Interrupt