Код
procedure TGraph.DrawVertex(Point: TPoint; Num: Integer);
begin
Image.Canvas.Pen.Color := clBlack;
Image.Canvas.Ellipse(Point.X - PointWidth, Point.Y - PointWidth, Point.X + PointWidth, Point.Y + PointWidth);
if VIsSelected(Num) then
Image.Canvas.Ellipse(Point.X - (PointWidth + 5), Point.Y - (PointWidth + 5), Point.X + (PointWidth + 5), Point.Y + (PointWidth + 5));
Image.Canvas.Font.Color := clBlue;
Image.Canvas.TextOut(Point.X, Point.Y, IntToStr(Num));
end;
procedure TGraph.DrawEdges;
var i, j: Integer;
begin
for i := 1 to High(E) do
for j := i+1 to High(E[i]) do begin
if E[i][j] > 0 then begin
Image.Canvas.Pen.Color := E[i][j];
Image.Canvas.MoveTo(V[i].X, V[i].Y);
Image.Canvas.LineTo(V[j].X, V[j].Y);
end;
end;
end;
procedure TGraph.Draw;
var i: Integer;
begin
Image.Canvas.FillRect(Image.ClientRect);
DrawEdges;
for i := 1 to High(V) do
DrawVertex(V[i], i);
end;