I am using the package xy
to draw simple Graphs or Networks. It allows oriented and non oriented edges and even weights on the edges, but the code is very complicated and it is very difficult to build bigger examples than the ones shown bellow.
Does anybody know another way to do this (a simple way)?
An example of the code I currently use:
\begin{figure}
\centering
\begin{minipage}{0.4\textwidth}
\centering
\[
\xymatrix{
\xy*{1}*\cir<6pt>{}\endxy\ar@{->}[r] & \xy*{2}*\cir<6pt>{}\endxy\ar@{->}[d] \\
\xy*{4}*\cir<6pt>{}\endxy\ar@{->}[ur]\ar@{->}@/_/[r]\ar@{->}[u] & \xy*{3}*\cir<6pt>{}\endxy\ar@{->}[lu]\ar@{->}@/_/[l]
}
\]
\end{minipage}
%\hfill
\begin{minipage}{0.4\textwidth}
\centering
\[
\xymatrix{
\xy*{1}*\cir<6pt>{}\endxy\ar@{-}[r] & \xy*{2}*\cir<6pt>{}\endxy\ar@{-}[d] \\
\xy*{4}*\cir<6pt>{}\endxy\ar@{-}[ur]\ar@{-}[r]\ar@{-}[u] & \xy*{3}*\cir<6pt>{}\endxy\ar@{-}[lu]
}
\]
\end{minipage}
\label{fig:graphExample}
\end{figure}
The result is:
Best Answer
Something like this via
tikz
. First define a style filem
for all nodes and allocate the position of node 1 with an(internal)
and{external label}
and the remaining nodes can be allocated by using the relative position commandsright/left/above/below = xx cm of <node 1>
in the option. After that use\draw[m,->] (< node 1 >) -- (< node 2 >);
for curve lines use
(a) to [bend right/left, out=<ang1>, in=<ang2>] (b)
Code