{"action":"created","comment":{"url":"https://api.github.com/repos/teapot-co/tempest/pulls/comments/56762767","id":56762767,"diff_hunk":"@@ -0,0 +1,40 @@\n+/*\n+ * Copyright 2016 Teapot, Inc.\n+ *\n+ * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this\n+ * file except in compliance with the License. You may obtain a copy of the License at\n+ *\n+ *     http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing, software distributed\n+ * under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR\n+ * CONDITIONS OF ANY KIND, either express or implied. See the License for the\n+ * specific language governing permissions and limitations under the License.\n+ */\n+\n+package co.teapot.graph\n+\n+/**\n+  * A transposed view of a given graph.\n+  */\n+private[graph] class TransposedGraphView(graph: DirectedGraph) extends DirectedGraph {\n+  override def outNeighbors(id: Int): IndexedSeq[Int] =\n+    graph.inNeighbors(id)\n+  override def inNeighbors(id: Int): IndexedSeq[Int] =\n+    graph.outNeighbors(id)\n+\n+  override def outNeighbor(id: Int, i: Int): Int =\n+    graph.inNeighbor(id, i)\n+  override def inNeighbor(id: Int, i: Int): Int =\n+    graph.outNeighbor(id, i)\n+\n+  override def outDegree(id: Int): Int = graph.inDegree(id)\n+  override def inDegree(id: Int): Int = graph.outDegree(id)\n+\n+  // These just defer to the underlying graph.\n+  override def maxNodeId: Int = graph.maxNodeId","path":"src/main/scala/co/teapot/graph/TransposedGraphView.scala","position":35,"original_position":35,"commit_id":"866842078e15d9a259bdab8e91264c00a3e70fcf","original_commit_id":"866842078e15d9a259bdab8e91264c00a3e70fcf","user":{"login":"ashishgpersonal","id":843109,"avatar_url":"https://avatars.githubusercontent.com/u/843109?v=3","gravatar_id":"","url":"https://api.github.com/users/ashishgpersonal","html_url":"https://github.com/ashishgpersonal","followers_url":"https://api.github.com/users/ashishgpersonal/followers","following_url":"https://api.github.com/users/ashishgpersonal/following{/other_user}","gists_url":"https://api.github.com/users/ashishgpersonal/gists{/gist_id}","starred_url":"https://api.github.com/users/ashishgpersonal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ashishgpersonal/subscriptions","organizations_url":"https://api.github.com/users/ashishgpersonal/orgs","repos_url":"https://api.github.com/users/ashishgpersonal/repos","events_url":"https://api.github.com/users/ashishgpersonal/events{/privacy}","received_events_url":"https://api.github.com/users/ashishgpersonal/received_events","type":"User","site_admin":false},"body":"I think I now understand a little better what I was saying in the earlier comment. The earlier comment doesn't make sense, since you would have to define maxNodeId. But can we define an intermediate class, something like\r\n\r\nclass PackagedDirectedGraph(graph: DirectedGraph) extends Directed Graph\r\n\r\nthat defines all the functions as you have defined maxNodeId, eg. override def OutDegree(id: Int):Int = graph.inDegree(id)\r\n\r\nAnd then, define TransPosedGraphView as extending PackagedDirectedGraph? That way, you have to only override the functions that you need to change.\r\n\r\nIt seems a little awkward to have to change every function in TransPosedGraphView and if we define additional views (eg. a BiDirectedView as in your other algorithms), this would make those simpler as well.\r\n\r\nIt is of course possible that there is an even simpler way of doing this which does not require going through PackagedDirectedGraph and I realize that the name is not ideal. But at least it requires us to only define the functionality that we change in TransPosedGraphView.","created_at":"2016-03-20T11:31:47Z","updated_at":"2016-03-20T11:31:47Z","html_url":"https://github.com/teapot-co/tempest/pull/3#discussion_r56762767","pull_request_url":"https://api.github.com/repos/teapot-co/tempest/pulls/3","_links":{"self":{"href":"https://api.github.com/repos/teapot-co/tempest/pulls/comments/56762767"},"html":{"href":"https://github.com/teapot-co/tempest/pull/3#discussion_r56762767"},"pull_request":{"href":"https://api.github.com/repos/teapot-co/tempest/pulls/3"}}},"pull_request":{"url":"https://api.github.com/repos/teapot-co/tempest/pulls/3","id":61610926,"html_url":"https://github.com/teapot-co/tempest/pull/3","diff_url":"https://github.com/teapot-co/tempest/pull/3.diff","patch_url":"https://github.com/teapot-co/tempest/pull/3.patch","issue_url":"https://api.github.com/repos/teapot-co/tempest/issues/3","number":3,"state":"open","locked":false,"title":"Implement transposed view of graph, with tests","user":{"login":"plofgren","id":6324377,"avatar_url":"https://avatars.githubusercontent.com/u/6324377?v=3","gravatar_id":"","url":"https://api.github.com/users/plofgren","html_url":"https://github.com/plofgren","followers_url":"https://api.github.com/users/plofgren/followers","following_url":"https://api.github.com/users/plofgren/following{/other_user}","gists_url":"https://api.github.com/users/plofgren/gists{/gist_id}","starred_url":"https://api.github.com/users/plofgren/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/plofgren/subscriptions","organizations_url":"https://api.github.com/users/plofgren/orgs","repos_url":"https://api.github.com/users/plofgren/repos","events_url":"https://api.github.com/users/plofgren/events{/privacy}","received_events_url":"https://api.github.com/users/plofgren/received_events","type":"User","site_admin":false},"body":"@ashishgpersonal This is a small PR to enable us to do producer cosine similarity via consumer cosine similarity on the transpose graph.","created_at":"2016-03-03T19:25:05Z","updated_at":"2016-03-20T11:31:47Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c94536d4e6c7fe60f51823a8e395c314041df1ba","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/teapot-co/tempest/pulls/3/commits","review_comments_url":"https://api.github.com/repos/teapot-co/tempest/pulls/3/comments","review_comment_url":"https://api.github.com/repos/teapot-co/tempest/pulls/comments{/number}","comments_url":"https://api.github.com/repos/teapot-co/tempest/issues/3/comments","statuses_url":"https://api.github.com/repos/teapot-co/tempest/statuses/866842078e15d9a259bdab8e91264c00a3e70fcf","head":{"label":"teapot-co:plofgren-transpose-graph","ref":"plofgren-transpose-graph","sha":"866842078e15d9a259bdab8e91264c00a3e70fcf","user":{"login":"teapot-co","id":10508237,"avatar_url":"https://avatars.githubusercontent.com/u/10508237?v=3","gravatar_id":"","url":"https://api.github.com/users/teapot-co","html_url":"https://github.com/teapot-co","followers_url":"https://api.github.com/users/teapot-co/followers","following_url":"https://api.github.com/users/teapot-co/following{/other_user}","gists_url":"https://api.github.com/users/teapot-co/gists{/gist_id}","starred_url":"https://api.github.com/users/teapot-co/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/teapot-co/subscriptions","organizations_url":"https://api.github.com/users/teapot-co/orgs","repos_url":"https://api.github.com/users/teapot-co/repos","events_url":"https://api.github.com/users/teapot-co/events{/privacy}","received_events_url":"https://api.github.com/users/teapot-co/received_events","type":"Organization","site_admin":false},"repo":{"id":52047208,"name":"tempest","full_name":"teapot-co/tempest","owner":{"login":"teapot-co","id":10508237,"avatar_url":"https://avatars.githubusercontent.com/u/10508237?v=3","gravatar_id":"","url":"https://api.github.com/users/teapot-co","html_url":"https://github.com/teapot-co","followers_url":"https://api.github.com/users/teapot-co/followers","following_url":"https://api.github.com/users/teapot-co/following{/other_user}","gists_url":"https://api.github.com/users/teapot-co/gists{/gist_id}","starred_url":"https://api.github.com/users/teapot-co/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/teapot-co/subscriptions","organizations_url":"https://api.github.com/users/teapot-co/orgs","repos_url":"https://api.github.com/users/teapot-co/repos","events_url":"https://api.github.com/users/teapot-co/events{/privacy}","received_events_url":"https://api.github.com/users/teapot-co/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/teapot-co/tempest","description":"Network storage and analytics library","fork":false,"url":"https://api.github.com/repos/teapot-co/tempest","forks_url":"https://api.github.com/repos/teapot-co/tempest/forks","keys_url":"https://api.github.com/repos/teapot-co/tempest/keys{/key_id}","collaborators_url":"https://api.github.com/repos/teapot-co/tempest/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/teapot-co/tempest/teams","hooks_url":"https://api.github.com/repos/teapot-co/tempest/hooks","issue_events_url":"https://api.github.com/repos/teapot-co/tempest/issues/events{/number}","events_url":"https://api.github.com/repos/teapot-co/tempest/events","assignees_url":"https://api.github.com/repos/teapot-co/tempest/assignees{/user}","branches_url":"https://api.github.com/repos/teapot-co/tempest/branches{/branch}","tags_url":"https://api.github.com/repos/teapot-co/tempest/tags","blobs_url":"https://api.github.com/repos/teapot-co/tempest/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/teapot-co/tempest/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/teapot-co/tempest/git/refs{/sha}","trees_url":"https://api.github.com/repos/teapot-co/tempest/git/trees{/sha}","statuses_url":"https://api.github.com/repos/teapot-co/tempest/statuses/{sha}","languages_url":"https://api.github.com/repos/teapot-co/tempest/languages","stargazers_url":"https://api.github.com/repos/teapot-co/tempest/stargazers","contributors_url":"https://api.github.com/repos/teapot-co/tempest/contributors","subscribers_url":"https://api.github.com/repos/teapot-co/tempest/subscribers","subscription_url":"https://api.github.com/repos/teapot-co/tempest/subscription","commits_url":"https://api.github.com/repos/teapot-co/tempest/commits{/sha}","git_commits_url":"https://api.github.com/repos/teapot-co/tempest/git/commits{/sha}","comments_url":"https://api.github.com/repos/teapot-co/tempest/comments{/number}","issue_comment_url":"https://api.github.com/repos/teapot-co/tempest/issues/comments{/number}","contents_url":"https://api.github.com/repos/teapot-co/tempest/contents/{+path}","compare_url":"https://api.github.com/repos/teapot-co/tempest/compare/{base}...{head}","merges_url":"https://api.github.com/repos/teapot-co/tempest/merges","archive_url":"https://api.github.com/repos/teapot-co/tempest/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/teapot-co/tempest/downloads","issues_url":"https://api.github.com/repos/teapot-co/tempest/issues{/number}","pulls_url":"https://api.github.com/repos/teapot-co/tempest/pulls{/number}","milestones_url":"https://api.github.com/repos/teapot-co/tempest/milestones{/number}","notifications_url":"https://api.github.com/repos/teapot-co/tempest/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/teapot-co/tempest/labels{/name}","releases_url":"https://api.github.com/repos/teapot-co/tempest/releases{/id}","deployments_url":"https://api.github.com/repos/teapot-co/tempest/deployments","created_at":"2016-02-18T23:40:44Z","updated_at":"2016-03-12T00:05:15Z","pushed_at":"2016-03-09T19:05:41Z","git_url":"git://github.com/teapot-co/tempest.git","ssh_url":"git@github.com:teapot-co/tempest.git","clone_url":"https://github.com/teapot-co/tempest.git","svn_url":"https://github.com/teapot-co/tempest","homepage":null,"size":437,"stargazers_count":2,"watchers_count":2,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":2,"default_branch":"master"}},"base":{"label":"teapot-co:master","ref":"master","sha":"a47d37c397fd8e3a5b39873c93afc24fc16cbfb9","user":{"login":"teapot-co","id":10508237,"avatar_url":"https://avatars.githubusercontent.com/u/10508237?v=3","gravatar_id":"","url":"https://api.github.com/users/teapot-co","html_url":"https://github.com/teapot-co","followers_url":"https://api.github.com/users/teapot-co/followers","following_url":"https://api.github.com/users/teapot-co/following{/other_user}","gists_url":"https://api.github.com/users/teapot-co/gists{/gist_id}","starred_url":"https://api.github.com/users/teapot-co/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/teapot-co/subscriptions","organizations_url":"https://api.github.com/users/teapot-co/orgs","repos_url":"https://api.github.com/users/teapot-co/repos","events_url":"https://api.github.com/users/teapot-co/events{/privacy}","received_events_url":"https://api.github.com/users/teapot-co/received_events","type":"Organization","site_admin":false},"repo":{"id":52047208,"name":"tempest","full_name":"teapot-co/tempest","owner":{"login":"teapot-co","id":10508237,"avatar_url":"https://avatars.githubusercontent.com/u/10508237?v=3","gravatar_id":"","url":"https://api.github.com/users/teapot-co","html_url":"https://github.com/teapot-co","followers_url":"https://api.github.com/users/teapot-co/followers","following_url":"https://api.github.com/users/teapot-co/following{/other_user}","gists_url":"https://api.github.com/users/teapot-co/gists{/gist_id}","starred_url":"https://api.github.com/users/teapot-co/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/teapot-co/subscriptions","organizations_url":"https://api.github.com/users/teapot-co/orgs","repos_url":"https://api.github.com/users/teapot-co/repos","events_url":"https://api.github.com/users/teapot-co/events{/privacy}","received_events_url":"https://api.github.com/users/teapot-co/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/teapot-co/tempest","description":"Network storage and analytics library","fork":false,"url":"https://api.github.com/repos/teapot-co/tempest","forks_url":"https://api.github.com/repos/teapot-co/tempest/forks","keys_url":"https://api.github.com/repos/teapot-co/tempest/keys{/key_id}","collaborators_url":"https://api.github.com/repos/teapot-co/tempest/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/teapot-co/tempest/teams","hooks_url":"https://api.github.com/repos/teapot-co/tempest/hooks","issue_events_url":"https://api.github.com/repos/teapot-co/tempest/issues/events{/number}","events_url":"https://api.github.com/repos/teapot-co/tempest/events","assignees_url":"https://api.github.com/repos/teapot-co/tempest/assignees{/user}","branches_url":"https://api.github.com/repos/teapot-co/tempest/branches{/branch}","tags_url":"https://api.github.com/repos/teapot-co/tempest/tags","blobs_url":"https://api.github.com/repos/teapot-co/tempest/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/teapot-co/tempest/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/teapot-co/tempest/git/refs{/sha}","trees_url":"https://api.github.com/repos/teapot-co/tempest/git/trees{/sha}","statuses_url":"https://api.github.com/repos/teapot-co/tempest/statuses/{sha}","languages_url":"https://api.github.com/repos/teapot-co/tempest/languages","stargazers_url":"https://api.github.com/repos/teapot-co/tempest/stargazers","contributors_url":"https://api.github.com/repos/teapot-co/tempest/contributors","subscribers_url":"https://api.github.com/repos/teapot-co/tempest/subscribers","subscription_url":"https://api.github.com/repos/teapot-co/tempest/subscription","commits_url":"https://api.github.com/repos/teapot-co/tempest/commits{/sha}","git_commits_url":"https://api.github.com/repos/teapot-co/tempest/git/commits{/sha}","comments_url":"https://api.github.com/repos/teapot-co/tempest/comments{/number}","issue_comment_url":"https://api.github.com/repos/teapot-co/tempest/issues/comments{/number}","contents_url":"https://api.github.com/repos/teapot-co/tempest/contents/{+path}","compare_url":"https://api.github.com/repos/teapot-co/tempest/compare/{base}...{head}","merges_url":"https://api.github.com/repos/teapot-co/tempest/merges","archive_url":"https://api.github.com/repos/teapot-co/tempest/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/teapot-co/tempest/downloads","issues_url":"https://api.github.com/repos/teapot-co/tempest/issues{/number}","pulls_url":"https://api.github.com/repos/teapot-co/tempest/pulls{/number}","milestones_url":"https://api.github.com/repos/teapot-co/tempest/milestones{/number}","notifications_url":"https://api.github.com/repos/teapot-co/tempest/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/teapot-co/tempest/labels{/name}","releases_url":"https://api.github.com/repos/teapot-co/tempest/releases{/id}","deployments_url":"https://api.github.com/repos/teapot-co/tempest/deployments","created_at":"2016-02-18T23:40:44Z","updated_at":"2016-03-12T00:05:15Z","pushed_at":"2016-03-09T19:05:41Z","git_url":"git://github.com/teapot-co/tempest.git","ssh_url":"git@github.com:teapot-co/tempest.git","clone_url":"https://github.com/teapot-co/tempest.git","svn_url":"https://github.com/teapot-co/tempest","homepage":null,"size":437,"stargazers_count":2,"watchers_count":2,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/teapot-co/tempest/pulls/3"},"html":{"href":"https://github.com/teapot-co/tempest/pull/3"},"issue":{"href":"https://api.github.com/repos/teapot-co/tempest/issues/3"},"comments":{"href":"https://api.github.com/repos/teapot-co/tempest/issues/3/comments"},"review_comments":{"href":"https://api.github.com/repos/teapot-co/tempest/pulls/3/comments"},"review_comment":{"href":"https://api.github.com/repos/teapot-co/tempest/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/teapot-co/tempest/pulls/3/commits"},"statuses":{"href":"https://api.github.com/repos/teapot-co/tempest/statuses/866842078e15d9a259bdab8e91264c00a3e70fcf"}}}}