Is there a way to determine the way vertices are placed?

Jun 3, 2013 at 2:51 PM
I suppose that nodexl has some algorithm that determines the locations of the vertices on the UI. Is there a quick way to configure it through C#?

Jun 3, 2013 at 3:49 PM
If you are using the NodeXLControl, then NodeXL will automatically use a layout algorithm called Fruchterman-Reingold to set the location of each vertex. Please clarify what you mean by "configure it." Do you want to change the parameters of the Fruchterman-Reingold algorithm, or replace it with a different algorithm, or set the vertex locations yourself, or something else?

-- Tony
Jun 3, 2013 at 3:55 PM
Yes, by writing "configure it" I mean to play with the Fruchterman-Reingold algorithm's parameters.

I'm also asking if other similar algorithms are part of nodexl.

I haven't looked at it, but I suppose that it's easy to specify the x and y axes for any vertex. Then implement a different algorithm similar to the Fruchterman-Reingold one. Not sure if there is a reason to implement another algorithm - I'm just curious for general knowledge.
Jun 3, 2013 at 5:17 PM
Yes, you can set a few parameters for the Fruchterman-Reingold algorithm, including a constant that determines the strength of the attractive and repulsive forces between the vertices (FruchtermanReingoldLayout.C) and the number of layout iterations (FruchtermanReingoldLayout.Iterations). These, and the other features I mention, are documented in the NodeXLApi.chm file that ships with the NodeXL Class Libraries.

Yes, there is an entire family of classes that implement different layout algorithms. A few are force-based, while most of the others are geometric: circle, spiral, grid, and so on. In the "LayoutBase Class" topic in the help file, the "Derived types" link will show you the available algorithms.

And yes, you can implement your own layout algorithm. You have to create a class that implements the ILayout interface. An easy way to do this is to derive your class from the supplied LayoutBase class and implement a few abstract members.

-- Tony
Jun 3, 2013 at 11:18 PM
Many thanks Tony.
Jun 22, 2013 at 12:09 AM
Another question please - how do I set the vertex locations myself?

Jun 22, 2013 at 5:41 PM
Edited Jun 23, 2013 at 6:20 PM
Here is how you can change the location of one vertex:

// Set the vertex location.
myVertex.Location = new System.Drawing.PointF(1.234F, 5.678F);

// Draw the graph without laying out the vertices again.

If you want to set the locations of all of your vertices, a more elegant solution is to implement your own Layout class. A Layout class implements the ILayout interface and "plugs into" NodeXL via the NodeXLControl.Layout property. When you implement a Layout class, NodeXL calls a method on your class that sets the Location property of every vertex in the graph. You can implement a Layout class from scratch, or derive your class from the supplied LayoutBase class and implement a few abstract members.

It all depends on the needs of your application.

-- Tony
Jun 22, 2013 at 6:43 PM