graphstream / gs-core

Graphstream core
http://graphstream-project.org/
Other
401 stars 109 forks source link

Implement clear() in HierarchialLayout #205

Open oliverfleetwood opened 8 years ago

oliverfleetwood commented 8 years ago

Hi,

It seems like HierarchialLayout in the gs-algo project does not do anything in clear(), unlike the BarnesHutLayout subclasses. I think it should clear all fields or you'll get an org.graphstream.graph.IdAlreadyInUseException: singleton exception: when you disable and enable the viewer with the same layout.

I couldn't post the issue in the gs-algo project so I'm posting it here instead.

jordilaforge commented 7 years ago

hi there i have looked into the HierachicalLayout myself and this class looks like it never has been finished. Therefore i have implemented my own HierachicalLayout, i hope i will find the time to bring this to a clean state to make a pull request out of it. But the version in graphstream is not working very well i see some strange layouting with specific graphs. In the meantime maybe just implement the clear() method yourself and make a pull request out of it.

oliverfleetwood commented 7 years ago

Hi, good to know. Actually, for now I'll just create a new HierarchialLayout instead of recycling it, that solves my problem at least. I'll see if I have time to make a pull request later.

pigne commented 7 years ago

Hi. The HierachicalLayout class is definitely not production-ready. Any input would be much appreciated.

jordilaforge commented 7 years ago

First of all a HierachicalLayout is only possible if you have a DAG (directed acyclic graph). In modern graph theory you would use the Sugiyama Method which is a method of doing a hierachical layout. It describes several steps and you need several helper algorithm to perfom it. Here are slides which show the steps and the different approaches: www.cs.usyd.edu.au/~visual/comp4048/slides03.ppt I started with a helper class for Topological Ordering (used for cylce check and to start longest path algo) next would be the longest path algorithm to perform the layering. so step after step, if every helper algo is implemented a proper HierachicalLayout can be performed.