private void GraphGenerate() { //the graphx library is used to generate the graph var LogicCore = new GXCore() { Graph = GraphSetup() }; //This property sets layout algorithm that will be used to calculate vertices positions //Different algorithms uses different values and some of them uses edge Weight property. LogicCore.DefaultLayoutAlgorithm = LayoutAlgorithmTypeEnum.KK; //Now we can set optional parameters using AlgorithmFactory //NOTE: default parameters can be automatically created each time you change Default algorithms LogicCore.DefaultLayoutAlgorithmParams = LogicCore.AlgorithmFactory.CreateLayoutParameters(LayoutAlgorithmTypeEnum.KK); //Unfortunately to change algo parameters you need to specify params type which is different for every algorithm. ((KKLayoutParameters)LogicCore.DefaultLayoutAlgorithmParams).MaxIterations = 100; //This property sets vertex overlap removal algorithm. //Such algorithms help to arrange vertices in the layout so no one overlaps each other. LogicCore.DefaultOverlapRemovalAlgorithm = OverlapRemovalAlgorithmTypeEnum.FSA; //Setup optional params LogicCore.DefaultOverlapRemovalAlgorithmParams = LogicCore.AlgorithmFactory.CreateOverlapRemovalParameters(OverlapRemovalAlgorithmTypeEnum.FSA); ((OverlapRemovalParameters)LogicCore.DefaultOverlapRemovalAlgorithmParams).HorizontalGap = 50; ((OverlapRemovalParameters)LogicCore.DefaultOverlapRemovalAlgorithmParams).VerticalGap = 50; //This property sets edge routing algorithm that is used to build route paths according to algorithm logic. //For ex., SimpleER algorithm will try to set edge paths around vertices so no edge will intersect any vertex. LogicCore.DefaultEdgeRoutingAlgorithm = EdgeRoutingAlgorithmTypeEnum.SimpleER; //This property sets async algorithms computation so methods like: Area.RelayoutGraph() and Area.GenerateGraph() //will run async with the UI thread. Completion of the specified methods can be catched by corresponding events: //Area.RelayoutFinished and Area.GenerateGraphFinished. LogicCore.AsyncAlgorithmCompute = false; //Finally assign logic core to GraphArea object LogicCore.EnableParallelEdges = true; LogicCore.ParallelEdgeDistance = 25; LogicCore.EdgeCurvingEnabled = true; GraphArea.SetVerticesDrag(true, true); GraphArea.LogicCore = LogicCore; GraphArea.GenerateGraph(); GraphArea.RelayoutGraph(true); }
private void GraphGenerate() { //the graphx library is used to generate the graph var LogicCore = new GXCore() { Graph = GraphSetup()}; //This property sets layout algorithm that will be used to calculate vertices positions //Different algorithms uses different values and some of them uses edge Weight property. LogicCore.DefaultLayoutAlgorithm = LayoutAlgorithmTypeEnum.KK; //Now we can set optional parameters using AlgorithmFactory //NOTE: default parameters can be automatically created each time you change Default algorithms LogicCore.DefaultLayoutAlgorithmParams = LogicCore.AlgorithmFactory.CreateLayoutParameters(LayoutAlgorithmTypeEnum.KK); //Unfortunately to change algo parameters you need to specify params type which is different for every algorithm. ((KKLayoutParameters)LogicCore.DefaultLayoutAlgorithmParams).MaxIterations = 100; //This property sets vertex overlap removal algorithm. //Such algorithms help to arrange vertices in the layout so no one overlaps each other. LogicCore.DefaultOverlapRemovalAlgorithm = OverlapRemovalAlgorithmTypeEnum.FSA; //Setup optional params LogicCore.DefaultOverlapRemovalAlgorithmParams = LogicCore.AlgorithmFactory.CreateOverlapRemovalParameters(OverlapRemovalAlgorithmTypeEnum.FSA); ((OverlapRemovalParameters)LogicCore.DefaultOverlapRemovalAlgorithmParams).HorizontalGap = 50; ((OverlapRemovalParameters)LogicCore.DefaultOverlapRemovalAlgorithmParams).VerticalGap = 50; //This property sets edge routing algorithm that is used to build route paths according to algorithm logic. //For ex., SimpleER algorithm will try to set edge paths around vertices so no edge will intersect any vertex. LogicCore.DefaultEdgeRoutingAlgorithm = EdgeRoutingAlgorithmTypeEnum.SimpleER; //This property sets async algorithms computation so methods like: Area.RelayoutGraph() and Area.GenerateGraph() //will run async with the UI thread. Completion of the specified methods can be catched by corresponding events: //Area.RelayoutFinished and Area.GenerateGraphFinished. LogicCore.AsyncAlgorithmCompute = false; //Finally assign logic core to GraphArea object LogicCore.EnableParallelEdges = true; LogicCore.ParallelEdgeDistance = 25; LogicCore.EdgeCurvingEnabled = true; GraphArea.SetVerticesDrag(true, true); GraphArea.LogicCore = LogicCore; GraphArea.GenerateGraph(); GraphArea.RelayoutGraph(true); }