Monday, April 09, 2007

Organic Graph Layout

Took me 4 days of work, but finally it's done. 4 hari hidup kelawar. It was a nightmare just to get it working correctly, and a lot of tweaking to get it just right. It solves the very thing we take for granted. Aesthetic values ... that make things look 'nice'. Ratios, determine how beautiful something really is. Who said the world isn't all math. Well, it isn't ... but most of it is anyway.

As to graphs, we look at a graph which the nodes have been randomly spread across a canvas, and rearrange it. But sub consciously we place nodes at a roughly same distance from every other node. We cluster them so that the connected nodes are closer together.and we try to get rid of crossing edges.

This is found in nature. But natural approach is a bit different but the result is more or less the same. You have 2 forces. Attracting and repelling ...
This model is what keeps molecules together. Keeps the moon in orbit. Keeps the earth in orbit. For all we know, keeps life itself going.

So organic graph layouts simulate how molecules keep intact. Each node has a repelling force, but to the nodes it is connected to, it attracts to some extent.

This is the pseudocode ...
set up initial node velocities to (0,0)
set up initial node positions randomly // no 2 nodes are in exactly the same position
loop
total_kinetic_energy := 0 // total kinetic energy of all particles
for each node

net_force := (0, 0) // running sum of node's total force

for each other node
net_force := net_force + Coulomb_repulsion( this_node, other_node )
next node

for each spring connected to this node
net_force := net_force + Hooke_attraction( this_node, spring )
next spring

// without damping, it moves forever

this_node.velocity := (this_node.velocity + timestep * net_force) * damping
this_node.position := this_node.position + timestep * this_node.velocity
total_kinetic_energy := total_kinetic_energy + (this_node.velocity)^2
next node

until total_kinetic_energy is less than some small number //the simulation has stopped moving
The result :


The code doesn't really deal with crossing edges but naturally most of the crossings will resolve itself.

Labels:

10 Comments:

  • Hi,

    When ever I surf on web I come to this website[url=http://www.weightrapidloss.com/lose-10-pounds-in-2-weeks-quick-weight-loss-tips].[/url]Plenty of useful information on shahrin14.blogspot.com. Let me tell you one thing guys, some time we really forget to pay attention towards our health. Here is a fact for you. Research indicates that closely 70% of all United States adults are either fat or overweight[url=http://www.weightrapidloss.com/lose-10-pounds-in-2-weeks-quick-weight-loss-tips].[/url] Hence if you're one of these people, you're not alone. Infact many among us need to lose 10 to 20 lbs once in a while to get sexy and perfect six pack abs. Now the question is how you are planning to have quick weight loss? [url=http://www.weightrapidloss.com/lose-10-pounds-in-2-weeks-quick-weight-loss-tips]Quick weight loss[/url] is not like piece of cake. You need to improve some of you daily habbits to achive weight loss in short span of time.

    About me: I am webmaster of [url=http://www.weightrapidloss.com/lose-10-pounds-in-2-weeks-quick-weight-loss-tips]Quick weight loss tips[/url]. I am also health expert who can help you lose weight quickly. If you do not want to go under difficult training program than you may also try [url=http://www.weightrapidloss.com/acai-berry-for-quick-weight-loss]Acai Berry[/url] or [url=http://www.weightrapidloss.com/colon-cleanse-for-weight-loss]Colon Cleansing[/url] for effortless weight loss.

    By Anonymous Anonymous, at 4:38 AM  

  • Thank you,

    This algorithm has been priceless. I've amended it to work in Java with GWT and applied it to 3 dimensions (using the size of the image to give the illusion of depth) and it works really well, before reading this, it was all just an idea, now I've been able to make it happen.

    Thanks again,

    Stu.

    By Anonymous Anonymous, at 10:21 PM  

  • continuously i used to read smaller articles or reviews that as well clear their motive,
    and that is also happening with this article which I am reading at this place.



    My web blog - Book Of Ra kostenlos App

    By Anonymous Anonymous, at 8:00 AM  

  • This is very interesting, You are a very skilled
    blogger. I have joined your rss feed and look forward to seeking more of
    your great post. Also, I have shared your web site in my social networks!


    my web-site :: novoline automaten spielen

    By Anonymous Anonymous, at 8:00 AM  

  • My programmer is trying to convince me to move to .net from PHP.
    I have always disliked the idea because of the expenses. But he's tryiong none the less. I've been using Movable-type on a number of websites for about a year and
    am worried about switching to another platform.

    I have heard good things about blogengine.net. Is there
    a way I can transfer all my wordpress content into it?
    Any kind of help would be greatly appreciated!

    Feel free to visit my web blog - sizzling hot online kostenlos spielen

    By Anonymous Anonymous, at 12:23 PM  

  • Hello there, I found your site via Google at the same time as searching for a comparable topic,
    your web site came up, it appears to be like good. I have bookmarked
    it in my google bookmarks.
    Hi there, just turned into alert to your weblog through Google, and found that it is really informative.
    I'm going to watch out for brussels. I will be grateful for those who continue this in future. A lot of folks will probably be benefited from your writing. Cheers!

    My blog :: novoline tricks 2013

    By Anonymous Anonymous, at 12:23 PM  

  • Pretty part of content. I just stumbled upon your website and in accession capital to assert that I get
    actually loved account your blog posts. Anyway I will be subscribing in your augment and even I
    achievement you get right of entry to constantly rapidly.


    Feel free to visit my web blog :: novoline spiele kostenlos spielen

    By Anonymous Anonymous, at 12:37 PM  

  • This piece of writing will assist the internet visitors
    for creating new webpage or even a weblog from start to end.


    Here is my web site; book of ra kostenlos spielen ohne anmeldung mybet

    By Anonymous Anonymous, at 3:40 PM  

  • Hi my loved one! I wish to say that this post is amazing, great written and include almost all important infos.
    I would like to peer more posts like this .

    My page novoline app f�roid download

    By Anonymous Anonymous, at 11:44 AM  

  • Can I just say what a relief to uncover somebody that actually
    understands what they are talking about on the internet.
    You certainly realize how to bring a problem to light
    and make it important. A lot more people must check this out and understand this side of the story.

    I was surprised you are not more popular since you definitely
    possess the gift.

    Also visit my blog :: Rhinoplasty Las Vegas

    By Anonymous Anonymous, at 7:51 AM  

Post a Comment

<< Home