{"action":"created","comment":{"url":"https://api.github.com/repos/Mikelle/homework_SE/pulls/comments/27355388","id":27355388,"diff_hunk":"@@ -0,0 +1,222 @@\n+﻿open NUnit.Framework\n+\n+type IGraph<'A> =\n+  interface\n+    abstract Size: int\n+    abstract Nodes: 'A array\n+    abstract HasEdge: 'A -> 'A -> bool\n+  end\n+\n+type MGraph<'A when 'A: equality> (a: 'A array, matrix : (bool array) array) =\n+  class \n+    interface IGraph<'A> with\n+      member this.Nodes = a\n+      member this.Size = a.Length\n+      member this.HasEdge n1 n2 =\n+        let i1 = Array.findIndex (fun x -> x = n1) a\n+        let i2 = Array.findIndex (fun x -> x = n2) a\n+        matrix.[i1].[i2]\n+  end\n+\n+type LGraph<'A when 'A: equality> (arr: 'A array, arrayOfLists: ('A list) array) =\n+  class \n+    interface IGraph<'A> with\n+      member this.Nodes = arr\n+      member this.Size = arr.Length\n+      member this.HasEdge n1 n2 =\n+        let i = Array.findIndex (fun x -> x = n1) arr\n+        List.exists (fun x -> x = n2) arrayOfLists.[i]\n+   end\n+\n+let rec dfs (graph: IGraph<'A>) (visited: bool array) node f =\n+  let mutable res = []\n+  let index = Array.findIndex (fun x -> x = node) graph.Nodes\n+  visited.[index] <- true\n+  for i in 0..graph.Size - 1 do\n+    if not visited.[i]\n+      && (f = 0 && graph.HasEdge node graph.Nodes.[i]\n+        || f  = 1 && graph.HasEdge graph.Nodes.[i] node)\n+    then \n+      visited.[i] <- true\n+      res <- List.append res [graph.Nodes.[i]]\n+      res <- List.append res (dfs graph visited graph.Nodes.[i] f)\n+  res\n+\n+let availableFrom (graph: IGraph<'A>) node =\n+  let visited = [|for i in 0..graph.Size - 1 -> false|]\n+  dfs graph visited node 0\n+\n+let availableIn (graph: IGraph<'A>) node =\n+  let visited = [|for i in 0..graph.Size - 1 -> false|]\n+  dfs graph visited node 1\n+\n+type ITGraph<'A, 'T> =\n+  interface\n+    inherit IGraph<'A>\n+    abstract taggs: 'T array\n+    abstract getTag: int -> 'T\n+  end\n+\n+let example = [|5; 8; 3; 9; 2; 1; 4;|] \n+let fls = false\n+let matrix = \n+    [| \n+        [| fls;  fls;  fls;  fls;  fls;  fls;  fls;|]; \n+        [| fls;  fls; true;  fls;  fls;  fls; true;|]; \n+        [| fls;  fls;  fls; true;  fls;  fls;  fls;|]; \n+        [| fls;  fls; true;  fls;  fls;  fls;  fls;|]; \n+        [| fls;  fls;  fls;  fls;  fls; true;  fls;|]; \n+        [|true;  fls;  fls;  fls;  fls;  fls;  fls;|]; \n+        [|true;  fls;  fls; true; true;  fls;  fls;|];\n+    |]\n+let arrayOfLists = [| []; [3; 4]; [9]; [3]; [1]; [5]; [2; 5; 9] |]\n+\n+let mgraph = new MGraph<int> (example, matrix)\n+let lgraph = new LGraph<int> (example, arrayOfLists)\n+\n+[<Test>]  \n+let ``Test 01: Nodes which available from node 1 (using MGraph)``() =\n+  let a = availableFrom mgraph 1\n+  Assert.AreEqual([5], a )\n+\n+[<Test>]  \n+let ``Test 02: Nodes which available from node 2 (using MGraph)``() =\n+  let a = availableFrom mgraph 2\n+  Assert.AreEqual([1; 5], a )\n+\n+[<Test>]  \n+let ``Test 03: Nodes which available from node 3 (using MGraph)``() =\n+  let a = availableFrom mgraph 3\n+  Assert.AreEqual([9], a )\n+\n+[<Test>]  \n+let ``Test 04: Nodes which available from node 4 (using MGraph)``() =\n+  let a = availableFrom mgraph 4\n+  Assert.AreEqual([5; 9; 3; 2; 1], a )\n+\n+[<Test>]  \n+let ``Test 05: Nodes which available from node 5 (using MGraph)``() =\n+  let a = availableFrom mgraph 5\n+  Assert.AreEqual([], a )","path":"2 sem (F#)/Homework_04 (Unit tests, Calc)/hw04__31.fs","position":100,"original_position":100,"commit_id":"f8b8e7249d54f0b0035cbb5de59c82cee6871dd9","original_commit_id":"f8b8e7249d54f0b0035cbb5de59c82cee6871dd9","user":{"login":"anlun","id":711192,"avatar_url":"https://avatars.githubusercontent.com/u/711192?v=3","gravatar_id":"","url":"https://api.github.com/users/anlun","html_url":"https://github.com/anlun","followers_url":"https://api.github.com/users/anlun/followers","following_url":"https://api.github.com/users/anlun/following{/other_user}","gists_url":"https://api.github.com/users/anlun/gists{/gist_id}","starred_url":"https://api.github.com/users/anlun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/anlun/subscriptions","organizations_url":"https://api.github.com/users/anlun/orgs","repos_url":"https://api.github.com/users/anlun/repos","events_url":"https://api.github.com/users/anlun/events{/privacy}","received_events_url":"https://api.github.com/users/anlun/received_events","type":"User","site_admin":false},"body":"Многие тесты нужно переписать компактнее с TestCase.","created_at":"2015-03-29T15:33:17Z","updated_at":"2015-03-29T15:33:17Z","html_url":"https://github.com/Mikelle/homework_SE/pull/5#discussion_r27355388","pull_request_url":"https://api.github.com/repos/Mikelle/homework_SE/pulls/5","_links":{"self":{"href":"https://api.github.com/repos/Mikelle/homework_SE/pulls/comments/27355388"},"html":{"href":"https://github.com/Mikelle/homework_SE/pull/5#discussion_r27355388"},"pull_request":{"href":"https://api.github.com/repos/Mikelle/homework_SE/pulls/5"}}},"pull_request":{"url":"https://api.github.com/repos/Mikelle/homework_SE/pulls/5","id":32177383,"html_url":"https://github.com/Mikelle/homework_SE/pull/5","diff_url":"https://github.com/Mikelle/homework_SE/pull/5.diff","patch_url":"https://github.com/Mikelle/homework_SE/pull/5.patch","issue_url":"https://api.github.com/repos/Mikelle/homework_SE/issues/5","number":5,"state":"open","locked":false,"title":"Hw04","user":{"login":"Mikelle","id":5672938,"avatar_url":"https://avatars.githubusercontent.com/u/5672938?v=3","gravatar_id":"","url":"https://api.github.com/users/Mikelle","html_url":"https://github.com/Mikelle","followers_url":"https://api.github.com/users/Mikelle/followers","following_url":"https://api.github.com/users/Mikelle/following{/other_user}","gists_url":"https://api.github.com/users/Mikelle/gists{/gist_id}","starred_url":"https://api.github.com/users/Mikelle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mikelle/subscriptions","organizations_url":"https://api.github.com/users/Mikelle/orgs","repos_url":"https://api.github.com/users/Mikelle/repos","events_url":"https://api.github.com/users/Mikelle/events{/privacy}","received_events_url":"https://api.github.com/users/Mikelle/received_events","type":"User","site_admin":false},"body":"hw04 ready for cheking.","created_at":"2015-03-29T06:33:53Z","updated_at":"2015-03-29T15:33:17Z","closed_at":null,"merged_at":null,"merge_commit_sha":"91b5a83637df67169d6883a5b5817f20d06ca7a0","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Mikelle/homework_SE/pulls/5/commits","review_comments_url":"https://api.github.com/repos/Mikelle/homework_SE/pulls/5/comments","review_comment_url":"https://api.github.com/repos/Mikelle/homework_SE/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Mikelle/homework_SE/issues/5/comments","statuses_url":"https://api.github.com/repos/Mikelle/homework_SE/statuses/f8b8e7249d54f0b0035cbb5de59c82cee6871dd9","head":{"label":"Mikelle:hw04","ref":"hw04","sha":"f8b8e7249d54f0b0035cbb5de59c82cee6871dd9","user":{"login":"Mikelle","id":5672938,"avatar_url":"https://avatars.githubusercontent.com/u/5672938?v=3","gravatar_id":"","url":"https://api.github.com/users/Mikelle","html_url":"https://github.com/Mikelle","followers_url":"https://api.github.com/users/Mikelle/followers","following_url":"https://api.github.com/users/Mikelle/following{/other_user}","gists_url":"https://api.github.com/users/Mikelle/gists{/gist_id}","starred_url":"https://api.github.com/users/Mikelle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mikelle/subscriptions","organizations_url":"https://api.github.com/users/Mikelle/orgs","repos_url":"https://api.github.com/users/Mikelle/repos","events_url":"https://api.github.com/users/Mikelle/events{/privacy}","received_events_url":"https://api.github.com/users/Mikelle/received_events","type":"User","site_admin":false},"repo":{"id":24905844,"name":"homework_SE","full_name":"Mikelle/homework_SE","owner":{"login":"Mikelle","id":5672938,"avatar_url":"https://avatars.githubusercontent.com/u/5672938?v=3","gravatar_id":"","url":"https://api.github.com/users/Mikelle","html_url":"https://github.com/Mikelle","followers_url":"https://api.github.com/users/Mikelle/followers","following_url":"https://api.github.com/users/Mikelle/following{/other_user}","gists_url":"https://api.github.com/users/Mikelle/gists{/gist_id}","starred_url":"https://api.github.com/users/Mikelle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mikelle/subscriptions","organizations_url":"https://api.github.com/users/Mikelle/orgs","repos_url":"https://api.github.com/users/Mikelle/repos","events_url":"https://api.github.com/users/Mikelle/events{/privacy}","received_events_url":"https://api.github.com/users/Mikelle/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Mikelle/homework_SE","description":"Homework for SE group","fork":false,"url":"https://api.github.com/repos/Mikelle/homework_SE","forks_url":"https://api.github.com/repos/Mikelle/homework_SE/forks","keys_url":"https://api.github.com/repos/Mikelle/homework_SE/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Mikelle/homework_SE/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Mikelle/homework_SE/teams","hooks_url":"https://api.github.com/repos/Mikelle/homework_SE/hooks","issue_events_url":"https://api.github.com/repos/Mikelle/homework_SE/issues/events{/number}","events_url":"https://api.github.com/repos/Mikelle/homework_SE/events","assignees_url":"https://api.github.com/repos/Mikelle/homework_SE/assignees{/user}","branches_url":"https://api.github.com/repos/Mikelle/homework_SE/branches{/branch}","tags_url":"https://api.github.com/repos/Mikelle/homework_SE/tags","blobs_url":"https://api.github.com/repos/Mikelle/homework_SE/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Mikelle/homework_SE/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Mikelle/homework_SE/git/refs{/sha}","trees_url":"https://api.github.com/repos/Mikelle/homework_SE/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Mikelle/homework_SE/statuses/{sha}","languages_url":"https://api.github.com/repos/Mikelle/homework_SE/languages","stargazers_url":"https://api.github.com/repos/Mikelle/homework_SE/stargazers","contributors_url":"https://api.github.com/repos/Mikelle/homework_SE/contributors","subscribers_url":"https://api.github.com/repos/Mikelle/homework_SE/subscribers","subscription_url":"https://api.github.com/repos/Mikelle/homework_SE/subscription","commits_url":"https://api.github.com/repos/Mikelle/homework_SE/commits{/sha}","git_commits_url":"https://api.github.com/repos/Mikelle/homework_SE/git/commits{/sha}","comments_url":"https://api.github.com/repos/Mikelle/homework_SE/comments{/number}","issue_comment_url":"https://api.github.com/repos/Mikelle/homework_SE/issues/comments{/number}","contents_url":"https://api.github.com/repos/Mikelle/homework_SE/contents/{+path}","compare_url":"https://api.github.com/repos/Mikelle/homework_SE/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Mikelle/homework_SE/merges","archive_url":"https://api.github.com/repos/Mikelle/homework_SE/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Mikelle/homework_SE/downloads","issues_url":"https://api.github.com/repos/Mikelle/homework_SE/issues{/number}","pulls_url":"https://api.github.com/repos/Mikelle/homework_SE/pulls{/number}","milestones_url":"https://api.github.com/repos/Mikelle/homework_SE/milestones{/number}","notifications_url":"https://api.github.com/repos/Mikelle/homework_SE/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Mikelle/homework_SE/labels{/name}","releases_url":"https://api.github.com/repos/Mikelle/homework_SE/releases{/id}","created_at":"2014-10-07T18:43:43Z","updated_at":"2015-03-08T20:42:40Z","pushed_at":"2015-03-29T06:36:20Z","git_url":"git://github.com/Mikelle/homework_SE.git","ssh_url":"git@github.com:Mikelle/homework_SE.git","clone_url":"https://github.com/Mikelle/homework_SE.git","svn_url":"https://github.com/Mikelle/homework_SE","homepage":null,"size":368,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"base":{"label":"Mikelle:hw03","ref":"hw03","sha":"2de0ae164cb8f13fe69243097b2c713289e20345","user":{"login":"Mikelle","id":5672938,"avatar_url":"https://avatars.githubusercontent.com/u/5672938?v=3","gravatar_id":"","url":"https://api.github.com/users/Mikelle","html_url":"https://github.com/Mikelle","followers_url":"https://api.github.com/users/Mikelle/followers","following_url":"https://api.github.com/users/Mikelle/following{/other_user}","gists_url":"https://api.github.com/users/Mikelle/gists{/gist_id}","starred_url":"https://api.github.com/users/Mikelle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mikelle/subscriptions","organizations_url":"https://api.github.com/users/Mikelle/orgs","repos_url":"https://api.github.com/users/Mikelle/repos","events_url":"https://api.github.com/users/Mikelle/events{/privacy}","received_events_url":"https://api.github.com/users/Mikelle/received_events","type":"User","site_admin":false},"repo":{"id":24905844,"name":"homework_SE","full_name":"Mikelle/homework_SE","owner":{"login":"Mikelle","id":5672938,"avatar_url":"https://avatars.githubusercontent.com/u/5672938?v=3","gravatar_id":"","url":"https://api.github.com/users/Mikelle","html_url":"https://github.com/Mikelle","followers_url":"https://api.github.com/users/Mikelle/followers","following_url":"https://api.github.com/users/Mikelle/following{/other_user}","gists_url":"https://api.github.com/users/Mikelle/gists{/gist_id}","starred_url":"https://api.github.com/users/Mikelle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mikelle/subscriptions","organizations_url":"https://api.github.com/users/Mikelle/orgs","repos_url":"https://api.github.com/users/Mikelle/repos","events_url":"https://api.github.com/users/Mikelle/events{/privacy}","received_events_url":"https://api.github.com/users/Mikelle/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Mikelle/homework_SE","description":"Homework for SE group","fork":false,"url":"https://api.github.com/repos/Mikelle/homework_SE","forks_url":"https://api.github.com/repos/Mikelle/homework_SE/forks","keys_url":"https://api.github.com/repos/Mikelle/homework_SE/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Mikelle/homework_SE/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Mikelle/homework_SE/teams","hooks_url":"https://api.github.com/repos/Mikelle/homework_SE/hooks","issue_events_url":"https://api.github.com/repos/Mikelle/homework_SE/issues/events{/number}","events_url":"https://api.github.com/repos/Mikelle/homework_SE/events","assignees_url":"https://api.github.com/repos/Mikelle/homework_SE/assignees{/user}","branches_url":"https://api.github.com/repos/Mikelle/homework_SE/branches{/branch}","tags_url":"https://api.github.com/repos/Mikelle/homework_SE/tags","blobs_url":"https://api.github.com/repos/Mikelle/homework_SE/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Mikelle/homework_SE/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Mikelle/homework_SE/git/refs{/sha}","trees_url":"https://api.github.com/repos/Mikelle/homework_SE/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Mikelle/homework_SE/statuses/{sha}","languages_url":"https://api.github.com/repos/Mikelle/homework_SE/languages","stargazers_url":"https://api.github.com/repos/Mikelle/homework_SE/stargazers","contributors_url":"https://api.github.com/repos/Mikelle/homework_SE/contributors","subscribers_url":"https://api.github.com/repos/Mikelle/homework_SE/subscribers","subscription_url":"https://api.github.com/repos/Mikelle/homework_SE/subscription","commits_url":"https://api.github.com/repos/Mikelle/homework_SE/commits{/sha}","git_commits_url":"https://api.github.com/repos/Mikelle/homework_SE/git/commits{/sha}","comments_url":"https://api.github.com/repos/Mikelle/homework_SE/comments{/number}","issue_comment_url":"https://api.github.com/repos/Mikelle/homework_SE/issues/comments{/number}","contents_url":"https://api.github.com/repos/Mikelle/homework_SE/contents/{+path}","compare_url":"https://api.github.com/repos/Mikelle/homework_SE/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Mikelle/homework_SE/merges","archive_url":"https://api.github.com/repos/Mikelle/homework_SE/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Mikelle/homework_SE/downloads","issues_url":"https://api.github.com/repos/Mikelle/homework_SE/issues{/number}","pulls_url":"https://api.github.com/repos/Mikelle/homework_SE/pulls{/number}","milestones_url":"https://api.github.com/repos/Mikelle/homework_SE/milestones{/number}","notifications_url":"https://api.github.com/repos/Mikelle/homework_SE/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Mikelle/homework_SE/labels{/name}","releases_url":"https://api.github.com/repos/Mikelle/homework_SE/releases{/id}","created_at":"2014-10-07T18:43:43Z","updated_at":"2015-03-08T20:42:40Z","pushed_at":"2015-03-29T06:36:20Z","git_url":"git://github.com/Mikelle/homework_SE.git","ssh_url":"git@github.com:Mikelle/homework_SE.git","clone_url":"https://github.com/Mikelle/homework_SE.git","svn_url":"https://github.com/Mikelle/homework_SE","homepage":null,"size":368,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Mikelle/homework_SE/pulls/5"},"html":{"href":"https://github.com/Mikelle/homework_SE/pull/5"},"issue":{"href":"https://api.github.com/repos/Mikelle/homework_SE/issues/5"},"comments":{"href":"https://api.github.com/repos/Mikelle/homework_SE/issues/5/comments"},"review_comments":{"href":"https://api.github.com/repos/Mikelle/homework_SE/pulls/5/comments"},"review_comment":{"href":"https://api.github.com/repos/Mikelle/homework_SE/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Mikelle/homework_SE/pulls/5/commits"},"statuses":{"href":"https://api.github.com/repos/Mikelle/homework_SE/statuses/f8b8e7249d54f0b0035cbb5de59c82cee6871dd9"}}}}