Pascal,找到2个图节点之间的所有方法

时间:2016-06-19 18:35:59

标签: graph pascal

我在PascalABC.Net计划中工作,寻找两点(图形节点)之间的所有方法。每个点都标有数字。图形以这种方式描述:在根文件夹中有一些带有点数的文件夹。每个文件只包含一个文件'info.txt',其中包含当前点所连接的点数。

程序应该以这种方式工作:用户写入所有点的数量(在计算过程中使用它,var nopall),起点数(var nosp)和数量结束点(var nofp)。程序获取此信息并连接到与当前点连接的最小点。它还检查重复(它们不应该发生)。但问题是它没有找到所有方法,它只是改变了最后一点并开始寻找新的方法。我应该按照我的计划做些什么呢?

program buildway;

var
paw: uint64; 
nopall: uint64;
nosp: uint64;
nofp: uint64;
lastpoint: uint64;  
wayfiletxt: text;
wayfilestr: string;
mapdir: string;
infotxt: text;
infostr: string;
connection: boolean;
pastpoint: uint64;

label start, check;

begin
  //user writes the var
  writeln('nop(all), nosp, nofp');
  readln(nopall);
  readln(nosp);
  readln(nofp);
//
  mapdir := GetDir;
  wayfilestr := IntToStr(nosp);
  lastpoint := nosp;
  paw := paw + 1;
  start:

  if lastpoint = nofp then
  begin
  ChDir(mapdir);
  Assign(wayfiletxt, 'way.txt');
  Append(wayfiletxt);
  Writeln(wayfiletxt, wayfilestr);
  Close(wayfiletxt);
  while
  WayfileStr[Length(WayfileStr)] <> '/'
    do
    SetLength(WayFileStr, Length(Wayfilestr) - 1); 
  SetLength(WayFileStr, Length(Wayfilestr) - 1); 
  if
  paw = nopall
    then
    paw := 0;
  paw := paw + 1;
 lastpoint := pastpoint;
 goto start;

 end;

 if paw = nosp
then
  begin
  paw := paw + 1;
  goto start;
  end;

connection := False;

while paw <= nopall
do
begin

//it's cheking for repeats
if
Pos(IntToStr(paw), '/' + wayfilestr + '/') <> 0
then    
begin
  paw := paw + 1;
  goto start;
end;  
  //
  //and there's cheking for connection
ChDir(mapdir);
ChDir(IntToStr(lastpoint));
Assign(infotxt, 'info.txt');
Reset(infotxt);
Read(infotxt, infostr);
begin
  check:
  if
  Pos('{' + paw + '}', infostr) = 0
      then
    while
    seekeof(infotxt) = False
      do
    begin
      readln(infotxt, infostr);
      goto check;
    end;
  if
  Pos('{' + paw + '}', infostr) <> 0
      then
    connection := True;
end;
Close(infotxt);
  //
  //variant 1
if connection = True then
begin
  wayfilestr := wayfilestr + '/' + paw;
  pastpoint := lastpoint;
  lastpoint := paw;
  if paw <> nofp
    then
    paw := 1;
  goto start;
end;
  //
  //variant 2
if connection = False then
begin
  paw := paw + 1;
  goto start;
end;  
//
end;
end.

0 个答案:

没有答案