Library to render Directed Graphs (similar to grap

2019-03-08 15:56发布

I am looking for a Java or Python library that can render graphs in the Dot language as image file. The problem is that I need a library that I can use on Google App Engine. Basically I am looking for a library that can convert the text description of a directed graph into an image of the graph.

For example:

Covert this edge list:

[A,B]
[B,C]
[A,C]
[C,D]

Into this image:

example image

I used Graphviz for this example, but I know it is not possible for me to use it with Google App Engine.

4条回答
来,给爷笑一个
2楼-- · 2019-03-08 16:06

You could take a look at the flash based perfuse project if just need to display a graph and not having it embedded as an image is acceptable.

They have some example applications of the library such as this Dependency Graph.

查看更多
够拽才男人
3楼-- · 2019-03-08 16:14

I do not think there is such pure python library, the best you can do is use NetworkX, it can draw using matplotlib or pygraphviz. Maybe you can modify networkx's matplotlib code to draw on server side, here is the code

Another problem is google app engine doesn't have any drawing API, but you may simply use SVG to generate such graphs or may be google charts API have something already there.

查看更多
甜甜的少女心
4楼-- · 2019-03-08 16:18

Canviz is what you are looking for: it is a JavaScript library for drawing Graphviz graphs to a web browser canvas. It works with most browsers.

Using Canviz has advantages for your web application over generating and sending bitmapped images and imagemaps to the browser:

  • The server only needs to have Graphviz generate xdot text; this is faster than generating bitmapped images.
  • Only the xdot text needs to be transferred to the browser; this is smaller than binary image data, and, if the browser supports it (which most do), the text can be gzip- or bzip2-compressed.
  • The web browser performs the drawing, not the server; this reduces server load.
  • The user can resize the graph without needing to involve the server; this is faster than having the server draw and send the graph in a different size.

To see it in action, look here.

查看更多
干净又极端
5楼-- · 2019-03-08 16:23

Google Charts API now supports GraphViz experimentally. (Note that the entire Image Charts project is officially deprecated.)

查看更多
登录 后发表回答