I think you're trying to use graphdrawing
when you actually should be using the normal graph
instead. The graphdrawing
library is for when you have stuff that follows a structural logic but the graph itself is not of a fixed nature. Quoting Till Tantau:
You do not specify where, exactly, the nodes and edges should be. This is something you leave to a graph drawing algorithm. The algorithm gets your description of the graph as an input and then decides where the nodes should go
on the page.
The graph you're proposing, to me, looks like you want to specify where the nodes are, but you want to do it in a concise and powerful way. Quoting Till again:
There is nothing in the graph
library that you cannot do using the normal \node
and the edge commands. Rather, its purpose is to offer a concise and powerful way of specifying which nodes are present and how they are connected.
Here it is how you draw your graph using the graph
library (no need for Lua):
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{graphs, graphs.standard, quotes}% quotes library is for the [""] edges
\begin{document}
\begin{tikzpicture}[node distance = {1.0cm and 1.5cm}, v/.style = {draw, circle}]
\graph[nodes={circle, draw}, grow right=2.25cm, branch down=1.75cm]{
A -- ["1"] C -- ["3"] E,
B -- ["1",swap] D -- ["4",swap] F,
B -- ["2"] A,
C -- ["2"] {D,B},
D -- ["3",swap] E -- ["1"] F
};
\end{tikzpicture}
\end{document}
Best Answer
You could also use PGFPlots for plotting your function and the integral. The trapeziums can be generated by plotting the function twice with a low sampling frequency: Once using the
ycomb
style for the vertical lines, and once using the defaultsharp plot
for the connecting lines.If you need to do this for several plot, you can define some styles to make it easier to keep everything consistent. That way, you can get the following image
using the following code:
Here's the complete document with all the styles:
In case you're not using the newest version of PGFPlots (1.8), the
set layers
andon axis
keys will not be defined. In that case, you can remove those keys and rearrange the\addplot
command to make sure everything's drawn in the right order: