Hi,
I'm trying to use NODEXL for tree structure (I know that there are other tool specially for such layout but i prefer to use the NODEXL due to other factors)
I have used the SugiyamaLayout but this is what i'm getting when the graph is draw.
![Image]()
How can I distribute the vertices evenly inside the windows frame ?
something like that:
![Image]()
This is my code:
I'm trying to use NODEXL for tree structure (I know that there are other tool specially for such layout but i prefer to use the NODEXL due to other factors)
I have used the SugiyamaLayout but this is what i'm getting when the graph is draw.

How can I distribute the vertices evenly inside the windows frame ?
something like that:

This is my code:
protected void PopulateAndDrawGraph()
{
oVertices = nodeXLControl1.Graph.Vertices;
oEdges = nodeXLControl1.Graph.Edges;
IVertex parent = oVertices.Add();
float primScreenHeight = (float)System.Windows.SystemParameters.FullPrimaryScreenHeight;
float primScreenWidth = (float)System.Windows.SystemParameters.FullPrimaryScreenWidth;
parent.Location = new System.Drawing.PointF(primScreenHeight/2, 20);
// Draw vertex Root as a Label, which is a rectangle containing text.
parent.SetValue(ReservedMetadataKeys.PerVertexShape, VertexShape.Label);
parent.SetValue(ReservedMetadataKeys.PerVertexLabel, tree.Graph.ToString());
// Set the label's text and fill colors.
parent.SetValue(ReservedMetadataKeys.PerColor, Color.FromArgb(255, 220, 220, 220));
parent.SetValue(ReservedMetadataKeys.PerVertexLabelFillColor, Color.FromArgb(255, 0, 0, 0));
buildTree(tree,parent);
nodeXLControl1.Layout = new Smrf.NodeXL.Layouts.SugiyamaLayout();
nodeXLControl1.DrawGraph(true);
}
public void buildTree(Node node,IVertex parent)
{
if (node.Children == null || node.Children.Count == 0)
{
return;
}
// Add Root Vertex
foreach (var child in node.Children)
{
IVertex childNode = oVertices.Add();
// Draw vertex Root as a Label, which is a rectangle containing text.
childNode.SetValue(ReservedMetadataKeys.PerVertexShape, VertexShape.Label);
childNode.SetValue(ReservedMetadataKeys.PerVertexLabel, child.Graph.ToString());
// Set the label's text and fill colors.
childNode.SetValue(ReservedMetadataKeys.PerColor, Color.FromArgb(255, 220, 220, 220));
childNode.SetValue(ReservedMetadataKeys.PerVertexLabelFillColor, Color.FromArgb(255, 0, 0, 0));
//Add Edge to father
IEdge oEdge1 = oEdges.Add(parent, childNode, true);
oEdge1.SetValue(ReservedMetadataKeys.PerColor, Color.FromArgb(255, 55, 125, 98));
oEdge1.SetValue(ReservedMetadataKeys.PerEdgeWidth, 3F);
oEdge1.SetValue(ReservedMetadataKeys.PerEdgeLabel, child.CurrentMove.Player + " - " + child.CurrentMove.Position);
buildTree(child, childNode);
}
}