[Tex/LaTex] draw the graphs (graph theory) with TikZ online

diagramsgraphics

I have a problem, I'm a master student, and I'm writing my thesis (graph theory) in LaTeX.

Can anyone help me to find an online website to draw graphs and then insert the code in LaTeX online?

Best Answer

Here is an example of using the igraph package in R and embedding the result in a pdf file using knitr and pdflatex. Depending upon your operating system and setup the actual workflow details may vary.

In general, 1) create the latex file with the embedded R commands. Save this with the extension *.Rnw (case sensitive) 2) now use R to run the knit command on this *.Rnw file. You will not get an *.tex file with the same base name as the original *.Rnw file. 3) Run pdflatex and then view the *.pdf file.

Here is an example source file (extracted from http://www.r-graph-gallery.com/247-network-chart-layouts/).

\documentclass[10pt,letterpaper]{article}
\begin{document}
Demo of Graph Theory using R and Tikz
<<>>=
# library
library(igraph)

# Create data
data=matrix(sample(0:1, 400, replace=TRUE, prob=c(0.8,0.2)), nrow=20)
network=graph_from_adjacency_matrix(data , mode='undirected', diag=F )

# When ploting, we can use different layouts:
par(mfrow=c(2,2), mar=c(1,1,1,1))
plot(network, layout=layout.sphere, main="sphere")
plot(network, layout=layout.circle, main="circle")
plot(network, layout=layout.random, main="random")
plot(network, layout=layout.fruchterman.reingold, main="fruchterman.reingold")
@
\end{document}

And results in

enter image description here