private void RandomizeGraph() { // Remove all bends var bends = CurrentIGraph.Edges.SelectMany(e => e.Bends).ToList(); foreach (var bend in bends) { CurrentIGraph.Remove(bend); } var r = new Random(); // Place nodes in random locations foreach (var node in CurrentIGraph.Nodes) { CurrentIGraph.SetNodeCenter(node, new PointD(r.Next((int)GraphControl.Viewport.MinX, (int)GraphControl.Viewport.MaxX), r.Next((int)GraphControl.Viewport.MinY, (int)GraphControl.Viewport.MaxY))); } GraphControl.UpdateContentRect(); }
protected override async Task RunModule() { TreeGenerator rg = new TreeGenerator(); rg.NodeCount = (int)Handler[NumberOfNodes].Value; rg.MaxDepth = (int)Handler[MaxDepth].Value; rg.MaxChildCount = (int)Handler[MaxChildCount].Value; rg.Generate(CurrentIGraph); int i = 0; foreach (INode node in CurrentIGraph.Nodes) { CurrentIGraph.AddLabel(node, "" + ++i); } GraphControl.Invalidate(); await new TreeLayoutModule { RunInBackground = false }.Start(Context); }
protected override Task RunModule() { RandomGraphGenerator rg = new RandomGraphGenerator { NodeCount = (int)Handler[NumberOfNodes].Value, EdgeCount = (int)Handler[NumberOfEdges].Value, AllowCycles = (bool)Handler[AllowCycles].Value, AllowMultipleEdges = (bool)Handler[AllowMultipleEdges].Value, AllowSelfLoops = (bool)Handler[AllowSelfloops].Value }; rg.Generate(CurrentIGraph); int i = 0; foreach (INode node in CurrentIGraph.Nodes) { CurrentIGraph.AddLabel(node, "" + ++i); } RandomizeGraph(); GraphControl.Invalidate(); return(Task.FromResult <object>(null)); }