If you have a node IDed 1 linked at a node IDed 2 via a link IDed 3; and you cut (Ctrl-X) Node IDed1 and Link IDed3, you keep the Node IDed 2 in the Graph and the others in the clipboard.
Now if you:
Paste: There's no problem, the Graph becomes like before.
Delete the Node and paste: There's no problem, The link is not useful and destroyed.
Delete the node, create a new node, and paste: The New node get IDed1, so the link conects to New node, yet it is the node you created at first!
Trick:
Change
- Code: Select all
function TSimpleGraph.GetUniqueID(PreferredID: DWORD): DWORD;
var
I: Integer;
IsUnique: Boolean;
CandidateID: DWORD;
begin
CandidateID := PreferredID;
repeat
IsUnique := True;
for I := Objects.Count - 1 downto 0 do
if Objects[I].ID = CandidateID then
begin
IsUnique := False;
Inc(CandidateID);
Break;
end;
until IsUnique;
Result := CandidateID;
end;
for
- Code: Select all
function TSimpleGraph.GetUniqueID: TDateTime;
Begin;
Result:=Now;
End;
And change all the references/declarations to IDs like DWORD for TDateTime type.
Each node will have an ID not integer, but double, and they always have different IDs, being this IDs them dates of birth too.
Any comments? Any different posibilities?