Home Wiki Blog Forum GEXF.net

Gephi forums

Community support

Translation ForceAtlas2 classes from Java to C #

Algorithms and parameters to put data in space

Translation ForceAtlas2 classes from Java to C #

Postby cheibia » 01 Aug 2013 18:59


I tried to translate the classes of ForceAtlas2 from Java to C# (.NET 4.5) using this page:
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();
for (int i = 0; i < 10000; i++) // 1000 may be replaced with another number of iterations

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.
Posts: 6
Joined: 02 Jul 2013 16:12

Re: Translation ForceAtlas2 classes from Java to C #

Postby admin » 02 Aug 2013 21: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.
User avatar
Gephi Community Manager
Posts: 964
Joined: 09 Dec 2009 15:41
Location: Paris, France

Return to Layouts

Who is online

Users browsing this forum: No registered users and 0 guests

sports medicine portsmouth nh where to buy metronidazole