prog/lib to draw graphs

F

Florian Lindner

Hello,
I'm looking for a program or python library to draw graphs.
They should look like the that:


/--------\ /--------\
| Node A | ------ belongs to ----> | Node B |
\--------/ \--------/

Which is a result of the function call like that:

connectNodes(firstNode, secondNode, description, lineStyle)
connectNodes("Node A", "Node B", "belongs to", dashed)

It should have a open scalable vector format as output (DVI, SVG, PDF, ...)
and should be able to make automatic optimal placement of the items.
Do you know something like that?
Thx,
Florian
 
J

John Hunter

Florian> Hello, I'm looking for a program or python library to
Florian> draw graphs. They should look like the that:


Florian> /--------\ /--------\ | Node A | ------ belongs to ---->
Florian> | Node B | \--------/ \--------/

Florian> Which is a result of the function call like that:

Florian> connectNodes(firstNode, secondNode, description,
Florian> lineStyle) connectNodes("Node A", "Node B", "belongs to",
Florian> dashed)

Florian> It should have a open scalable vector format as output
Florian> (DVI, SVG, PDF, ...) and should be able to make
Florian> automatic optimal placement of the items. Do you know
Florian> something like that? Thx, Florian --
Florian> http://mail.python.org/mailman/listinfo/python-list

graphviz is a sophisticated graph drawing program

http://www.research.att.com/sw/tools/graphviz/

There is a python interface

http://www.cs.virginia.edu/~jg9h/graphiz/

JDH
 
N

netnews.upenn.edu

Florian said:
Hello,
I'm looking for a program or python library to draw graphs.
They should look like the that:


/--------\ /--------\
| Node A | ------ belongs to ----> | Node B |
\--------/ \--------/

Which is a result of the function call like that:

connectNodes(firstNode, secondNode, description, lineStyle)
connectNodes("Node A", "Node B", "belongs to", dashed)

It should have a open scalable vector format as output (DVI, SVG, PDF, ...)
and should be able to make automatic optimal placement of the items.
Do you know something like that?
Thx,
Florian

Try graphviz:

http://www.research.att.com/sw/tools/graphviz/


I think there's a python interface to graphviz floating around (Google
it), but it's trivial to write a Python routine that spits out valid
Graphviz "dot" files.

In the case of your example, the contents of the dot file would be
something like:

digraph G{
"Node A" -> "Node B" [label="belongs to"];
}


--Paul
 
B

Bill Scherer

[P&M]

Florian said:
Hello,
I'm looking for a program or python library to draw graphs.
They should look like the that:


/--------\ /--------\
| Node A | ------ belongs to ----> | Node B |
\--------/ \--------/

Florian -

Graphviz (http://www.graphviz.org) is a great package for drawing
graphs. It ouputs to many formats. There is a python lib for it at
http://www.freshports.org/graphics/py-graphviz/, but I have not used
it. It's easy enough to generate dot[1] code and call dot to generate
the graph image, so that's what I usually do.

HTH,

Bill


1. 'dot' is one of the graphviz commands.
 
F

Florian Lindner

netnews.upenn.edu said:
Florian said:
Hello,
I'm looking for a program or python library to draw graphs.
They should look like the that:


/--------\ /--------\
| Node A | ------ belongs to ----> | Node B |
\--------/ \--------/

Which is a result of the function call like that:

connectNodes(firstNode, secondNode, description, lineStyle)
connectNodes("Node A", "Node B", "belongs to", dashed)

It should have a open scalable vector format as output (DVI, SVG, PDF,
...) and should be able to make automatic optimal placement of the items.
Do you know something like that?
Thx,
Florian

Try graphviz:

http://www.research.att.com/sw/tools/graphviz/


I think there's a python interface to graphviz floating around (Google
it), but it's trivial to write a Python routine that spits out valid
Graphviz "dot" files.

In the case of your example, the contents of the dot file would be
something like:

digraph G{
"Node A" -> "Node B" [label="belongs to"];
}

Thanks! (to all)
Does GraphViz also support the automated optimal placement of nodes? I'll
have many nodes...
Thx,
Florian
 
K

Kyle Rawlins

Thanks! (to all)
Does GraphViz also support the automated optimal placement of nodes?
I'll
have many nodes...

What constitutes optimal is a matter of an entire subfield of graph
theory, and is pretty different depending on what type of graph you are
doing. Nonetheless, graphviz does pretty well without any cues. In a
project I used to use it in (a browser for large automatically learned
ontologies) I would sometimes use it to render thousands of nodes, and
it would usually look better than I expected. There is a problem in
that highly connected large graphs result in a lot of black ink for the
edges, since in such graph they will be much denser than the DPI of
your screen. I'm not sure you'll find any full display of a large
graph practical for interactive use without a lot of tweaking.

If you do want to use it interactively, be prepared for long waits
(>30s, sometimes several minutes) for very large graphs. For small
graphs, it's near instantaneous. This is a problem with graph layout
algorithms in general, however, and not graphviz per se - they do not
scale very efficiently. People I know who used ygraph, a commercial
package, told me that it was not much faster on large graphs.

hope that helps,
-kyle
 
W

Will Henney

Florian Lindner said:
Hello,
I'm looking for a program or python library to draw graphs.
They should look like the that:


/--------\ /--------\
| Node A | ------ belongs to ----> | Node B |
\--------/ \--------/

Which is a result of the function call like that:

connectNodes(firstNode, secondNode, description, lineStyle)
connectNodes("Node A", "Node B", "belongs to", dashed)

It should have a open scalable vector format as output (DVI, SVG, PDF, ...)
and should be able to make automatic optimal placement of the items.

Since you mention DVI you probably know about LaTeX. You might
want to try its `psfrag' package, which can do all you want and
more. Learning curve is a bit steep, but the results are _very_
high quality. Nothing to do with Python though......
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,280
Latest member
BGBBrock56

Latest Threads

Top