Translation ForceAtlas2 classes from Java to C #

Algorithms and parameters to put data in space
Post Reply [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable
cheibia
Posts:6
Joined:02 Jul 2013 15:12
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable
Translation ForceAtlas2 classes from Java to C #

Post by cheibia » 01 Aug 2013 17:59

Hello,

I tried to translate the classes of ForceAtlas2 from Java to C# (.NET 4.5) using this page:
https://github.com/gephi/gephi/tree/mas ... orceAtlas2
in order to test its performance and display some trees (hierarchy).

My work consists in translating just the part of the code that is responsible for calculation (without graphics).
So, I did some modifications:

1) I deleted "ForceAtlas2Builder" class completely.

2) I transformed "ForceAtlas2LayoutData" class to an attribute of "Node" class. This class has as attributes: double x; double y; string id; double size; int degree; boolean fixed; ForceAtlas2LayoutData layout;
Of course, I defined "ForceAtlas2LayoutData" class independantly.

3) I created "Edge" class that has as attributes (properties): Node source; Node target; double weight;

4) I created an interface "IArborescence" that has as attributes: double x; double y; string id; List<Node> childrenList;

5) I created a class called "Conversion" that contains methods tranformating an "IArborescence" to a list of Node and a list of Edge. These lists are necessary to do calculations in initAlgo(), goAlgo().. in "ForceAtlas2" class.
The class "Conversion" permits to retrieve an "IArborescence" from a list of Node and a list of Edge using the unicity of each id (an attribute of Node).

6) I didn't translate Threads in a first time, in order to test the coherence of calculations.

Then I tested what I did using this algorithm in the main class:
ForceAtlas2 forceAtlas2 = new ForceAtlas2();
forceAtlas2.initAlgo();
forceAtlas2.resetPropertiesValues();
for (int i = 0; i < 10000; i++) // 1000 may be replaced with another number of iterations
{
forceAtlas2.goAlgo();
}

I tried to represent the coordinates of Nodes after calculations (using R and Excel) and unfortunately I found that results are not compatible with a "force-based algorithm".
Please, can you help me to find problem(s) in what I did? (there is no error of compilation regardless the number of iteration).
Have I missed to translate some fundamental Java packages that are necessary to run this algorithm correctly?

Thanks in advance.
cheibia.

admin
Gephi Community Manager
Posts:964
Joined:09 Dec 2009 14:41
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable

Re: Translation ForceAtlas2 classes from Java to C #

Post by admin » 02 Aug 2013 20:24

Hmm maybe check your C# algorithm twice?

I personally always makes many small mistakes when I code a layout, and a slight change may throw all coordinates away.

Post Reply
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable