3D Graph Layout Algorithms?

Hello there! I'm developing a project for my first computer science thesis at the university of Bari, Italy. This project consists in a OpenGL graph visualization tool but I'm having trouble in implementing a correct layout algorithm.
The problem is that I have been unable to find any information regarding the actual algorithms.. all I've discovered is that there are many commercial products out there that implement these algorithms.. :) I need to know how to implement them myself!
I have a set of spheres (and the x-y-z coordinates of their center), and a set of edges which describe the various connection between those spheres. I'm currently using a sort of very simple spring embedder algorithm which works in this way:
Phase 1:
get sphere 1 (s1)
get sphere 2 (s2)
check s1 against all other spheres
if their euclidean distance is too small they are moved farther away in this way:
if (s1.x < s2.x)
s1.x -= delta
s2.x += delta
if (s1.y < s2.y)
s1.y -= delta
and so on. This is the only way to avoid collisions between spheres that I thought of, since they are not puntiform in fact they have a certain radious. Then in phase 2 I iterate between all the edges and if two connected spheres are too distant from each other they are moved nearer in a way like the one described above. But it doesn't seem to work as it should in fact this algorithm seems to lock the spheres after a number of iteration but rarely produces pleasing visual configurations.
So could anyone please point me in the right direction? What kind of algorithm could I use? A description would be very useful.. Thanks in advance!

Hi, I am coauthor and developer of some of the spring-embedder algorithms used in the Java graph layout library 'yFiles' (we call them 'organic layout algorithms'). Some of the algorithms actually work in 3D and all of them can be adapted very easily to run in 3D. We are using combinations and variants and enhanced versions of some of the following algorithms, as well as some of our own, but for a starter this should be enough information for you:
google for 'GRIP layout' 'GUIDE layout', Kamada-Kawai, Fruchterman-Reingold, Eigenvalue graph layout, GEM spring embedder,
Implementing those algorithms well can lead to very nice results: feel free to take a look at our gallery of graph layouts:
http://www.yworks.com/en/products_yfiles_practicalinfo_gallery.htm
Regards, and a happy new year, Sebastian

Similar Messages

  • Graph Drawing Algorithms II

    Hi guys,
    I'm researching graph layout algorithms. Most of the packages available don't suit because they require the user to specify a number of nodes and edges between them and then it draws them very prettily.
    Because I want an extension of a Circle class to be drawn and I need it to be drawn on a customised JPanel called Canvas most of these programs aren't suitable. I have the program laying them out itself but atm they look crude and horrible.
    What I'd like is a plug in java program that can assign coordinates and a basic structure to the graph that I entered.
    Thank you very much for reading this far,

    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import javax.swing.*;
    public class CircleTest extends JPanel
        CircleModel[] circles;
        CircleModel selectedCircle;
        final int
            PAD  = 20,
            SIZE = 10;
        public CircleTest()
            Point[] cps = { new Point(25,25), new Point(80,60), new Point(35,80) };
            circles = new CircleModel[cps.length];
            circles[0] = new CircleModel(cps[0], 15, Color.green.darker(), Color.cyan);
            circles[1] = new CircleModel(cps[1], 20, Color.red,            Color.orange);
            circles[2] = new CircleModel(cps[2], 15, Color.blue,           Color.magenta);
        protected void paintComponent(Graphics g)
             super.paintComponent(g);
             Graphics2D g2 = (Graphics2D)g;
             g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                                 RenderingHints.VALUE_ANTIALIAS_ON);
             double w = getWidth();
             double h = getHeight();
             double xInc = SIZE * (w - 2*PAD) / CircleModel.MAX_X;
             double yInc = SIZE * (h - 2*PAD) / CircleModel.MAX_Y;
             g2.setPaint(new Color(220,200,240));
             // vertical model grid lines
             double x = PAD;
             for(int j = 0; j <= SIZE; j++, x += xInc)
                 g2.draw(new Line2D.Double(x, PAD, x, h-PAD));
             // horizontal model grid lines
             double y = PAD;
             for(int j = 0; j <= SIZE; j++, y += yInc)
                 g2.draw(new Line2D.Double(PAD, y, w-PAD, y));
             double vw = w - 2*PAD;
             double vh = h - 2*PAD;
             for(int j = 0; j < circles.length; j++)
                 CircleModel circle = circles[j];
                 Color color = circle.color;
                 if(circle == selectedCircle)
                     color = circle.selectColor;
                 g2.setPaint(color);
                 Point2D p = circle.getLocation(vw, vh);
                 double[] s = circle.getSize(vw, vh);
                 g2.draw(new Ellipse2D.Double(PAD+p.getX(), PAD+p.getY(), s[0], s[1]));
                 g2.setPaint(Color.red);
                 p = circle.getCenter(vw, vh);
                 g2.fill(new Ellipse2D.Double(PAD+p.getX()-2, PAD+p.getY()-2, 4, 4));
        public void setSelection(CircleModel selected)
            selectedCircle = selected;
            repaint();
        public Rectangle2D getViewRect()
            Rectangle2D.Double r = new Rectangle2D.Double();
            r.x = PAD;
            r.y = PAD;
            r.width  = getWidth()  - 2*PAD;
            r.height = getHeight() - 2*PAD;
            return r;
        public static void main(String[] args)
            CircleTest test = new CircleTest();
            SweepTester sweeper = new SweepTester(test);
            test.addMouseMotionListener(sweeper);
            JFrame f = new JFrame();
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.getContentPane().add(test);
            f.setSize(400,400);
            f.setLocation(200,200);
            f.setVisible(true);
    class SweepTester extends MouseMotionAdapter
        CircleTest circleTest;
        CircleModel lastSelection;
        public SweepTester(CircleTest ct)
            circleTest = ct;
        public void mouseMoved(MouseEvent e)
            Point p = e.getPoint();
            boolean haveSelection = false;
            CircleModel[] circles = circleTest.circles;
            Rectangle2D r2 = circleTest.getViewRect();
            for(int j = 0; j < circles.length; j++)
                if(circles[j].contains(p, r2))
                    circleTest.setSelection(circles[j]);
                    lastSelection = circles[j];
                    haveSelection = true;
                    break;
            if(!haveSelection && lastSelection != null)
                lastSelection = null;
                circleTest.setSelection(null);
    class CircleModel
        Point2D center;
        double radius;
        Color color;
        Color selectColor;
        final static int
            MAX_X = 100,
            MAX_Y = 100;
        public CircleModel(Point p, int r, Color c, Color sc)
            center = p;
            radius = r;
            color = c;
            selectColor = sc;
        protected Point2D getLocation(double w, double h)
            Point2D.Double modelLoc = new Point2D.Double();
            modelLoc.x = center.getX() - radius;
            modelLoc.y = center.getY() - radius;
            Point2D viewLoc = modelToView(modelLoc, w, h);
            return viewLoc;
        protected Point2D getCenter(double w, double h)
            return modelToView(center, w, h);
        protected double[] getSize(double w, double h)
            Point2D cp = getCenter(w,h);
            Point2D loc = getLocation(w,h);
            double width  = 2 * (cp.getX() - loc.getX());
            double height = 2 * (cp.getY() - loc.getY());
            return new double[] { width, height };
        private Point2D modelToView(Point2D modelP, double viewWidth, double viewHeight)
            Point2D.Double viewP = new Point2D.Double();
            viewP.x = viewWidth  * modelP.getX() / MAX_X;
            viewP.y = viewHeight * modelP.getY() / MAX_Y;
            return viewP;
        public boolean contains(Point p, Rectangle2D r)
            Point2D loc = getLocation(r.getWidth(), r.getHeight());
            double[] size = getSize(r.getWidth(), r.getHeight());
            Ellipse2D e = new Ellipse2D.Double(r.getX() + loc.getX(),
                                               r.getY() + loc.getY(), size[0], size[1]);
            return e.contains(p);
    }

  • Declutter layout algorithm

    Hi all you algorithm gurus - I'm looking for ideas for an algorithm to solve the following problem. It's specifically meant to "spread out" or "declutter" the overlapping vertices in a graph visualization system, but I'll state it in more general terms.
    In a rectangular area of the screen there are n rectangles. Each rectangle has a location (the (x,y) coordinate of upper-left corner) a width and a height. Some of the rectangles may overlap each other. The declutter layout algorithm should translate the vertices from their original locations, such that after translation no vertices overlap. The algorithm should also try to minimize the translation distance of each rectangle, so the user does not lose all context.
    Any ideas? Sounds similar to a spring embedded layout algorithm, or some kind of repellent force algorithm, except we're not concerned about connectedness of vertices. Just need to spread out the overlapping ones.

    Any ideas? Sounds similar to a spring embedded
    layout algorithm, or some kind of repellent force
    algorithm, except we're not concerned about
    connectedness of vertices. Just need to spread out
    the overlapping ones.I think a good way to start thinking of algorithms is to consider how you would do this manually. In this case, I would probably start at the top left-corner rectangle, find elements overlap it, and move those away in along the axis of their greatest linear overlap. Then recurse on those rectangles.
    Now if the relative position of the elements is unimportant, you can use a bin packing algorithm and rerrange all the elements.

  • Layout algorithms

    hi there,
    are there any examples of layout algorithms being implemented in java?
    such as the one of Sugiyama (Kozo Sugiyama, 1980).
    Can anyone direct me to some sources please?
    I would be grateful to any help I can get.
    Sincerely
    Karlheinz Toni

    hi,
    take a look at http://www.yworks.com/ - they have a very good java graph drawing library, which can create automatic layouts (among which are sugiyama styles and related styles)
    you may download an evaluation version, or use the free online graph editor yEd (using webstart) which demonstrates a lot of the available layouts. Additionally, they have a nice gallery of graph drawings and automatic layouts on their site... go see it
    greetings, sebastian

  • Any free library for graph layout (vertexes and edges)?

    Does anybody know any free library for graph layout (vertexes and edges)?
    I would like to create applet which:
    1) will read definition of graph - for example like the list of edges
    (vertex11-vertex12; verte21-vertex22; ...; vertexN1-vertexN2)
    2) will generate layout of it (like Circle, Sugiyama, Radial Tree, Tree etc.);
    3) will listen to user which will touch of some vertex and it can:
    3.1) display some information about itself;
    3.2) expand itself (that is: it will show-display all its neighbours-vertexes) or
    collaps itself (that is: it will hide all (all almost all) its neighbours-vertexes.
    I do not want to create the whole Java code for layout algorithms:
    I would like to use some pretty Java library. That is library which has:
    1) methods for defining the topological structure of graph
    (that is the list of vertexec and edges between them);
    2) methods for drawing - visualising of it (like tree, radial tree, circle, etc.).
    I have tried many libraries but I can not such library which:
    - is free (so yFiles no);
    - is small and compact (like TouchGraph);
    - works with JDK 1.3.1, no higher (so Jung no);
    - has a nice API (so JGraph no);
    - is alive (so TouchGraph no - it ihas 2 ywars old its last update);
    - works correctly (not like JGraph - JGraphAddons:
    it has 8 layout algorithms, but most of them does not work).
    Has anybody any tips?
    Thank you very much in advance.
    Mirek

    Hi Owen,
    I promiss I will notice, if I wil find some suit free library. But I think my requirements are not so high. For example there are some tips:
    1) TouchGraph: it is VERY small and compact (that: it has no other dependences), but it has 2 years old update - so it writes to console window information about "obsolete" code when I run its applet; and it has no live forum; but I like its API, but it has some bugs!
    2) JGraph has nice layouts (but they do not work all) and very unpleasent methods for defining of topological structure of graph (vertexes and edges between them). But there is indipendent library JGraphT, which can cooperate with JGraph, and it has very nice API for defining the graph from the topological (not visual) point of view (addVertex, addEdge etc.). But JGraphT is not updated so often like JGraph and therefore there is problems with its colaborate with it. And also have bugs, like JGraph.
    3) Yesterady I have found next library: JGraphOpen - it has many examples (for visualising of graphs and for standard tasks for graph theory (the shortest way etc.) but it is also (like TouchGraph) 2 years old and is not so small like it.
    So has anybody any idea? I would like to find some other free libraries or some tips how to force to cooperative JGraph + JGraphT.
    Thanks
    Mirek

  • Spring Embedded Layout Algorithm

    Does anyone know where I can find pseudocode for this? I've found code, but I want to come up with my own. I've been told this algorithm is not too difficult, but I'm not having any luck searching for pseudocode.
    Please help!

    Yep the code I gave will, in general pull all the nodes into a bunch in the middle.
    There are a number of ways around this:
    First. Fix the position of some nodes. The can be useful for some applications. Circuit layout for example
    were you may want to specify the positions of some of the components.
    Second. Add a term to the code that tries to seperate nodes. Therefore nodes are pulled together by thier
    common edges but the effect is countered by another term if they get too close together.
    Often a combination of the two is used as the first approach is generally useful but its a pain to require
    users to specify the fixed nodes. The second works in general but it is often useful for the users to be able
    to specify some fixed nodes, if they want to, ala the first approach.
    How you implement this "push" factor depends on your needs. It may be a global value in which each
    node tries to seperate itself from all other nodes (this can be expensive O(n^2)) or more simply that
    each node has a gradually increasing "push" factor applied the closer it gets to nodes it is directly linked to.
    Also the weight of the edges can be incorporated into the calculation if they have such a thing.
    I should also say that if your graph contains many edges per node then it can be more efficient to iterate
    through the nodes (rather then the edges) and compute the combined pull exterted on that node by all of the
    edges that connect to it.

  • Graph Theory Algorithm-All possible paths between 2 vertices w/ constraints

    Hi all,
    I have a project I'm working with. I need to find all possible paths between two vertices on a graph.
    I realize this will be NP-complete or worse, but right now i'm looking for a brute force method to do this via algorithm/pseudocode
    Given:
    connected, weighted edges, directed Graph G = (V,E) with no loops
    Given v1 and v2 are vertices in V, and C = constraint value,
    I would like a way to find all possible paths from v1 to v2 that have a length less than C. Length = adding up all the edges on a path
    Can anyone provide any help on this?
    Thanks!

    Sure, no problemo.
    Create a bucket of paths, initially empty. (Bucket is a technical term for a collection)
    Start at v1. Take all the edges that lead from v1 to any place else, like x.
    Each one of those paths consists of a single edge is a path from v1 to somewhere and furthermore it has a length. It is a partial path with a length Now do it again, grab any path out of the bucket, leave from its terminal point x and extend it by an edge and create a bunch more paths that are now two edges long, which you can throw back into that same bucket.
    If you ever get to v2, you have a path from v1 to p2. Add it to your solutions list. If you ever exceed C, well throw it out because it is too long. And if you can't extend from a particular vertex then toss it as well.
    All you ever do is pull a partial path from the bucket, create all its possible one edge extensions, keep the winners, toss out the impossible, and throw all new still valid partial paths back into the bucket.
    If there are loops and if there are edges with zero or negative weight, this would not necessarily terminate. But you say that is not a problem for you.
    Just for the record, nothing is worse than NP-complete.

  • Line, Node Layout algorithms

    Does flex provide any support for layouts. Say I have a
    couple of nodes connected by lines. Can flex automatically draw
    these using some built-in layouts like orthogonal, hierarchial
    etc., or on some criteria that causes a minimal number of line
    intersections etc.,
    There are third party libraries that do these layouts for
    Java swing applications. I am looking for similar support in flex.

    hi,
    take a look at http://www.yworks.com/ - they have a very good java graph drawing library, which can create automatic layouts (among which are sugiyama styles and related styles)
    you may download an evaluation version, or use the free online graph editor yEd (using webstart) which demonstrates a lot of the available layouts. Additionally, they have a nice gallery of graph drawings and automatic layouts on their site... go see it
    greetings, sebastian

  • Know of a Good Algorithm to arrange a Tree (Graph)?

    Do you know of a good algorithm to arrange a graph? The JDK comes with a demo example of a graph relaxer but I was wondering if there were any others out there.
    thanks in advance,
    Anil

    Here are some sites I have been directed to:
    http://graphdrawing.org/
    Graph Drawing: Algorithms for the Visualization of Graphs (Paperback)
    by Ioannis G. Tollis, Giuseppe Di Battista, Peter Eades, Roberto Tamassia

  • Sirius editor with Kieler/KLay layouter resizes nodes

    Hi,
    I have been trying to use the Kieler layout algorithms on diagrams that are created by a Sirius based editor.
    Each time I relayout the diagram, using the Kieler based layout algorithm, diagram nodes are resized; they are enlarged.
    I suspect that this is a problem of the Kieler layout algorithms but I want to know whether anyone has also tried this and if someone has found a solution for this issue already.
    Greetings,
    Wilbert

    OK
    I think I found something.
    For some reasons, the Kieler (layered) layout algorithm considers each node to be a subgraph on its own. If the diagram is layouted, it first starts layouting its subgraphs and then the graph itself. The layout algorithm can be configured using properties. In fact, each item on the graph can have some properties. One of them is the Border Spacing which has a default value is 12.
    So whenever a diagram is layouted, first all nodes are 'layouted'. As they are considered to be sugraphs, the Border Spacing property is applied which increases the size of the subgraphs with 24 pixels (12 on each side). Then the nodes on the diagram themselves are relayouted, taking the new size into account.
    I am not sure whether the Sirius editor does something that leads Kieler to the conclusion that each node is a subgraph on its own or that Kieler interprets the Sirius generated diagram wrongly. So I'm not sure 'who to blame'.
    So I think that I have a (manual) workaround. After displaying the graph for the first time, I need to select all nodes and set their border spacing property to zero. Selecting all nodes can be done with one action so that makes this workable.
    I'm open for any additional suggestions.
    Greetings,
    Wilbert.

  • Draw a flowchart graph

    hi all,
    I want to draw a flochart graph, I use the sample applet graph.java(from SUN) but I have a problem: how place automatically all nodes?
    I read about layout algorithm but I never found samples...
    Anyone could help me?

    I'm not sure if JGraph does flow charts, but I think it would. Here is the home page:
    http://jgraph.sourceforge.net/

  • Use Kieler Layout on Sirius Diagram

    Hi all,
    I want to work with Obeo Designer which is a solution on top of Sirius. And i need to provide to the user the possibility to choose "graph" layout on his diagram.
    For that, Kielier seems to be a good choice but the documentation is very poor.
    Can anyone explain to me how to integrate KIELER Layout (Klay) ?
    Or another solution than KIELER ?
    Thanks for your help.

    Hello,
    I have seen Kieler in action with a Sirius diagram but have not
    installed the environment myself. I do not think it required a lot of
    customization as their is a Kieler Layout feature dedicated for GMF
    diagram and Sirius is GMF-based. This feature added a Layout view where
    you can choose Layout algorithms and other parameters (like padding if I
    remember correctly). Have you tried to install Kieler or add it to your
    target platform?
    Regards,
    Steve
    Le 09/07/2015 17:52, Benoit Wilcox a écrit :
    > Just a precision, by "graph" layout i mean orthogonal, circular etc...
    Steve Monnier - Obeo
    Need professional services for Sirius?
    http://www.obeodesigner.com/sirius

  • Sirius Layout

    Hi,
    I'm interested in adding layouts to Sirius. I found several pages, such as
    https://www.eclipse.org/forums/index.php/t/863729/ and
    http://docs.obeonetwork.com/obeodesigner/6.2/viewpoint/developer/general/extensions-provide_custom_arrange-all.html
    but I really need more detailed information about layouts in Sirius, I would like to use Kieler algorithms, but also, I want to provide my own. Probably you could provide me, with some sample code or another tutorial, that put me in the right direction. Thanks in advance!
    Cheers,
    Anthony

    Hello,
    I have seen Kieler in action with a Sirius diagram but have not
    installed the environment myself. I do not think it required a lot of
    customization as their is a Kieler Layout feature dedicated for GMF
    diagram and Sirius is GMF-based. This feature added a Layout view where
    you can choose Layout algorithms and other parameters (like padding if I
    remember correctly). Have you tried to install Kieler or add it to your
    target platform?
    Regards,
    Steve
    Le 09/07/2015 17:52, Benoit Wilcox a écrit :
    > Just a precision, by "graph" layout i mean orthogonal, circular etc...
    Steve Monnier - Obeo
    Need professional services for Sirius?
    http://www.obeodesigner.com/sirius

  • Is this graph possible?

    Does anyone know if this kind of graph layout is even possible in Keynote or Pages? What would I have to use to achieve it?
    Thanks in advance!
    <table style="width:194px;"><tr><td align="center" style="height:194px;background:url(http://picasaweb.google.com/s/c/transparentalbumbackground.gif) no-repeat left"></td></tr><tr><td style="text-align:center;font-family:arial,sans-serif;font-size:11px">Keynote</td></tr></table>

    I still haven't found out whether this is possible. Could anybody help?

  • ADF 11g hiearchyViewer widget: can rendering of the graph be customized

    The hiearchyViewer widget supports rendering a graph of one parent to many children nodes. I have a need to display a directed graph where many parent nodes is linked to a common child node . Is it possible to extend the hiearchyViewer widget to override the graph rendering algorithm? If the answer is yes, how may I able to do it, or is there sample code I can review? If the answer is no, how can I create an ADF widget that uses the same flash library the hierarchyViewer ADF widget is using to render its graph. Thank you.

    The HV can't show multi-parents to a children relationship.
    We are working on a new component that should be able to do that - hopefully it will make it into the 12 release.
    You can see a couple of beta screenshots here:
    http://one-size-doesnt-fit-all.blogspot.com/2011/10/adf-take-aways-from-oracle-open-world.html

Maybe you are looking for

  • Excel from alv

    hi i use class CL_SALV_TABLE to show alv, when i transfer it to excel to answer look in this format: USD 01.01.2001 28.52 USD 01.01.2001 25.34 i want that the fromat look like: USD        01.01.2001     28.52 USD        01.01.2001     25.34 how can i

  • Compressor 3.5 hangs on creating DVD

    All I want to do is burn a simple standard definition viewing DVD. No matter if I use *"Share - Burn DVD"* in Final Cut Pro 7 or the new *"Burn DVD"* in Compressor 3.5, the encoding/processing goes almost all the way through and then *hangs forever*

  • Is the ABAP Webdynpro CATS available in both ESS and MSS?

    Hi experts, We are in the process of implementing the WDA CATS application for ESS (ECC 6 EHP5) but our scenario is actually for managers to enter in time in CATS on behalf of their employees. I can't find any information on this scenario using the W

  • Java server unavailable

    Hi Gurus, J2ee Server unavailable in the NWDS instance and the dispatcher is running but the status of the Java Server is "Starting Apps " for a long time( in yellow).can anyone help me out in this ,solutions rewarded regards, S.Rajeshkumar

  • Using Command + 1/2 with Expose to reorder windows

    I am able to use Expose to show open windows but if I try to use Command + either 1 or 2 to reorder the windows either alphabetically or by application, nothing happens.