LyXProblems creating a graph (graph theory)

Information and discussion about LyX, a WYSIWYM editor, available for Linux, Windows and Mac OS X systems.
Post Reply
usr
Posts: 4
Joined: Wed Mar 09, 2011 1:17 pm

Problems creating a graph (graph theory)

Post by usr »

Hi,

I wanted to create a graph (with some nodes and edges), xy-pic can do so. The xy-pic-documentation explains in chapter 3.2 how to do so: You create for example a 3*3-matrix with a U-node in the first column/first row and a Y-node in the 3rd row/2nd column. If you want to make an arrow from U to Y write down

Code: Select all

U\ar[ddr]
instead of only

Code: Select all

U
in the first column/first row(that means: "start an arrow at U which ends two times down and one on the right, therefore [ddr]" (where the Y is written).

But if I put the cursor somewhere else there is a problem. Instead of the arrow from U to Y I see U-!Ch!Ch!>[ddr] on the left and top of the matrix.

The strange thing is that I only reproduced the given example but it doesn't work when I write it down by myself. What has happened here?

Thanks!
usr
(Lyx 1.6.9)

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

d60pmp
Posts: 17
Joined: Wed Mar 09, 2011 1:54 pm

Problems creating a graph (graph theory)

Post by d60pmp »

Perhaps this is unhelpful, but try Graphviz.
http://en.wikipedia.org/wiki/Graphviz
usr
Posts: 4
Joined: Wed Mar 09, 2011 1:17 pm

Re: Problems creating a graph (graph theory)

Post by usr »

Thanks.

I would prefer a lyx-tool so that I can see the graph before I make the PDF. But if that is not possible, I will try that.

Has anyone an idea about the problem with xy-pic. Can you reproduce that problem?

Thanks!
usr
usr
Posts: 4
Joined: Wed Mar 09, 2011 1:17 pm

Problems creating a graph (graph theory)

Post by usr »

Now I think I got it.

Code: Select all

\xymatrix{U\ar@{{-}}[ddr]\\&XY&X\\&Y&Z}
is the code to solve the problem.

I think I made a mistake:
When lyx wants to create graphs you have to create a special matrix before (with

Code: Select all

\xymatrix
) and not those who are created when you take the matrix button (which creates a matrix type called "array"). To see the difference watch the source code.

So you can solve the problem when you type the code at first as written above and then put it into the mathematics mode. (I still don't really understand how to navigate between those xy-matrix elements so I prefer to code all at once and then take the mathematics mode.)

The option

Code: Select all

{{-}}
in the above code has the effect that the arcs are shown as undirected edges.

Thank you!
d60pmp
Posts: 17
Joined: Wed Mar 09, 2011 1:54 pm

Problems creating a graph (graph theory)

Post by d60pmp »

Yep, was just about to post saying the same thing:

Code: Select all

%WORKS
$\xymatrix{A\ar[dr] & B\\
C & D}$

%DOESN'T WORK
$\begin{array}{cc}
A\ar[dr] & B\\
C & D\end{array}$
If you need more detail check out Help -> Specific Manuals -> XY-pic Manual

It's a nice package, I'll probably be using it to draw some more LaTeXy neural networks for my dissertation.

Edit: I'd say that was problem solved, don't forget to stick a tick on the icon.
Post Reply