{"action":"created","comment":{"url":"https://api.github.com/repos/markreynoso/data-structures/pulls/comments/155401430","pull_request_review_id":81713927,"id":155401430,"diff_hunk":"@@ -0,0 +1,95 @@\n+\"\"\"Implement a class for a graph data structure.\"\"\"\n+\n+\n+class Graph(object):\n+    \"\"\"Graph class.\"\"\"\n+\n+    def __init__(self):\n+        \"\"\"Initialize a graph.\"\"\"\n+        self._graph = {}\n+\n+    def nodes(self):\n+        \"\"\"Return a list of all nodes in graph.\"\"\"\n+        return list(self._graph.keys())\n+\n+    def edges(self):\n+        \"\"\"Return a list of edges in graph.\"\"\"\n+        edges = []\n+        for key in self._graph:\n+            for i in self._graph[key]:\n+                edges.append((key, i))\n+        return edges\n+\n+    def add_node(self, val):\n+        \"\"\"Add a node with value of val to graph.\"\"\"\n+        self._graph[val] = {}\n+\n+    def add_edge(self, val1, val2, weight=0):\n+        \"\"\"Add a new edge to graph between val1 & val2 as well as add vals.\"\"\"\n+        if val1 in self._graph and val2 in self._graph:\n+            if val2 not in self._graph[val1]:\n+                self._graph[val1][val2] = weight\n+        elif val1 in self._graph and val2 not in self._graph:\n+            self._graph[val2] = {}\n+            self._graph[val1][val2] = weight\n+        elif val2 in self._graph and val1 not in self._graph:\n+            self._graph[val1] = {}\n+            self._graph[val1][val2] = weight\n+        else:\n+            self._graph[val1] = {val2: weight}\n+            self._graph[val2] = {}\n+\n+    def del_node(self, val):\n+        \"\"\"Delete node w/val from graph, raises exception if not exist.\"\"\"\n+        if val in self._graph:\n+            del self._graph[val]\n+            for key in self._graph:\n+                for i in self._graph[key]:\n+                    if i == val:\n+                        del self._graph[key][val]\n+        else:\n+            raise ValueError('There is no node of that value in the graph.')\n+\n+    def del_edge(self, val1, val2):\n+        \"\"\"Delete edge between val1 & val2 from graph.\"\"\"\n+        try:\n+            if val2 in self._graph[val1]:\n+                del self._graph[val1][val2]\n+            else:\n+                raise ValueError('These edges do not exist.')\n+        except KeyError:\n+            raise ValueError('These edges do not exist.')\n+\n+    def has_node(self, val):\n+        \"\"\"Return true or false if node has value.\"\"\"\n+        if val in self._graph:\n+            return True\n+        else:\n+            return False\n+\n+    def neighbors(self, val):\n+        \"\"\"Return list of nodes connected node(val).\"\"\"\n+        try:\n+            self._graph[val]\n+            neighbors = []\n+            for key in self._graph[val]:\n+                if key not in neighbors:\n+                    neighbors.append(key)\n+            for key in self._graph:\n+                for child in self._graph[key]:\n+                    if child == val and key not in neighbors:\n+                        neighbors.append(key)\n+            else:\n+                return neighbors","path":"src/graph.py","position":83,"original_position":83,"commit_id":"655414a2b7c53165e5056db8beaabb6d34443620","original_commit_id":"655414a2b7c53165e5056db8beaabb6d34443620","user":{"login":"nhuntwalker","id":5581888,"avatar_url":"https://avatars0.githubusercontent.com/u/5581888?v=4","gravatar_id":"","url":"https://api.github.com/users/nhuntwalker","html_url":"https://github.com/nhuntwalker","followers_url":"https://api.github.com/users/nhuntwalker/followers","following_url":"https://api.github.com/users/nhuntwalker/following{/other_user}","gists_url":"https://api.github.com/users/nhuntwalker/gists{/gist_id}","starred_url":"https://api.github.com/users/nhuntwalker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nhuntwalker/subscriptions","organizations_url":"https://api.github.com/users/nhuntwalker/orgs","repos_url":"https://api.github.com/users/nhuntwalker/repos","events_url":"https://api.github.com/users/nhuntwalker/events{/privacy}","received_events_url":"https://api.github.com/users/nhuntwalker/received_events","type":"User","site_admin":false},"body":"\"neighbors\" only goes one way. If \"val\" points to some other node in the graph, that other node is \"val\"'s neighbor. However, \"val\" is not that node's neighbor.","created_at":"2017-12-07T00:29:37Z","updated_at":"2017-12-07T00:30:46Z","html_url":"https://github.com/markreynoso/data-structures/pull/7#discussion_r155401430","pull_request_url":"https://api.github.com/repos/markreynoso/data-structures/pulls/7","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/markreynoso/data-structures/pulls/comments/155401430"},"html":{"href":"https://github.com/markreynoso/data-structures/pull/7#discussion_r155401430"},"pull_request":{"href":"https://api.github.com/repos/markreynoso/data-structures/pulls/7"}}},"pull_request":{"url":"https://api.github.com/repos/markreynoso/data-structures/pulls/7","id":156561297,"html_url":"https://github.com/markreynoso/data-structures/pull/7","diff_url":"https://github.com/markreynoso/data-structures/pull/7.diff","patch_url":"https://github.com/markreynoso/data-structures/pull/7.patch","issue_url":"https://api.github.com/repos/markreynoso/data-structures/issues/7","number":7,"state":"open","locked":false,"title":"Graph 1 - DO NOT MERGE","user":{"login":"markreynoso","id":27329753,"avatar_url":"https://avatars3.githubusercontent.com/u/27329753?v=4","gravatar_id":"","url":"https://api.github.com/users/markreynoso","html_url":"https://github.com/markreynoso","followers_url":"https://api.github.com/users/markreynoso/followers","following_url":"https://api.github.com/users/markreynoso/following{/other_user}","gists_url":"https://api.github.com/users/markreynoso/gists{/gist_id}","starred_url":"https://api.github.com/users/markreynoso/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/markreynoso/subscriptions","organizations_url":"https://api.github.com/users/markreynoso/orgs","repos_url":"https://api.github.com/users/markreynoso/repos","events_url":"https://api.github.com/users/markreynoso/events{/privacy}","received_events_url":"https://api.github.com/users/markreynoso/received_events","type":"User","site_admin":false},"body":"","created_at":"2017-12-05T20:06:13Z","updated_at":"2017-12-07T00:30:46Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a893ce83a6466cca04ce899af450f68720be60bf","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/markreynoso/data-structures/pulls/7/commits","review_comments_url":"https://api.github.com/repos/markreynoso/data-structures/pulls/7/comments","review_comment_url":"https://api.github.com/repos/markreynoso/data-structures/pulls/comments{/number}","comments_url":"https://api.github.com/repos/markreynoso/data-structures/issues/7/comments","statuses_url":"https://api.github.com/repos/markreynoso/data-structures/statuses/655414a2b7c53165e5056db8beaabb6d34443620","head":{"label":"markreynoso:graph_1","ref":"graph_1","sha":"655414a2b7c53165e5056db8beaabb6d34443620","user":{"login":"markreynoso","id":27329753,"avatar_url":"https://avatars3.githubusercontent.com/u/27329753?v=4","gravatar_id":"","url":"https://api.github.com/users/markreynoso","html_url":"https://github.com/markreynoso","followers_url":"https://api.github.com/users/markreynoso/followers","following_url":"https://api.github.com/users/markreynoso/following{/other_user}","gists_url":"https://api.github.com/users/markreynoso/gists{/gist_id}","starred_url":"https://api.github.com/users/markreynoso/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/markreynoso/subscriptions","organizations_url":"https://api.github.com/users/markreynoso/orgs","repos_url":"https://api.github.com/users/markreynoso/repos","events_url":"https://api.github.com/users/markreynoso/events{/privacy}","received_events_url":"https://api.github.com/users/markreynoso/received_events","type":"User","site_admin":false},"repo":{"id":111463249,"name":"data-structures","full_name":"markreynoso/data-structures","owner":{"login":"markreynoso","id":27329753,"avatar_url":"https://avatars3.githubusercontent.com/u/27329753?v=4","gravatar_id":"","url":"https://api.github.com/users/markreynoso","html_url":"https://github.com/markreynoso","followers_url":"https://api.github.com/users/markreynoso/followers","following_url":"https://api.github.com/users/markreynoso/following{/other_user}","gists_url":"https://api.github.com/users/markreynoso/gists{/gist_id}","starred_url":"https://api.github.com/users/markreynoso/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/markreynoso/subscriptions","organizations_url":"https://api.github.com/users/markreynoso/orgs","repos_url":"https://api.github.com/users/markreynoso/repos","events_url":"https://api.github.com/users/markreynoso/events{/privacy}","received_events_url":"https://api.github.com/users/markreynoso/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/markreynoso/data-structures","description":"Data-Structures","fork":true,"url":"https://api.github.com/repos/markreynoso/data-structures","forks_url":"https://api.github.com/repos/markreynoso/data-structures/forks","keys_url":"https://api.github.com/repos/markreynoso/data-structures/keys{/key_id}","collaborators_url":"https://api.github.com/repos/markreynoso/data-structures/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/markreynoso/data-structures/teams","hooks_url":"https://api.github.com/repos/markreynoso/data-structures/hooks","issue_events_url":"https://api.github.com/repos/markreynoso/data-structures/issues/events{/number}","events_url":"https://api.github.com/repos/markreynoso/data-structures/events","assignees_url":"https://api.github.com/repos/markreynoso/data-structures/assignees{/user}","branches_url":"https://api.github.com/repos/markreynoso/data-structures/branches{/branch}","tags_url":"https://api.github.com/repos/markreynoso/data-structures/tags","blobs_url":"https://api.github.com/repos/markreynoso/data-structures/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/markreynoso/data-structures/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/markreynoso/data-structures/git/refs{/sha}","trees_url":"https://api.github.com/repos/markreynoso/data-structures/git/trees{/sha}","statuses_url":"https://api.github.com/repos/markreynoso/data-structures/statuses/{sha}","languages_url":"https://api.github.com/repos/markreynoso/data-structures/languages","stargazers_url":"https://api.github.com/repos/markreynoso/data-structures/stargazers","contributors_url":"https://api.github.com/repos/markreynoso/data-structures/contributors","subscribers_url":"https://api.github.com/repos/markreynoso/data-structures/subscribers","subscription_url":"https://api.github.com/repos/markreynoso/data-structures/subscription","commits_url":"https://api.github.com/repos/markreynoso/data-structures/commits{/sha}","git_commits_url":"https://api.github.com/repos/markreynoso/data-structures/git/commits{/sha}","comments_url":"https://api.github.com/repos/markreynoso/data-structures/comments{/number}","issue_comment_url":"https://api.github.com/repos/markreynoso/data-structures/issues/comments{/number}","contents_url":"https://api.github.com/repos/markreynoso/data-structures/contents/{+path}","compare_url":"https://api.github.com/repos/markreynoso/data-structures/compare/{base}...{head}","merges_url":"https://api.github.com/repos/markreynoso/data-structures/merges","archive_url":"https://api.github.com/repos/markreynoso/data-structures/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/markreynoso/data-structures/downloads","issues_url":"https://api.github.com/repos/markreynoso/data-structures/issues{/number}","pulls_url":"https://api.github.com/repos/markreynoso/data-structures/pulls{/number}","milestones_url":"https://api.github.com/repos/markreynoso/data-structures/milestones{/number}","notifications_url":"https://api.github.com/repos/markreynoso/data-structures/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/markreynoso/data-structures/labels{/name}","releases_url":"https://api.github.com/repos/markreynoso/data-structures/releases{/id}","deployments_url":"https://api.github.com/repos/markreynoso/data-structures/deployments","created_at":"2017-11-20T21:10:49Z","updated_at":"2017-11-20T21:10:51Z","pushed_at":"2017-12-06T19:22:57Z","git_url":"git://github.com/markreynoso/data-structures.git","ssh_url":"git@github.com:markreynoso/data-structures.git","clone_url":"https://github.com/markreynoso/data-structures.git","svn_url":"https://github.com/markreynoso/data-structures","homepage":null,"size":151,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":8,"license":null,"forks":0,"open_issues":8,"watchers":0,"default_branch":"master"}},"base":{"label":"markreynoso:master","ref":"master","sha":"ffd41ab12aadd341e0e6007d217860acb6e3f6b3","user":{"login":"markreynoso","id":27329753,"avatar_url":"https://avatars3.githubusercontent.com/u/27329753?v=4","gravatar_id":"","url":"https://api.github.com/users/markreynoso","html_url":"https://github.com/markreynoso","followers_url":"https://api.github.com/users/markreynoso/followers","following_url":"https://api.github.com/users/markreynoso/following{/other_user}","gists_url":"https://api.github.com/users/markreynoso/gists{/gist_id}","starred_url":"https://api.github.com/users/markreynoso/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/markreynoso/subscriptions","organizations_url":"https://api.github.com/users/markreynoso/orgs","repos_url":"https://api.github.com/users/markreynoso/repos","events_url":"https://api.github.com/users/markreynoso/events{/privacy}","received_events_url":"https://api.github.com/users/markreynoso/received_events","type":"User","site_admin":false},"repo":{"id":111463249,"name":"data-structures","full_name":"markreynoso/data-structures","owner":{"login":"markreynoso","id":27329753,"avatar_url":"https://avatars3.githubusercontent.com/u/27329753?v=4","gravatar_id":"","url":"https://api.github.com/users/markreynoso","html_url":"https://github.com/markreynoso","followers_url":"https://api.github.com/users/markreynoso/followers","following_url":"https://api.github.com/users/markreynoso/following{/other_user}","gists_url":"https://api.github.com/users/markreynoso/gists{/gist_id}","starred_url":"https://api.github.com/users/markreynoso/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/markreynoso/subscriptions","organizations_url":"https://api.github.com/users/markreynoso/orgs","repos_url":"https://api.github.com/users/markreynoso/repos","events_url":"https://api.github.com/users/markreynoso/events{/privacy}","received_events_url":"https://api.github.com/users/markreynoso/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/markreynoso/data-structures","description":"Data-Structures","fork":true,"url":"https://api.github.com/repos/markreynoso/data-structures","forks_url":"https://api.github.com/repos/markreynoso/data-structures/forks","keys_url":"https://api.github.com/repos/markreynoso/data-structures/keys{/key_id}","collaborators_url":"https://api.github.com/repos/markreynoso/data-structures/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/markreynoso/data-structures/teams","hooks_url":"https://api.github.com/repos/markreynoso/data-structures/hooks","issue_events_url":"https://api.github.com/repos/markreynoso/data-structures/issues/events{/number}","events_url":"https://api.github.com/repos/markreynoso/data-structures/events","assignees_url":"https://api.github.com/repos/markreynoso/data-structures/assignees{/user}","branches_url":"https://api.github.com/repos/markreynoso/data-structures/branches{/branch}","tags_url":"https://api.github.com/repos/markreynoso/data-structures/tags","blobs_url":"https://api.github.com/repos/markreynoso/data-structures/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/markreynoso/data-structures/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/markreynoso/data-structures/git/refs{/sha}","trees_url":"https://api.github.com/repos/markreynoso/data-structures/git/trees{/sha}","statuses_url":"https://api.github.com/repos/markreynoso/data-structures/statuses/{sha}","languages_url":"https://api.github.com/repos/markreynoso/data-structures/languages","stargazers_url":"https://api.github.com/repos/markreynoso/data-structures/stargazers","contributors_url":"https://api.github.com/repos/markreynoso/data-structures/contributors","subscribers_url":"https://api.github.com/repos/markreynoso/data-structures/subscribers","subscription_url":"https://api.github.com/repos/markreynoso/data-structures/subscription","commits_url":"https://api.github.com/repos/markreynoso/data-structures/commits{/sha}","git_commits_url":"https://api.github.com/repos/markreynoso/data-structures/git/commits{/sha}","comments_url":"https://api.github.com/repos/markreynoso/data-structures/comments{/number}","issue_comment_url":"https://api.github.com/repos/markreynoso/data-structures/issues/comments{/number}","contents_url":"https://api.github.com/repos/markreynoso/data-structures/contents/{+path}","compare_url":"https://api.github.com/repos/markreynoso/data-structures/compare/{base}...{head}","merges_url":"https://api.github.com/repos/markreynoso/data-structures/merges","archive_url":"https://api.github.com/repos/markreynoso/data-structures/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/markreynoso/data-structures/downloads","issues_url":"https://api.github.com/repos/markreynoso/data-structures/issues{/number}","pulls_url":"https://api.github.com/repos/markreynoso/data-structures/pulls{/number}","milestones_url":"https://api.github.com/repos/markreynoso/data-structures/milestones{/number}","notifications_url":"https://api.github.com/repos/markreynoso/data-structures/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/markreynoso/data-structures/labels{/name}","releases_url":"https://api.github.com/repos/markreynoso/data-structures/releases{/id}","deployments_url":"https://api.github.com/repos/markreynoso/data-structures/deployments","created_at":"2017-11-20T21:10:49Z","updated_at":"2017-11-20T21:10:51Z","pushed_at":"2017-12-06T19:22:57Z","git_url":"git://github.com/markreynoso/data-structures.git","ssh_url":"git@github.com:markreynoso/data-structures.git","clone_url":"https://github.com/markreynoso/data-structures.git","svn_url":"https://github.com/markreynoso/data-structures","homepage":null,"size":151,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":8,"license":null,"forks":0,"open_issues":8,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/markreynoso/data-structures/pulls/7"},"html":{"href":"https://github.com/markreynoso/data-structures/pull/7"},"issue":{"href":"https://api.github.com/repos/markreynoso/data-structures/issues/7"},"comments":{"href":"https://api.github.com/repos/markreynoso/data-structures/issues/7/comments"},"review_comments":{"href":"https://api.github.com/repos/markreynoso/data-structures/pulls/7/comments"},"review_comment":{"href":"https://api.github.com/repos/markreynoso/data-structures/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/markreynoso/data-structures/pulls/7/commits"},"statuses":{"href":"https://api.github.com/repos/markreynoso/data-structures/statuses/655414a2b7c53165e5056db8beaabb6d34443620"}},"author_association":"OWNER"}}
{"actor":{"display_login":"nhuntwalker"}}