Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Algorithm for automatic placement of flowchart shapes

My team needs to build a flowchart generator in JavaScript, using either HTML5 Canvas or the D3 library (or anything else more suitable, suggestions welcome). The flowchart will be generated from a directed graph defined in a JSON document. My question is the following: which standard algorithm could we use to facilitate the automated placement of shapes in the flowchart (nodes in the graph) in order to minimize the number of overlapping connections and their lengths?

like image 926
Ismael Ghalimi Avatar asked Aug 28 '12 03:08

Ismael Ghalimi


People also ask

Can a flow chart be developed into an algorithm?

As a visual representation of data flow, flowcharts are useful in writing a program or algorithm and explaining it to others or collaborating with them on it. You can use an algorithm flowchart to spell out the logic behind a program before ever starting to code the automated process.


3 Answers

This is the library I found useful. Its called GoJS. Hope this helps.

like image 116
Awadhoot Avatar answered Oct 17 '22 23:10

Awadhoot


The standard algorithm you're looking for is force directed graph: http://en.wikipedia.org/wiki/Force-based_algorithms_(graph_drawing) If you want a lightweight, browser agnostic and efficient FD js library take a look at arbor.js: https://github.com/samizdatco/arbor

IMHO D3 is the most powerful library you'll find (it embeds force based algorithm), but it's not compatible with IE < 9 and a bit lower level (document oriented) than over libraries (less to learn, more to think).

JIT is also a good library (it also embeds force based algorithm), not compatible with IE < 9. It's more like Highcharts for infovis. More to learn (helpers, options, parameters), less to think.

WireIt (YUI3) and JSplump (jQuery) are good plumbing libraries but do not include FD algorithms.

like image 33
anh-tuan Avatar answered Oct 18 '22 00:10

anh-tuan


Force-directed algorithm is not exactly optimal for this kind of problems. I'd rather suggest to use a Layered graph drawing (http://en.wikipedia.org/wiki/Layered_graph_drawing) algorithm. A nice JS implementation of such algorithm is Dagre (https://github.com/cpettitt/dagre). You can also take a look at my blog post about auto-layout and rendering of directed graphs: http://www.daviddurman.com/automatic-graph-layout-with-jointjs-and-dagre.html.

like image 6
dave Avatar answered Oct 17 '22 22:10

dave