Need to create a simple diagram

I thought I had a simple requirement for this, but it almost seems like you have to write a program to do anything. I have a set of nodes that connect, but I don't know the best X/Y coordinates to assign so the result is easily readable. Is GraphViz the way to go here? I figured this program would offer a simple solution, but I don't even know where to begin.

Update, no luck

I tried it, but it's generating an empty png file.  Looks like I can't attach a file, so the text of the GV file is below if that helps.  Syntax or something?  Thanks.

InternationalChemicals.bat:

dot -Tpng InternationalChemicals.gv > InternationalChemicals.png

 

InternationalChemicals.gv (small portion of file since spam filter is triggered otherwise)

digraph InternationalChemicals {
WHS01320891 -> WHS013101052
WHS0588224 -> WHS013101052
WHS111828 -> WHS013101052
WHS061911 -> WHS013101052
WHS200AB0 -> WHS013101052
WHS570AE0 -> WHS013101052
WHS571AE0 -> WHS013101052
}

This should work fine. At

This should work fine. At least, it does for me. You should either be getting something or you should get error messages. Given you are using a .bat file, I assume you are working on Windows. Try running the command directly in a dos shell. And add a -v flag to give you some trace information.

You can also try using gvedit, from the shortcuts menu, to load your file and see the result.

I assume you have added the path to the Graphviz bin directory to your PATH environment variable.

Larger files?

What should my batch file say if I have a much larger file, like 50,000-100,000 nodes?

The same commands are used

The same commands are used regardless of the size of the graph. All that matters is what layout you want and what options you wish to use. That said, each algorithm has its performance limit. The dot layout is superquadratic. You can run it on a 50,000 node graph, but don't expect output for a long, long time.

For large graphs, the only layouts in Graphviz with acceptable performance are twopi and sfdp. A great deal depends on what you are looking for in the layout. Also, even if you produce a layout for large graph, you have to consider how you plan to look at it.

This should work fine. At

This should work fine. At least, it does for me. You should either be getting something or you should get error messages. Given you are using a .bat file, I assume you are working on Windows. Try running the command directly in a dos shell. And add a -v flag to give you some trace information.

You can also try using gvedit, from the shortcuts menu, to load your file and see the result.

I assume you have added the path to the Graphviz bin directory to your PATH environment variable.

Success, one more question

OK, looks like I need to work on the pathing. Seems to work now.

So, one more question.  It created a PNG, but I really want to be able to use this in another software package. It requires me to send in the nodes with x,y coordinates so it can show in the graph.  Is there a way to get an export that includes some kind of x,y coords instead of a PNG format?

Drop the -Tpng flag. This

Drop the -Tpng flag. This tells dot to produce png output. By default, dot produces output in the dot language with coordinates attached. This is probably what is wanted, but you should check with the other software package, as there are several other text formats with coordinates that can be produced.

You can take a look at some

You can take a look at some of the drawings at http://www.graphviz.org/Gallery.php and see if any of these is what your are after. If so, you can try it out on your graph. First, you have to describe your graph in the dot language. This is fairly straightforward. For example, the input

 

digraph G {
  a -> b [color=red]
}

describes a graph named G with nodes a and b and one edge from a to b, with the color red. You would enter this into a plain text file, say, mygraph.gv (.gv indicates the contents are a Graphviz file.) You would then run the desired graphviz command. For example,

  dot -Tpng mygraph.gv > mygraph.png

This will do a layout and a drawing, leaving the output in mygraph.png. 

For more information on the available attributes, see the tutorial http://www.graphviz.org/pdf/dotguide.pdf

More generally, there is a lot of documentation at http://www.graphviz.org/Documentation.php

Did you get my followups?

Did  you get my follow up question/example?  It seems everything is getting stuck in moderation.

 

I'm the moderator. :)

I'm the moderator. :)

Well, I sent two more that aren't showing. ;-)

Two more posts aren't showing.

Interesting, thanks

Interesting, I'll give that a try.  I suppose the nomenclature was throwing my off too. For example it seems that "edge" really just means "arrow".

 

There is a lot of variability

There is a lot of variability in the nomenclature. Nodes are also called vertices. Edges are called links. The arrow notation is just an aid for directed graphs, to remind you that the edge has a direction from one node to another. For undirected graphs, edges are represented by '--'.

Recent comments