Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Draw an adjacency-list representation of a graph with tikz

912 views
Skip to first unread message

romildo

unread,
Aug 25, 2010, 3:23:23 PM8/25/10
to
Hello.

I would like to draw the adjacency-list representation of a graph
using tikz, but I do not master it yet.

The picture should look like the one found at
http://www.iceb.ufop.br/decom/prof/romildo/misc/adjacency-list.jpg

Any help?

Romildo

Merciadri Luca

unread,
Aug 26, 2010, 1:57:40 PM8/26/10
to
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

romildo <j.ro...@gmail.com> writes:

Are you sure that this is possible (i.e. already implemented)?

- --
Merciadri Luca
See http://www.student.montefiore.ulg.ac.be/~merciadri/
- --

It is better to die on one's feet than live on one's knees.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Processed by Mailcrypt 3.5.8 <http://mailcrypt.sourceforge.net/>

iEYEARECAAYFAkx2qxQACgkQM0LLzLt8Mhx18QCghCRlS/Vrr9ImIqxQHZK65jP2
OCUAni0slSwhqrv/Y3P85E91tEdG7PvN
=tAVV
-----END PGP SIGNATURE-----

Ignasi Furio

unread,
Sep 2, 2010, 7:23:52 AM9/2/10
to
On Aug 25, 9:23 pm, romildo <j.romi...@gmail.com> wrote:

Try this:

%------------------------
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\setlength{\PreviewBorder}{5mm}
\pagestyle{empty}

\begin{document}
\thispagestyle{empty}
\begin{tikzpicture}
\matrix (M) [matrix of nodes,
column sep=0pt,
row sep=0pt,
nodes={draw,fill=gray!20,minimum width=.5cm,outer sep=0pt,minimum
height=.7cm,anchor=center},
column 1/.style={minimum height=.8cm}]{
\mbox{} &[2mm] 2 & \mbox{} &[2mm] 5 & $/$ &[2mm] & &[2mm] & \\
\mbox{} & 1 & \mbox{} & 5 & \mbox{} & 3 & \mbox{} & 4 & $/$ \\
\mbox{} & 2 & \mbox{} & 4 & $/$ & & & & \\
\mbox{} & 2 & \mbox{} & 5 & \mbox{} & 3 & $/$ & & \\
\mbox{} & 4 & \mbox{} & 1 & \mbox{} & 2 & $/$ & & \\
};
\foreach \i in {1,2,3,4,5}{
\path (M-\i-1) [late options={label=left:\i}];
\draw[->] (M-\i-1.center)--(M-\i-2.west);
\draw[->] (M-\i-3.center)--(M-\i-4.west);
}
\draw[->] (M-2-5.center)--(M-2-6.west);
\draw[->] (M-4-5.center)--(M-4-6.west);
\draw[->] (M-5-5.center)--(M-5-6.west);
\draw[->] (M-2-7.center)--(M-2-8.west);
\end{tikzpicture}
\end{document}
%-------------------------

Ignasi

0 new messages