Skip to content

Commit

Permalink
goodbye tikz images; hello png; closes #93
Browse files Browse the repository at this point in the history
  • Loading branch information
mpadge committed Oct 1, 2019
1 parent 5af9d8f commit 66c9490
Show file tree
Hide file tree
Showing 9 changed files with 180 additions and 139 deletions.
6 changes: 2 additions & 4 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@
^CONTRIBUTING\.md$
^cran-comments.md$
^vignettes/makefile$
^vignettes/bencharm_data.rds$
^vignettes/bencharm.Rmd$
docs/
data-raw/
tests/valgrind-script.R$
tests/valgrind-test.R$
^tests/valgrind-script.R$
^tests/valgrind-test.R$
^_pkgdown\.yml$
^appveyor\.yml$
^.*\.Rproj$
Expand Down
23 changes: 4 additions & 19 deletions vignettes/dodgr.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ output:
toc_float: true
number_sections: false
theme: flatly
header-includes:
- \usepackage{tikz}
- \usetikzlibrary{arrows}
vignette: >
%\VignetteIndexEntry{1 dodgr}
%\VignetteEngine{knitr::rmarkdown}
Expand All @@ -34,13 +31,8 @@ A. In Fig. 1, for example, the weights between the graph vertices (A, B, C, and
D) differ depending on the direction of travel, and it is only possible to
traverse the entire graph in an anti-clockwise direction.

```{r fig1, fig.align="center", echo=FALSE, engine='tikz',fig.ext='svg', code=readLines("fig1.tex"), fig.cap="Figure 1: A weighted, directed graph"}
```
(Note that this image does not currently render on the github-hosted version of
this site, for reasons currently [beyond our
control](https://github.com/ATFutures/dodgr/issues/93); a properly rendered
version can be seen on the equivalent [CRAN
vignette](https://cran.r-project.org/package=dodgr/vignettes/dodgr.html).)
![](fig1.png)


Graphs in `dodgr` are represented by simple flat `data.frame` objects, so the
graph of Fig. 1, presuming the edge weights to take values of 1, 2, and 3, would
Expand Down Expand Up @@ -69,13 +61,7 @@ other **R** packages, such as
through its ability to trace paths through *dual-weighted* directed graphs,
illustrated in Fig. 2.

```{r fig2, fig.align="center", echo=FALSE, engine='tikz',fig.ext='svg', code=readLines("fig2.tex"), fig.cap="Figure 2: A **dual**-weighted, directed graph in which the weights (represented by thicknesses) of the grey arrows differ from those of the black arrows."}
```
(As above, this image also does not currently render on the github-hosted
version of this site, for reasons currently [beyond our
control](https://github.com/ATFutures/dodgr/issues/93); a properly rendered
version can be seen on the equivalent [CRAN
vignette](https://cran.r-project.org/package=dodgr/vignettes/dodgr.html).)
![](fig2.png)

Dual-weighted directed graphs are common in many areas, a foremost example
being routing through street networks. Routes through street networks depends on
Expand Down Expand Up @@ -550,8 +536,7 @@ d <- igraph::distances (igr, v = pts, to = pts, mode = "out")
A further unique feature of `dodgr` is the ability to remove redundant vertices
from graphs (see Fig. 3), thereby speeding up routing calculations.

```{r fig3, fig.align="center", echo=FALSE, engine='tikz',fig.ext='svg', code=readLines("fig3.tex"), fig.cap="Figure 3: **(A)** Vertex#2 is redundant for routing calculations from anywhere other than that point itself. (**B**) Equivalent graph to (**A**) contracted through removal of vertex#2. (**C**) Vertex#2 is not redundant."}
```
![](fig3.png)

In Fig. 3(A), the only way to get from vertex 1 to 3, 4 or 5 is through C. The
intermediate vertex B is redundant for routing purposes (and than to or from
Expand Down
Binary file added vignettes/fig1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
47 changes: 28 additions & 19 deletions vignettes/fig1.tex
Original file line number Diff line number Diff line change
@@ -1,22 +1,31 @@
\begin{tikzpicture}[font=\tiny]
\tikzstyle{node_style} = [draw=white, very thick, circle, fill=orange]
\tikzstyle{arrow_style1} = [->, black, line width=1, >=latex]
\tikzstyle{arrow_style2} = [->, black, line width=2, >=latex]
\tikzstyle{arrow_style3} = [->, black, line width=3, >=latex]
\tikzstyle{edge_style2} = [lightgray, line width=1]
%\documentclass[tikz,convert={outfile=\jobname.svg},border=5pt]{standalone}
\documentclass[tikz,border=5pt]{standalone}
\usepackage[utf8x]{inputenc}
% To create the .png:
% > pdflatex fig1.tex
% > convert -density 300 fig1.pdf -quality 100 fig1.png

\begin{document}
\begin{tikzpicture}[font=\tiny]
\tikzstyle{node_style} = [draw=white, very thick, circle, fill=orange]
\tikzstyle{arrow_style1} = [->, black, line width=1, >=latex]
\tikzstyle{arrow_style2} = [->, black, line width=2, >=latex]
\tikzstyle{arrow_style3} = [->, black, line width=3, >=latex]

\node[node_style] (n1) at (0,0) {A};
\node[node_style] (n2) at (4,0) {B};
\node[node_style] (n3) at (4,2) {C};
\node[node_style] (n4) at (0,2) {D};

\draw[arrow_style1] (n1) edge [bend left=20] (n2);
\draw[arrow_style2] (n2) edge [bend left=20] (n1);
\draw[arrow_style1] (n2) edge [bend left=20] (n3);
\draw[arrow_style2] (n3) edge [bend left=20] (n2);
\draw[arrow_style1] (n3) edge [bend left=20] (n4);
\draw[arrow_style2] (n4) edge [bend left=20] (n3);
\draw[arrow_style1] (n4) edge (n1);
\draw[arrow_style3, shorten <=2pt, shorten >=2pt] (n2) edge [out=140, in=-60] (n4);
\end{tikzpicture}
\node[node_style] (n1) at (0,0) {A};
\node[node_style] (n2) at (4,0) {B};
\node[node_style] (n3) at (4,2) {C};
\node[node_style] (n4) at (0,2) {D};

\draw[arrow_style1] (n1) edge [bend left=20] (n2);
\draw[arrow_style2] (n2) edge [bend left=20] (n1);
\draw[arrow_style1] (n2) edge [bend left=20] (n3);
\draw[arrow_style2] (n3) edge [bend left=20] (n2);
\draw[arrow_style1] (n3) edge [bend left=20] (n4);
\draw[arrow_style2] (n4) edge [bend left=20] (n3);
\draw[arrow_style1] (n4) edge (n1);
\draw[arrow_style3, shorten <=2pt, shorten >=2pt] (n2) edge [out=140, in=-60] (n4);
\end{tikzpicture}

\end{document}
Binary file added vignettes/fig2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
89 changes: 48 additions & 41 deletions vignettes/fig2.tex
Original file line number Diff line number Diff line change
@@ -1,41 +1,48 @@
\begin{tikzpicture}[font=\tiny, >=latex, shorten >=5pt, shorten <=5pt]
\tikzstyle{nonode} = []
\tikzstyle{node_style} = [draw=white, very thick, circle, fill=orange]
\tikzstyle{black_arrow1} = [->, black, line width=1]
\tikzstyle{black_arrow2} = [->, black, line width=2]
\tikzstyle{black_arrow3} = [->, black, line width=3]
\tikzstyle{grey_arrow} = [->, lightgray, dashed, line width=1]

\node[nonode] (nAd) at (0,-0.1) {};
\node[nonode] (nAl) at (-0.1,0) {};
\node[nonode] (nBd) at (4,-0.1) {};
\node[nonode] (nBr) at (4.1,0) {};
\node[nonode] (nCd) at (4,1.9) {};
\node[nonode] (nCr) at (4.1,2) {};
\node[nonode] (nDd) at (0,1.9) {};
\node[nonode] (nDl) at (-0.1,2) {};

\draw[grey_arrow] (nAd) edge [bend left=10] (nBd);
\draw[grey_arrow] (nBd) edge [bend left=10] (nAd);
\draw[grey_arrow] (nBr) edge [bend left=10] (nCr);
\draw[grey_arrow] (nCr) edge [bend left=10] (nBr);
\draw[grey_arrow] (nCd) edge [bend left=10] (nDd);
\draw[grey_arrow] (nDd) edge [bend left=10] (nCd);
\draw[grey_arrow] (nDl) edge [bend right=10] (nAl);
\draw[grey_arrow] (nBd) edge [out=120, in=-40] (nDl);

\node[node_style] (nA) at (0,0) {A};
\node[node_style] (nB) at (4,0) {B};
\node[node_style] (nC) at (4,2) {C};
\node[node_style] (nD) at (0,2) {D};

\draw[black_arrow1] (nA) edge [bend left=10] (nB);
\draw[black_arrow2] (nB) edge [bend left=10] (nA);
\draw[black_arrow1] (nB) edge [bend left=10] (nC);
\draw[black_arrow2] (nC) edge [bend left=10] (nB);
\draw[black_arrow1] (nC) edge [bend left=10] (nD);
\draw[black_arrow2] (nD) edge [bend left=10] (nC);
\draw[black_arrow1] (nD) edge (nA);

\draw[black_arrow3, shorten <=2pt, shorten >=2pt] (nB) edge [out=140, in=-60] (nD);
\end{tikzpicture}
\documentclass[tikz,border=5pt]{standalone}
\usepackage[utf8x]{inputenc}

\begin{document}

\begin{tikzpicture}[font=\tiny, >=latex, shorten >=5pt, shorten <=5pt]
\tikzstyle{nonode} = []
\tikzstyle{node_style} = [draw=white, very thick, circle, fill=orange]
\tikzstyle{black_arrow1} = [->, black, line width=1]
\tikzstyle{black_arrow2} = [->, black, line width=2]
\tikzstyle{black_arrow3} = [->, black, line width=3]
\tikzstyle{grey_arrow} = [->, black!50, dashed, line width=1]

\node[nonode] (nAd) at (0,-0.1) {};
\node[nonode] (nAl) at (-0.1,0) {};
\node[nonode] (nBd) at (4,-0.1) {};
\node[nonode] (nBr) at (4.1,0) {};
\node[nonode] (nCd) at (4,1.9) {};
\node[nonode] (nCr) at (4.1,2) {};
\node[nonode] (nDd) at (0,1.9) {};
\node[nonode] (nDl) at (-0.1,2) {};

\draw[grey_arrow] (nAd) edge [bend left=10] (nBd);
\draw[grey_arrow] (nBd) edge [bend left=10] (nAd);
\draw[grey_arrow] (nBr) edge [bend left=10] (nCr);
\draw[grey_arrow] (nCr) edge [bend left=10] (nBr);
\draw[grey_arrow] (nCd) edge [bend left=10] (nDd);
\draw[grey_arrow] (nDd) edge [bend left=10] (nCd);
\draw[grey_arrow] (nDl) edge [bend right=10] (nAl);
\draw[grey_arrow] (nBd) edge [out=120, in=-40] (nDl);

\node[node_style] (nA) at (0,0) {A};
\node[node_style] (nB) at (4,0) {B};
\node[node_style] (nC) at (4,2) {C};
\node[node_style] (nD) at (0,2) {D};

\draw[black_arrow1] (nA) edge [bend left=10] (nB);
\draw[black_arrow2] (nB) edge [bend left=10] (nA);
\draw[black_arrow1] (nB) edge [bend left=10] (nC);
\draw[black_arrow2] (nC) edge [bend left=10] (nB);
\draw[black_arrow1] (nC) edge [bend left=10] (nD);
\draw[black_arrow2] (nD) edge [bend left=10] (nC);
\draw[black_arrow1] (nD) edge (nA);

\draw[black_arrow3, shorten <=2pt, shorten >=2pt] (nB) edge [out=140, in=-60] (nD);
\end{tikzpicture}

\end{document}
Binary file added vignettes/fig3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
119 changes: 63 additions & 56 deletions vignettes/fig3.tex
Original file line number Diff line number Diff line change
@@ -1,56 +1,63 @@
\begin{tikzpicture}[scale=3]
\tikzstyle{node_style} = [thick, circle, fill=orange]
\tikzstyle{arrow_style1} = [->, black, line width=1, >=latex]

% This is (C) at the top
\node[node_style] (n21) at (0,3) {1};
\node[node_style] (n22) at (1,2.75) {2};
\node[node_style] (n23) at (2,2.5) {3};
\node[node_style] (n24) at (2.5,3) {4};
\node[node_style] (n25) at (2.5,2) {5};

\draw[arrow_style1] (n21) edge [bend left=10] (n22);
\draw[arrow_style1] (n22) edge [bend left=10] (n21);
\draw[arrow_style1] (n22) edge [bend left=10] (n23);
\draw[arrow_style1] (n23) edge [bend left=10] (n22);
\draw[arrow_style1] (n23) edge [bend left=10] (n24);
\draw[arrow_style1] (n24) edge [bend left=20] (n23);
\draw[arrow_style1] (n23) edge [bend left=10] (n25);
\draw[arrow_style1] (n25) edge [bend left=20] (n23);

% Then (B) in the middle
\node[node_style] (n1) at (1,2) {1};
%\node[node_style] (n2) at (2,1.75) {2};
\node[node_style] (n3) at (3,1.5) {3};
\node[node_style] (n4) at (3.5,2) {4};
\node[node_style] (n5) at (3.5,1) {5};

\draw[arrow_style1] (n1) edge [bend left=10] (n3);
\draw[arrow_style1] (n3) edge [bend left=10] (n1);
%\draw[arrow_style1] (n2) edge [bend left=10] (n3);
%\draw[arrow_style1] (n3) edge [bend left=10] (n2);
\draw[arrow_style1] (n3) edge [bend left=10] (n4);
\draw[arrow_style1] (n4) edge [bend left=20] (n3);
\draw[arrow_style1] (n3) edge [bend left=10] (n5);
\draw[arrow_style1] (n5) edge [bend left=20] (n3);

% Then (A) at the bottom
\node[node_style] (n11) at (0,1) {1};
\node[node_style] (n12) at (1,0.75) {2};
\node[node_style] (n13) at (2,0.5) {3};
\node[node_style] (n14) at (2.5,1) {4};
\node[node_style] (n15) at (2.5,0) {5};

\draw[arrow_style1] (n11) edge [bend left=10] (n12);
\draw[arrow_style1] (n12) edge [bend left=10] (n11);
\draw[arrow_style1] (n12) edge [bend left=10] (n13);
%\draw[arrow_style1] (n13) edge [bend left=10] (n12);
\draw[arrow_style1] (n13) edge [bend left=10] (n14);
\draw[arrow_style1] (n14) edge [bend left=20] (n13);
\draw[arrow_style1] (n13) edge [bend left=10] (n15);
\draw[arrow_style1] (n15) edge [bend left=20] (n13);

\node at (4, 2.5) {\bf\LARGE (A)};
\node at (4, 1.5) {\bf\LARGE (B)};
\node at (4, 0.5) {\bf\LARGE (C)};
\end{tikzpicture}
\documentclass[tikz,border=5pt]{standalone}
\usepackage[utf8x]{inputenc}

\begin{document}

\begin{tikzpicture}[scale=3]
\tikzstyle{node_style} = [thick, circle, fill=orange]
\tikzstyle{arrow_style1} = [->, black, line width=1, >=latex]

% This is (C) at the top
\node[node_style] (n21) at (0,3) {1};
\node[node_style] (n22) at (1,2.75) {2};
\node[node_style] (n23) at (2,2.5) {3};
\node[node_style] (n24) at (2.5,3) {4};
\node[node_style] (n25) at (2.5,2) {5};

\draw[arrow_style1] (n21) edge [bend left=10] (n22);
\draw[arrow_style1] (n22) edge [bend left=10] (n21);
\draw[arrow_style1] (n22) edge [bend left=10] (n23);
\draw[arrow_style1] (n23) edge [bend left=10] (n22);
\draw[arrow_style1] (n23) edge [bend left=10] (n24);
\draw[arrow_style1] (n24) edge [bend left=20] (n23);
\draw[arrow_style1] (n23) edge [bend left=10] (n25);
\draw[arrow_style1] (n25) edge [bend left=20] (n23);

% Then (B) in the middle
\node[node_style] (n1) at (1,2) {1};
%\node[node_style] (n2) at (2,1.75) {2};
\node[node_style] (n3) at (3,1.5) {3};
\node[node_style] (n4) at (3.5,2) {4};
\node[node_style] (n5) at (3.5,1) {5};

\draw[arrow_style1] (n1) edge [bend left=10] (n3);
\draw[arrow_style1] (n3) edge [bend left=10] (n1);
%\draw[arrow_style1] (n2) edge [bend left=10] (n3);
%\draw[arrow_style1] (n3) edge [bend left=10] (n2);
\draw[arrow_style1] (n3) edge [bend left=10] (n4);
\draw[arrow_style1] (n4) edge [bend left=20] (n3);
\draw[arrow_style1] (n3) edge [bend left=10] (n5);
\draw[arrow_style1] (n5) edge [bend left=20] (n3);

% Then (A) at the bottom
\node[node_style] (n11) at (0,1) {1};
\node[node_style] (n12) at (1,0.75) {2};
\node[node_style] (n13) at (2,0.5) {3};
\node[node_style] (n14) at (2.5,1) {4};
\node[node_style] (n15) at (2.5,0) {5};

\draw[arrow_style1] (n11) edge [bend left=10] (n12);
\draw[arrow_style1] (n12) edge [bend left=10] (n11);
\draw[arrow_style1] (n12) edge [bend left=10] (n13);
%\draw[arrow_style1] (n13) edge [bend left=10] (n12);
\draw[arrow_style1] (n13) edge [bend left=10] (n14);
\draw[arrow_style1] (n14) edge [bend left=20] (n13);
\draw[arrow_style1] (n13) edge [bend left=10] (n15);
\draw[arrow_style1] (n15) edge [bend left=20] (n13);

\node at (4, 2.5) {\bf\LARGE (A)};
\node at (4, 1.5) {\bf\LARGE (B)};
\node at (4, 0.5) {\bf\LARGE (C)};
\end{tikzpicture}

\end{document}
35 changes: 35 additions & 0 deletions vignettes/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,38 @@ open: $(LFILE).html

clean:
rm -rf *.html *.png



fig1: pdflone convone rmone

pdflone: fig1.tex
pdflatex fig1.tex

convone: fig1.pdf
convert -density 300 fig1.pdf -quality 100 fig1.png

rmone:
rm fig1.aux fig1.log fig1.pdf

fig2: pdfltwo convtwo rmtwo

pdfltwo: fig2.tex
pdflatex fig2.tex

convtwo: fig2.pdf
convert -density 300 fig2.pdf -quality 100 fig2.png

rmtwo:
rm fig2.aux fig2.log fig2.pdf

fig3: pdflthree convthree rmthree

pdflthree: fig3.tex
pdflatex fig3.tex

convthree: fig3.pdf
convert -density 300 fig3.pdf -quality 100 fig3.png

rmthree:
rm fig3.aux fig3.log fig3.pdf

0 comments on commit 66c9490

Please sign in to comment.