Re: A computer science question

ken at ken at
Tue Feb 10 20:01:16 CET 2015

I think you’re looking for a clever application of a “Force-Directed Graph” drawing algorithm

There are whole books to this field, but there’s a sample web page with an algorithm done in javascript here:


Sent from Windows Mail

From: Peter Haworth
Sent: ‎Tuesday‎, ‎10‎ ‎February‎ ‎2015 ‎18‎:‎23
To: How to use LiveCode

I've managed to get by for many years without the benefit of any formal
computer science training but I think I've finally run into a situation
which is probably solvable by a computer science algorithm.

I want to implement a database diagram feature in my SQLiteAdmin program
with a graphic to represent each table and lines connecting tables that
have a foreign key relationship.

The first challenge was to arrange the tables in a series of levels with
the tables that are not referenced in any foreign keys at the top the
second level with tables that reference the top level, and so on.  That I
have figured out with a nice recursive handler.

Now I'm faced with the issue of drawing the relationship lines.  Currently
the tables at each level are arranged in alphabetical order but that pretty
much guarantees that a table graphic will not be in the optimal position to
be connected to its parent table.

For example, I'm looking at a diagram where the table at the top left needs
a line drawn to the table at the bottom right.  Ideally the table at the
bottom right should be placed at the bottom left (or somewhere close) so
the connecting line can drawn from it to the table at the top left.

I'm guessing there is a computer science algorithm that will place the
table graphics in the optimal position for the connection lines to be
drawn.  Can anyone point me to that algorithm?

lcSQL Software <>
Home of lcStackBrowser <> and
SQLiteAdmin <>
use-livecode mailing list
use-livecode at
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:

More information about the use-livecode mailing list