From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.13.219.144 with SMTP id d138mr6329426ywe.30.1474911495602; Mon, 26 Sep 2016 10:38:15 -0700 (PDT) X-Received: by 10.157.51.3 with SMTP id f3mr1430054otc.4.1474911495554; Mon, 26 Sep 2016 10:38:15 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!news.glorb.com!w41no2918174qtw.1!news-out.google.com!b4ni13197iti.0!nntp.google.com!x192no4855316itb.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Mon, 26 Sep 2016 10:38:15 -0700 (PDT) In-Reply-To: <955937c4-b9f9-4e21-9d22-98382df2f45f@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=2601:2c4:103:7e10:1514:cc9a:992c:cdd; posting-account=bfqYCQoAAADhOBV9jx08D2gm5EA72sgj NNTP-Posting-Host: 2601:2c4:103:7e10:1514:cc9a:992c:cdd References: <955937c4-b9f9-4e21-9d22-98382df2f45f@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <80cedca4-c83d-4c40-920c-f3fddb8e1438@googlegroups.com> Subject: Re: New to Ada need help implementing Warshall's algorithm From: James Brewer Injection-Date: Mon, 26 Sep 2016 17:38:15 +0000 Content-Type: text/plain; charset=UTF-8 Xref: news.eternal-september.org comp.lang.ada:31902 Date: 2016-09-26T10:38:15-07:00 List-Id: Thought I would clarify my previous post. So here it goes. Ideally, the input data will look like this (the number of row and columns will vary and there will be more than one set (matrix) of data with different row and column names in the input file. example: ColName1 ColName2 ColName3 ColNameN RowName1 0 0 0 0 RowName2 1 1 1 1 RowName3 0 1 0 0 RowNameN 0 1 1 0 Here is the code I have so far without the read from file and output to file implementation. WITH Text_IO; USE Text_IO; -- This gets the IO facility. WITH Ada.Integer_Text_IO; USE Ada.Integer_Text_IO; -- This gets the integer IO facility. --**** -- use zero elements in array to store size 0,0 and row/column names? -- read size -- use size to read names of columns -- store in array -- use size to read first row of data? -- as data is read convert from 0/1 to true false and store? -- if value read = 0 => array2d(n,n) = false -- if value read = 1 => array2d(n,n) = true -- * main procedure * PROCEDURE BooleanTest IS -- Main, but no special name is needed.BEGIN N : Integer := 4; -- max size ** to be read OutputConvertion : Integer; Array2d: ARRAY (1..N, 1..N) OF boolean; -- * main procedure starts begins* BEGIN -- read array size and column names -- hard coded to be read from file Array2d(1, 1) := false; Array2d(1, 2) := false; Array2d(1, 3) := false; Array2d(1, 4) := false; Array2d(2, 1) := false; Array2d(2, 2) := true; Array2d(2, 3) := false; Array2d(2, 4) := true; Array2d(3, 1) := false; Array2d(3, 2) := true; Array2d(3, 3) := false; Array2d(3, 4) := true; Array2d(4, 1) := true; Array2d(4, 2) := false; Array2d(4, 3) := true; Array2d(4, 4) := false; FOR I IN 1..N LOOP FOR J IN 1..N LOOP IF Array2d(J,I) = true THEN --true nodes connected FOR K IN 1..N LOOP Array2d(J,K) := Array2d(J,K) OR Array2d(I,K); END LOOP; END IF; END LOOP; END LOOP; -- *********** output to screen ************ FOR I IN 1..N LOOP FOR J IN 1..N LOOP IF Array2d(I,J) = True THEN OutputConvertion := 1; ELSE OutputConvertion := 0; END IF; Put( OutputConvertion); Put(" "); END LOOP; New_Line(1); END LOOP; END BooleanTest; -- * main procedure ends * Thanks again for all the help.