File:Adjacencylist array of linkedlists directedgraph.svg
Original file (SVG file, nominally 200 × 125 pixels, file size: 22 KB)
Captions
Summary
[edit]DescriptionAdjacencylist array of linkedlists directedgraph.svg |
Deutsch: Adjazenzlisten des gerichteten Graphen in implementiert mit einem knotenindizierten Array und einfach verketteten Listen.
English: Adjacencylist of a digraph implemented as array of linked lists.
Created using the tikz package and compiled with pdflatex. \documentclass{standalone}
\usepackage{ifthen}
\usepackage{tikz}
\usetikzlibrary{positioning,calc,shapes.multipart,arrows}
\tikzstyle{pointer}=[fill=black, circle, minimum width = 3pt, inner sep=0]
\tikzstyle{link}=[>=stealth]
\tikzstyle{array}=[draw, fill=green!40, minimum width = 7mm, minimum height = 7mm]
\tikzstyle{list_node_horizontal}=[draw, rectangle split, rectangle split parts=2, rectangle split horizontal,
rounded corners=2pt,minimum height=5mm, minimum width=10mm, node distance=5mm,fill=red!35]
\tikzstyle{nil}=[draw, rectangle,minimum height=4mm, minimum width=4mm, node distance=5mm]
\def\Adjacencylist#1{%
% Draw Adjacency List
\foreach [count=\j] \element in \adlist {
% a counter the refers to the previous node
\prevnode=\j
\advance\prevnode by -1
% draw the node from the list with a pointer
\node[list_node_horizontal,right = of node\the\prevnode] (node\j) {\element};
\path[-] let \p1 = (node\j.two), \p2 = (node\j.center) in
node[pointer] (rightpointer\j) at (\x1+2,\y2){};
%draw incomming link from previous node
\draw[link,->] (rightpointer\the\prevnode) edge (node\j);
}
% Draw nil pointer
\node[nil, right = of rightpointer\j] (rightnil) {};
\draw (rightnil.north east) -- (rightnil.south west);
\draw (rightnil.north west) -- (rightnil.south east);
% Draw edge to nil pointer node
\path [link,->] (rightpointer\j) edge (rightnil);
}
\newcount\prevnode
\begin{document}
% Define graph as a list of pairs, where each pair consists of a node, the delimiter "/" and the set of adjacent nodes.
\newcommand{\inputgraph}{a/{b,d,e}, b/{c}, c/{d}, d/{a}, e/{}}
% Draw array and adjacency lists
\begin{tikzpicture}
\foreach [count=\i] \index/\adlist in \inputgraph {
\node[array] (rightpointer0) at (0,-\i*0.7) {\index};
\coordinate (node0) at (0.4,-\i*0.7);
\Adjacencylist{\adlist}
}
\end{tikzpicture}
\end{document}
|
Date | |
Source | Own work |
Author | Wdvorak |
Licensing
[edit]This file is made available under the Creative Commons CC0 1.0 Universal Public Domain Dedication. | |
The person who associated a work with this deed has dedicated the work to the public domain by waiving all of their rights to the work worldwide under copyright law, including all related and neighboring rights, to the extent allowed by law. You can copy, modify, distribute and perform the work, even for commercial purposes, all without asking permission.
http://creativecommons.org/publicdomain/zero/1.0/deed.enCC0Creative Commons Zero, Public Domain Dedicationfalsefalse |
File history
Click on a date/time to view the file as it appeared at that time.
Date/Time | Thumbnail | Dimensions | User | Comment | |
---|---|---|---|---|---|
current | 21:45, 28 July 2015 | 200 × 125 (22 KB) | Wdvorak (talk | contribs) | User created page with UploadWizard |
You cannot overwrite this file.
File usage on Commons
The following page uses this file:
File usage on other wikis
The following other wikis use this file:
- Usage on de.wikipedia.org
Metadata
This file contains additional information such as Exif metadata which may have been added by the digital camera, scanner, or software program used to create or digitize it. If the file has been modified from its original state, some details such as the timestamp may not fully reflect those of the original file. The timestamp is only as accurate as the clock in the camera, and it may be completely wrong.
Width | 159.889pt |
---|---|
Height | 99.611pt |