public void PrintDataStructuresBoruvka( AdjVertexSortedList[] lists, IValiableDSU dsu, Color[] colors, int size = 20) { bitmap = new Bitmap(dataStructuresArea.Width, dataStructuresArea.Height); graphics = Graphics.FromImage(bitmap); graphics.Clear(areaBackColor); Point leftBorder = new Point(3, 3); float nameSize = graphics.MeasureString("DSU", smallFont).Height; graphics.DrawString("DSU", smallFont, textBrush, leftBorder); leftBorder.Offset(0, (int)nameSize + 3); List <TreePointsDSU> dsuTrees = TreePointsDSU.GetTrees(dsu, leftBorder, size, 3); PrintDSU(dsuTrees, size, colors); leftBorder.Offset(0, TreePointsDSU.GetMaxLevel(dsuTrees) * (size + 3) + 3); nameSize = graphics.MeasureString( "Сортированные списки смежности компонент:", smallFont).Height; graphics.DrawString( "Сортированные списки смежности компонент:", smallFont, textBrush, leftBorder); leftBorder.Offset(0, (int)nameSize + 3); for (int i = 0; i < lists.Length; i++) { if (lists[i] == null) { break; } if (lists[i].IsEmpty) { continue; } PrintASL(lists[i], i.ToString(), leftBorder, size); leftBorder.Offset(0, size + 3); } dataStructuresArea.Image = bitmap; }
public static List <TreePointsDSU> GetTrees( IValiableDSU dsu, Point firstPoint, int size, int interval) { firstPoint.Offset(size / 2, size / 2); List <TreePointsDSU> trees = new List <TreePointsDSU>(); TreePointsDSU currentTree; for (int i = 0; i < dsu.GetCount(); i++) { if (dsu.GetValue(i) == i) { currentTree = new TreePointsDSU(i, i); trees.Add(currentTree); FindAllBranches(currentTree); } } ListSetPoints(trees, firstPoint, size, interval); return(trees); void FindAllBranches(TreePointsDSU tree) { TreePointsDSU addedTree; for (int i = 0; i < dsu.GetCount(); i++) { if (dsu.GetValue(i) == tree.id && i != tree.id) { addedTree = new TreePointsDSU(i, tree.root); tree.branches.Add(addedTree); FindAllBranches(addedTree); } } } }
public void PrintDataStructuresKruskal(Edge <VisVertex>[] list, Edge <VisVertex> currentEdge, IValiableDSU dsu, Color[] colors, int size = 20) { bitmap = new Bitmap(dataStructuresArea.Width, dataStructuresArea.Height); graphics = Graphics.FromImage(bitmap); graphics.Clear(areaBackColor); Point leftBorder = PrintSortedEdgeList(list, currentEdge, new Point(3, 3), 20, 400); float nameSize = graphics.MeasureString("DSU", smallFont).Height; graphics.DrawString("DSU", smallFont, textBrush, leftBorder); leftBorder.Offset(0, (int)nameSize + 3); List <TreePointsDSU> dsuTrees = TreePointsDSU.GetTrees(dsu, leftBorder, size, 3); PrintDSU(dsuTrees, size, colors); dataStructuresArea.Image = bitmap; }