{"action":"created","comment":{"url":"https://api.github.com/repos/gonum/graph/pulls/comments/30690623","id":30690623,"diff_hunk":"@@ -87,3 +93,57 @@ func Betweenness(g graph.Graph) map[int]float64 {\n \n \treturn cb\n }\n+\n+// BetweennessWeighted returns the betweenness centrality for nodes in the weighted\n+// graph g used to construct the given shortest paths.\n+//\n+//  C_B(v) = \\sum_{s ≠ v ≠ t ∈ V} (\\sigma_{st}(v) / \\sigma_{st})\n+//\n+func BetweennessWeighted(g graph.CostGraph, p search.ShortestPaths) map[int]float64 {\n+\tnodes := g.NodeList()\n+\tcb := make(map[int]float64, len(nodes))","path":"network/betweenness.go","position":30,"original_position":30,"commit_id":"0d75a53f4afe5f0e2896ffac0d41d658fd53d8ab","original_commit_id":"0d75a53f4afe5f0e2896ffac0d41d658fd53d8ab","user":{"login":"vladimir-ch","id":1837502,"avatar_url":"https://avatars.githubusercontent.com/u/1837502?v=3","gravatar_id":"","url":"https://api.github.com/users/vladimir-ch","html_url":"https://github.com/vladimir-ch","followers_url":"https://api.github.com/users/vladimir-ch/followers","following_url":"https://api.github.com/users/vladimir-ch/following{/other_user}","gists_url":"https://api.github.com/users/vladimir-ch/gists{/gist_id}","starred_url":"https://api.github.com/users/vladimir-ch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vladimir-ch/subscriptions","organizations_url":"https://api.github.com/users/vladimir-ch/orgs","repos_url":"https://api.github.com/users/vladimir-ch/repos","events_url":"https://api.github.com/users/vladimir-ch/events{/privacy}","received_events_url":"https://api.github.com/users/vladimir-ch/received_events","type":"User","site_admin":false},"body":"Is there any reason why in Betweennes() the nodes are explicitly inserted into cb while here they are not?","created_at":"2015-05-20T11:07:39Z","updated_at":"2015-05-20T11:07:39Z","html_url":"https://github.com/gonum/graph/pull/64#discussion_r30690623","pull_request_url":"https://api.github.com/repos/gonum/graph/pulls/64","_links":{"self":{"href":"https://api.github.com/repos/gonum/graph/pulls/comments/30690623"},"html":{"href":"https://github.com/gonum/graph/pull/64#discussion_r30690623"},"pull_request":{"href":"https://api.github.com/repos/gonum/graph/pulls/64"}}},"pull_request":{"url":"https://api.github.com/repos/gonum/graph/pulls/64","id":35793930,"html_url":"https://github.com/gonum/graph/pull/64","diff_url":"https://github.com/gonum/graph/pull/64.diff","patch_url":"https://github.com/gonum/graph/pull/64.patch","issue_url":"https://api.github.com/repos/gonum/graph/issues/64","number":64,"state":"open","locked":false,"title":"network: add more network analysis measures","user":{"login":"kortschak","id":275221,"avatar_url":"https://avatars.githubusercontent.com/u/275221?v=3","gravatar_id":"","url":"https://api.github.com/users/kortschak","html_url":"https://github.com/kortschak","followers_url":"https://api.github.com/users/kortschak/followers","following_url":"https://api.github.com/users/kortschak/following{/other_user}","gists_url":"https://api.github.com/users/kortschak/gists{/gist_id}","starred_url":"https://api.github.com/users/kortschak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kortschak/subscriptions","organizations_url":"https://api.github.com/users/kortschak/orgs","repos_url":"https://api.github.com/users/kortschak/repos","events_url":"https://api.github.com/users/kortschak/events{/privacy}","received_events_url":"https://api.github.com/users/kortschak/received_events","type":"User","site_admin":false},"body":"This brings the general case for betweenness (though see below) and various centrality measures.\r\n\r\nCurrently we perform poorly for sparse graphs since we use FloydWarshal's algorithm to find shortest paths. One approach to address this would be for the functions here that take a search.ShortestPaths to take an equivalent interface (or a reduced interface for the centrality measures that only need weights) and then make search.Johnson return a type that satisfies this instead of a pair of maps. I don't want to do this because although it is an easy solution for the centrality measures it will give incorrect results for betweenness when there are non-unique shortest paths; the current implementation of Dijkstra's algorithm in search does not report more than one shortest path. So I plan to reimplement a Dijkstra's algorithm that does this, keeping the results in a search.ShortestPaths, and then call this from search.Johnson. I am not sure that I will export this implementation since the usual use case for Dijkstra is to find a single shortest path and the overhead for keeping all paths is non-trivial. Maybe we provide both.\r\n\r\nThoughts?\r\n\r\nWhichever we do, I will generate both Dijkstra implementations from a template to keep them in sync except for the path retention.\r\n\r\nAdditional tests are probably needed for the weighted cases, but they can come later. Manually validating these is painful.\r\n\r\n@vladimir-ch PTAL","created_at":"2015-05-20T02:46:10Z","updated_at":"2015-05-20T11:07:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e6c59cf53ce75e1f0fec54f9e9e536b40207b5e4","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/gonum/graph/pulls/64/commits","review_comments_url":"https://api.github.com/repos/gonum/graph/pulls/64/comments","review_comment_url":"https://api.github.com/repos/gonum/graph/pulls/comments{/number}","comments_url":"https://api.github.com/repos/gonum/graph/issues/64/comments","statuses_url":"https://api.github.com/repos/gonum/graph/statuses/0d75a53f4afe5f0e2896ffac0d41d658fd53d8ab","head":{"label":"gonum:centrality-measures","ref":"centrality-measures","sha":"0d75a53f4afe5f0e2896ffac0d41d658fd53d8ab","user":{"login":"gonum","id":3771091,"avatar_url":"https://avatars.githubusercontent.com/u/3771091?v=3","gravatar_id":"","url":"https://api.github.com/users/gonum","html_url":"https://github.com/gonum","followers_url":"https://api.github.com/users/gonum/followers","following_url":"https://api.github.com/users/gonum/following{/other_user}","gists_url":"https://api.github.com/users/gonum/gists{/gist_id}","starred_url":"https://api.github.com/users/gonum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gonum/subscriptions","organizations_url":"https://api.github.com/users/gonum/orgs","repos_url":"https://api.github.com/users/gonum/repos","events_url":"https://api.github.com/users/gonum/events{/privacy}","received_events_url":"https://api.github.com/users/gonum/received_events","type":"Organization","site_admin":false},"repo":{"id":8589420,"name":"graph","full_name":"gonum/graph","owner":{"login":"gonum","id":3771091,"avatar_url":"https://avatars.githubusercontent.com/u/3771091?v=3","gravatar_id":"","url":"https://api.github.com/users/gonum","html_url":"https://github.com/gonum","followers_url":"https://api.github.com/users/gonum/followers","following_url":"https://api.github.com/users/gonum/following{/other_user}","gists_url":"https://api.github.com/users/gonum/gists{/gist_id}","starred_url":"https://api.github.com/users/gonum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gonum/subscriptions","organizations_url":"https://api.github.com/users/gonum/orgs","repos_url":"https://api.github.com/users/gonum/repos","events_url":"https://api.github.com/users/gonum/events{/privacy}","received_events_url":"https://api.github.com/users/gonum/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/gonum/graph","description":"Discrete math structures and functions","fork":false,"url":"https://api.github.com/repos/gonum/graph","forks_url":"https://api.github.com/repos/gonum/graph/forks","keys_url":"https://api.github.com/repos/gonum/graph/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gonum/graph/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gonum/graph/teams","hooks_url":"https://api.github.com/repos/gonum/graph/hooks","issue_events_url":"https://api.github.com/repos/gonum/graph/issues/events{/number}","events_url":"https://api.github.com/repos/gonum/graph/events","assignees_url":"https://api.github.com/repos/gonum/graph/assignees{/user}","branches_url":"https://api.github.com/repos/gonum/graph/branches{/branch}","tags_url":"https://api.github.com/repos/gonum/graph/tags","blobs_url":"https://api.github.com/repos/gonum/graph/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gonum/graph/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gonum/graph/git/refs{/sha}","trees_url":"https://api.github.com/repos/gonum/graph/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gonum/graph/statuses/{sha}","languages_url":"https://api.github.com/repos/gonum/graph/languages","stargazers_url":"https://api.github.com/repos/gonum/graph/stargazers","contributors_url":"https://api.github.com/repos/gonum/graph/contributors","subscribers_url":"https://api.github.com/repos/gonum/graph/subscribers","subscription_url":"https://api.github.com/repos/gonum/graph/subscription","commits_url":"https://api.github.com/repos/gonum/graph/commits{/sha}","git_commits_url":"https://api.github.com/repos/gonum/graph/git/commits{/sha}","comments_url":"https://api.github.com/repos/gonum/graph/comments{/number}","issue_comment_url":"https://api.github.com/repos/gonum/graph/issues/comments{/number}","contents_url":"https://api.github.com/repos/gonum/graph/contents/{+path}","compare_url":"https://api.github.com/repos/gonum/graph/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gonum/graph/merges","archive_url":"https://api.github.com/repos/gonum/graph/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gonum/graph/downloads","issues_url":"https://api.github.com/repos/gonum/graph/issues{/number}","pulls_url":"https://api.github.com/repos/gonum/graph/pulls{/number}","milestones_url":"https://api.github.com/repos/gonum/graph/milestones{/number}","notifications_url":"https://api.github.com/repos/gonum/graph/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gonum/graph/labels{/name}","releases_url":"https://api.github.com/repos/gonum/graph/releases{/id}","created_at":"2013-03-05T21:22:45Z","updated_at":"2015-05-15T00:39:27Z","pushed_at":"2015-05-20T07:19:48Z","git_url":"git://github.com/gonum/graph.git","ssh_url":"git@github.com:gonum/graph.git","clone_url":"https://github.com/gonum/graph.git","svn_url":"https://github.com/gonum/graph","homepage":"","size":2277,"stargazers_count":66,"watchers_count":66,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":7,"mirror_url":null,"open_issues_count":23,"forks":7,"open_issues":23,"watchers":66,"default_branch":"master"}},"base":{"label":"gonum:master","ref":"master","sha":"1a1b98c1adb7887bad557d5666bd02c3e46ccaef","user":{"login":"gonum","id":3771091,"avatar_url":"https://avatars.githubusercontent.com/u/3771091?v=3","gravatar_id":"","url":"https://api.github.com/users/gonum","html_url":"https://github.com/gonum","followers_url":"https://api.github.com/users/gonum/followers","following_url":"https://api.github.com/users/gonum/following{/other_user}","gists_url":"https://api.github.com/users/gonum/gists{/gist_id}","starred_url":"https://api.github.com/users/gonum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gonum/subscriptions","organizations_url":"https://api.github.com/users/gonum/orgs","repos_url":"https://api.github.com/users/gonum/repos","events_url":"https://api.github.com/users/gonum/events{/privacy}","received_events_url":"https://api.github.com/users/gonum/received_events","type":"Organization","site_admin":false},"repo":{"id":8589420,"name":"graph","full_name":"gonum/graph","owner":{"login":"gonum","id":3771091,"avatar_url":"https://avatars.githubusercontent.com/u/3771091?v=3","gravatar_id":"","url":"https://api.github.com/users/gonum","html_url":"https://github.com/gonum","followers_url":"https://api.github.com/users/gonum/followers","following_url":"https://api.github.com/users/gonum/following{/other_user}","gists_url":"https://api.github.com/users/gonum/gists{/gist_id}","starred_url":"https://api.github.com/users/gonum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gonum/subscriptions","organizations_url":"https://api.github.com/users/gonum/orgs","repos_url":"https://api.github.com/users/gonum/repos","events_url":"https://api.github.com/users/gonum/events{/privacy}","received_events_url":"https://api.github.com/users/gonum/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/gonum/graph","description":"Discrete math structures and functions","fork":false,"url":"https://api.github.com/repos/gonum/graph","forks_url":"https://api.github.com/repos/gonum/graph/forks","keys_url":"https://api.github.com/repos/gonum/graph/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gonum/graph/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gonum/graph/teams","hooks_url":"https://api.github.com/repos/gonum/graph/hooks","issue_events_url":"https://api.github.com/repos/gonum/graph/issues/events{/number}","events_url":"https://api.github.com/repos/gonum/graph/events","assignees_url":"https://api.github.com/repos/gonum/graph/assignees{/user}","branches_url":"https://api.github.com/repos/gonum/graph/branches{/branch}","tags_url":"https://api.github.com/repos/gonum/graph/tags","blobs_url":"https://api.github.com/repos/gonum/graph/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gonum/graph/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gonum/graph/git/refs{/sha}","trees_url":"https://api.github.com/repos/gonum/graph/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gonum/graph/statuses/{sha}","languages_url":"https://api.github.com/repos/gonum/graph/languages","stargazers_url":"https://api.github.com/repos/gonum/graph/stargazers","contributors_url":"https://api.github.com/repos/gonum/graph/contributors","subscribers_url":"https://api.github.com/repos/gonum/graph/subscribers","subscription_url":"https://api.github.com/repos/gonum/graph/subscription","commits_url":"https://api.github.com/repos/gonum/graph/commits{/sha}","git_commits_url":"https://api.github.com/repos/gonum/graph/git/commits{/sha}","comments_url":"https://api.github.com/repos/gonum/graph/comments{/number}","issue_comment_url":"https://api.github.com/repos/gonum/graph/issues/comments{/number}","contents_url":"https://api.github.com/repos/gonum/graph/contents/{+path}","compare_url":"https://api.github.com/repos/gonum/graph/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gonum/graph/merges","archive_url":"https://api.github.com/repos/gonum/graph/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gonum/graph/downloads","issues_url":"https://api.github.com/repos/gonum/graph/issues{/number}","pulls_url":"https://api.github.com/repos/gonum/graph/pulls{/number}","milestones_url":"https://api.github.com/repos/gonum/graph/milestones{/number}","notifications_url":"https://api.github.com/repos/gonum/graph/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gonum/graph/labels{/name}","releases_url":"https://api.github.com/repos/gonum/graph/releases{/id}","created_at":"2013-03-05T21:22:45Z","updated_at":"2015-05-15T00:39:27Z","pushed_at":"2015-05-20T07:19:48Z","git_url":"git://github.com/gonum/graph.git","ssh_url":"git@github.com:gonum/graph.git","clone_url":"https://github.com/gonum/graph.git","svn_url":"https://github.com/gonum/graph","homepage":"","size":2277,"stargazers_count":66,"watchers_count":66,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":7,"mirror_url":null,"open_issues_count":23,"forks":7,"open_issues":23,"watchers":66,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/gonum/graph/pulls/64"},"html":{"href":"https://github.com/gonum/graph/pull/64"},"issue":{"href":"https://api.github.com/repos/gonum/graph/issues/64"},"comments":{"href":"https://api.github.com/repos/gonum/graph/issues/64/comments"},"review_comments":{"href":"https://api.github.com/repos/gonum/graph/pulls/64/comments"},"review_comment":{"href":"https://api.github.com/repos/gonum/graph/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/gonum/graph/pulls/64/commits"},"statuses":{"href":"https://api.github.com/repos/gonum/graph/statuses/0d75a53f4afe5f0e2896ffac0d41d658fd53d8ab"}}}}