{"action":"created","comment":{"url":"https://api.github.com/repos/graphframes/graphframes/pulls/comments/52394572","id":52394572,"diff_hunk":"@@ -150,21 +225,87 @@ TODO\n \n # Subgraphs\n \n+In GraphX, the `subgraph()` method takes an edge triplet (edge, src vertex, and dst vertex, plus\n+attributes) and allows the user to select a subgraph based on triplet and vertex filters.\n+\n+GraphFrames provide an even more powerful way to select subgraphs based on a combination of\n+motif finding and DataFrame filters.\n+\n+**Simple subgraph: vertex and edge filters**:\n+The following example shows how to select a subgraph based upon vertex and edge filters.\n+\n <div class=\"codetabs\">\n \n <div data-lang=\"scala\"  markdown=\"1\">\n {% highlight scala %}\n-val g: GraphFrame = ...  // Create a GraphFrame\n+import org.graphframes.examples\n+val g: GraphFrame = examples.Graphs.friends\n \n-TODO\n+// Select subgraph of users older than 30, and edges of type \"friend\"\n+val v2 = g.vertices.filter(\"age > 30\")\n+val e2 = g.edges.filter(\"relationship = 'friend'\")\n+val g2 = GraphFrame(v2, e2)\n {% endhighlight %}\n </div>\n \n <div data-lang=\"python\"  markdown=\"1\">\n {% highlight python %}\n-g = ...  # Create a GraphFrame\n+from graphframes.examples import Graphs\n+g = Graphs(sqlContext).friends()  # Get example graph\n \n-TODO\n+# Select subgraph of users older than 30, and edges of type \"friend\"\n+v2 = g.vertices.filter(\"age > 30\")\n+e2 = g.edges.filter(\"relationship = 'friend'\")\n+g2 = GraphFrame(v2, e2)\n+{% endhighlight %}\n+</div>\n+\n+</div>\n+\n+**Complex subgraph: triplet filters**:\n+The following example shows how to select a subgraph based upon triplet filters which\n+operate on an edge and its src and dst vertices.  This example could be extended to go beyond\n+triplets by using more complex motifs.\n+\n+<div class=\"codetabs\">\n+\n+<div data-lang=\"scala\"  markdown=\"1\">\n+{% highlight scala %}\n+import org.graphframes.examples\n+val g: GraphFrame = examples.Graphs.friends  // get example graph\n+\n+// Select subgraph based on edges of type \"follow\"\n+// pointing from a younger user to an older user.\n+val paths = g.find(\"(a)-[e]->(b)\")","path":"docs/user-guide.md","position":215,"original_position":215,"commit_id":"d4033501fa740593b7f83741c55cab2a1e2dc1c2","original_commit_id":"d4033501fa740593b7f83741c55cab2a1e2dc1c2","user":{"login":"jkbradley","id":5084283,"avatar_url":"https://avatars.githubusercontent.com/u/5084283?v=3","gravatar_id":"","url":"https://api.github.com/users/jkbradley","html_url":"https://github.com/jkbradley","followers_url":"https://api.github.com/users/jkbradley/followers","following_url":"https://api.github.com/users/jkbradley/following{/other_user}","gists_url":"https://api.github.com/users/jkbradley/gists{/gist_id}","starred_url":"https://api.github.com/users/jkbradley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jkbradley/subscriptions","organizations_url":"https://api.github.com/users/jkbradley/orgs","repos_url":"https://api.github.com/users/jkbradley/repos","events_url":"https://api.github.com/users/jkbradley/events{/privacy}","received_events_url":"https://api.github.com/users/jkbradley/received_events","type":"User","site_admin":false},"body":"e is an edge; it's the right syntax","created_at":"2016-02-09T23:46:31Z","updated_at":"2016-02-09T23:46:31Z","html_url":"https://github.com/graphframes/graphframes/pull/4#discussion_r52394572","pull_request_url":"https://api.github.com/repos/graphframes/graphframes/pulls/4","_links":{"self":{"href":"https://api.github.com/repos/graphframes/graphframes/pulls/comments/52394572"},"html":{"href":"https://github.com/graphframes/graphframes/pull/4#discussion_r52394572"},"pull_request":{"href":"https://api.github.com/repos/graphframes/graphframes/pulls/4"}}},"pull_request":{"url":"https://api.github.com/repos/graphframes/graphframes/pulls/4","id":58797646,"html_url":"https://github.com/graphframes/graphframes/pull/4","diff_url":"https://github.com/graphframes/graphframes/pull/4.diff","patch_url":"https://github.com/graphframes/graphframes/pull/4.patch","issue_url":"https://api.github.com/repos/graphframes/graphframes/issues/4","number":4,"state":"open","locked":false,"title":"Doc for subgraphs.  Example friends graph.","user":{"login":"jkbradley","id":5084283,"avatar_url":"https://avatars.githubusercontent.com/u/5084283?v=3","gravatar_id":"","url":"https://api.github.com/users/jkbradley","html_url":"https://github.com/jkbradley","followers_url":"https://api.github.com/users/jkbradley/followers","following_url":"https://api.github.com/users/jkbradley/following{/other_user}","gists_url":"https://api.github.com/users/jkbradley/gists{/gist_id}","starred_url":"https://api.github.com/users/jkbradley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jkbradley/subscriptions","organizations_url":"https://api.github.com/users/jkbradley/orgs","repos_url":"https://api.github.com/users/jkbradley/repos","events_url":"https://api.github.com/users/jkbradley/events{/privacy}","received_events_url":"https://api.github.com/users/jkbradley/received_events","type":"User","site_admin":false},"body":"Doc for subgraphs in user-guide.\r\nExample friends graph available in Scala and Python.\r\n\r\nMinor fixes:\r\n* quick-start pyspark shell\r\n* user-guide: graph creation\r\n* Remove println from debugging\r\n* Persist vertices when creating graph from edges only","created_at":"2016-02-09T19:39:21Z","updated_at":"2016-02-09T23:46:31Z","closed_at":null,"merged_at":null,"merge_commit_sha":"24ee696681441ecd8f75d3647fc150fb31648e5a","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/graphframes/graphframes/pulls/4/commits","review_comments_url":"https://api.github.com/repos/graphframes/graphframes/pulls/4/comments","review_comment_url":"https://api.github.com/repos/graphframes/graphframes/pulls/comments{/number}","comments_url":"https://api.github.com/repos/graphframes/graphframes/issues/4/comments","statuses_url":"https://api.github.com/repos/graphframes/graphframes/statuses/d4033501fa740593b7f83741c55cab2a1e2dc1c2","head":{"label":"jkbradley:subgraphs","ref":"subgraphs","sha":"d4033501fa740593b7f83741c55cab2a1e2dc1c2","user":{"login":"jkbradley","id":5084283,"avatar_url":"https://avatars.githubusercontent.com/u/5084283?v=3","gravatar_id":"","url":"https://api.github.com/users/jkbradley","html_url":"https://github.com/jkbradley","followers_url":"https://api.github.com/users/jkbradley/followers","following_url":"https://api.github.com/users/jkbradley/following{/other_user}","gists_url":"https://api.github.com/users/jkbradley/gists{/gist_id}","starred_url":"https://api.github.com/users/jkbradley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jkbradley/subscriptions","organizations_url":"https://api.github.com/users/jkbradley/orgs","repos_url":"https://api.github.com/users/jkbradley/repos","events_url":"https://api.github.com/users/jkbradley/events{/privacy}","received_events_url":"https://api.github.com/users/jkbradley/received_events","type":"User","site_admin":false},"repo":{"id":50961016,"name":"graphframes","full_name":"jkbradley/graphframes","owner":{"login":"jkbradley","id":5084283,"avatar_url":"https://avatars.githubusercontent.com/u/5084283?v=3","gravatar_id":"","url":"https://api.github.com/users/jkbradley","html_url":"https://github.com/jkbradley","followers_url":"https://api.github.com/users/jkbradley/followers","following_url":"https://api.github.com/users/jkbradley/following{/other_user}","gists_url":"https://api.github.com/users/jkbradley/gists{/gist_id}","starred_url":"https://api.github.com/users/jkbradley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jkbradley/subscriptions","organizations_url":"https://api.github.com/users/jkbradley/orgs","repos_url":"https://api.github.com/users/jkbradley/repos","events_url":"https://api.github.com/users/jkbradley/events{/privacy}","received_events_url":"https://api.github.com/users/jkbradley/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jkbradley/graphframes","description":"","fork":true,"url":"https://api.github.com/repos/jkbradley/graphframes","forks_url":"https://api.github.com/repos/jkbradley/graphframes/forks","keys_url":"https://api.github.com/repos/jkbradley/graphframes/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jkbradley/graphframes/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jkbradley/graphframes/teams","hooks_url":"https://api.github.com/repos/jkbradley/graphframes/hooks","issue_events_url":"https://api.github.com/repos/jkbradley/graphframes/issues/events{/number}","events_url":"https://api.github.com/repos/jkbradley/graphframes/events","assignees_url":"https://api.github.com/repos/jkbradley/graphframes/assignees{/user}","branches_url":"https://api.github.com/repos/jkbradley/graphframes/branches{/branch}","tags_url":"https://api.github.com/repos/jkbradley/graphframes/tags","blobs_url":"https://api.github.com/repos/jkbradley/graphframes/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jkbradley/graphframes/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jkbradley/graphframes/git/refs{/sha}","trees_url":"https://api.github.com/repos/jkbradley/graphframes/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jkbradley/graphframes/statuses/{sha}","languages_url":"https://api.github.com/repos/jkbradley/graphframes/languages","stargazers_url":"https://api.github.com/repos/jkbradley/graphframes/stargazers","contributors_url":"https://api.github.com/repos/jkbradley/graphframes/contributors","subscribers_url":"https://api.github.com/repos/jkbradley/graphframes/subscribers","subscription_url":"https://api.github.com/repos/jkbradley/graphframes/subscription","commits_url":"https://api.github.com/repos/jkbradley/graphframes/commits{/sha}","git_commits_url":"https://api.github.com/repos/jkbradley/graphframes/git/commits{/sha}","comments_url":"https://api.github.com/repos/jkbradley/graphframes/comments{/number}","issue_comment_url":"https://api.github.com/repos/jkbradley/graphframes/issues/comments{/number}","contents_url":"https://api.github.com/repos/jkbradley/graphframes/contents/{+path}","compare_url":"https://api.github.com/repos/jkbradley/graphframes/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jkbradley/graphframes/merges","archive_url":"https://api.github.com/repos/jkbradley/graphframes/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jkbradley/graphframes/downloads","issues_url":"https://api.github.com/repos/jkbradley/graphframes/issues{/number}","pulls_url":"https://api.github.com/repos/jkbradley/graphframes/pulls{/number}","milestones_url":"https://api.github.com/repos/jkbradley/graphframes/milestones{/number}","notifications_url":"https://api.github.com/repos/jkbradley/graphframes/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jkbradley/graphframes/labels{/name}","releases_url":"https://api.github.com/repos/jkbradley/graphframes/releases{/id}","deployments_url":"https://api.github.com/repos/jkbradley/graphframes/deployments","created_at":"2016-02-03T00:02:52Z","updated_at":"2016-02-03T00:02:55Z","pushed_at":"2016-02-09T19:48:48Z","git_url":"git://github.com/jkbradley/graphframes.git","ssh_url":"git@github.com:jkbradley/graphframes.git","clone_url":"https://github.com/jkbradley/graphframes.git","svn_url":"https://github.com/jkbradley/graphframes","homepage":null,"size":412,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"graphframes:master","ref":"master","sha":"fb11cdedd88e645980bdaa6eb94faac6313ee20c","user":{"login":"graphframes","id":16808115,"avatar_url":"https://avatars.githubusercontent.com/u/16808115?v=3","gravatar_id":"","url":"https://api.github.com/users/graphframes","html_url":"https://github.com/graphframes","followers_url":"https://api.github.com/users/graphframes/followers","following_url":"https://api.github.com/users/graphframes/following{/other_user}","gists_url":"https://api.github.com/users/graphframes/gists{/gist_id}","starred_url":"https://api.github.com/users/graphframes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/graphframes/subscriptions","organizations_url":"https://api.github.com/users/graphframes/orgs","repos_url":"https://api.github.com/users/graphframes/repos","events_url":"https://api.github.com/users/graphframes/events{/privacy}","received_events_url":"https://api.github.com/users/graphframes/received_events","type":"Organization","site_admin":false},"repo":{"id":50067430,"name":"graphframes","full_name":"graphframes/graphframes","owner":{"login":"graphframes","id":16808115,"avatar_url":"https://avatars.githubusercontent.com/u/16808115?v=3","gravatar_id":"","url":"https://api.github.com/users/graphframes","html_url":"https://github.com/graphframes","followers_url":"https://api.github.com/users/graphframes/followers","following_url":"https://api.github.com/users/graphframes/following{/other_user}","gists_url":"https://api.github.com/users/graphframes/gists{/gist_id}","starred_url":"https://api.github.com/users/graphframes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/graphframes/subscriptions","organizations_url":"https://api.github.com/users/graphframes/orgs","repos_url":"https://api.github.com/users/graphframes/repos","events_url":"https://api.github.com/users/graphframes/events{/privacy}","received_events_url":"https://api.github.com/users/graphframes/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/graphframes/graphframes","description":"","fork":false,"url":"https://api.github.com/repos/graphframes/graphframes","forks_url":"https://api.github.com/repos/graphframes/graphframes/forks","keys_url":"https://api.github.com/repos/graphframes/graphframes/keys{/key_id}","collaborators_url":"https://api.github.com/repos/graphframes/graphframes/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/graphframes/graphframes/teams","hooks_url":"https://api.github.com/repos/graphframes/graphframes/hooks","issue_events_url":"https://api.github.com/repos/graphframes/graphframes/issues/events{/number}","events_url":"https://api.github.com/repos/graphframes/graphframes/events","assignees_url":"https://api.github.com/repos/graphframes/graphframes/assignees{/user}","branches_url":"https://api.github.com/repos/graphframes/graphframes/branches{/branch}","tags_url":"https://api.github.com/repos/graphframes/graphframes/tags","blobs_url":"https://api.github.com/repos/graphframes/graphframes/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/graphframes/graphframes/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/graphframes/graphframes/git/refs{/sha}","trees_url":"https://api.github.com/repos/graphframes/graphframes/git/trees{/sha}","statuses_url":"https://api.github.com/repos/graphframes/graphframes/statuses/{sha}","languages_url":"https://api.github.com/repos/graphframes/graphframes/languages","stargazers_url":"https://api.github.com/repos/graphframes/graphframes/stargazers","contributors_url":"https://api.github.com/repos/graphframes/graphframes/contributors","subscribers_url":"https://api.github.com/repos/graphframes/graphframes/subscribers","subscription_url":"https://api.github.com/repos/graphframes/graphframes/subscription","commits_url":"https://api.github.com/repos/graphframes/graphframes/commits{/sha}","git_commits_url":"https://api.github.com/repos/graphframes/graphframes/git/commits{/sha}","comments_url":"https://api.github.com/repos/graphframes/graphframes/comments{/number}","issue_comment_url":"https://api.github.com/repos/graphframes/graphframes/issues/comments{/number}","contents_url":"https://api.github.com/repos/graphframes/graphframes/contents/{+path}","compare_url":"https://api.github.com/repos/graphframes/graphframes/compare/{base}...{head}","merges_url":"https://api.github.com/repos/graphframes/graphframes/merges","archive_url":"https://api.github.com/repos/graphframes/graphframes/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/graphframes/graphframes/downloads","issues_url":"https://api.github.com/repos/graphframes/graphframes/issues{/number}","pulls_url":"https://api.github.com/repos/graphframes/graphframes/pulls{/number}","milestones_url":"https://api.github.com/repos/graphframes/graphframes/milestones{/number}","notifications_url":"https://api.github.com/repos/graphframes/graphframes/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/graphframes/graphframes/labels{/name}","releases_url":"https://api.github.com/repos/graphframes/graphframes/releases{/id}","deployments_url":"https://api.github.com/repos/graphframes/graphframes/deployments","created_at":"2016-01-20T23:17:56Z","updated_at":"2016-02-03T00:01:24Z","pushed_at":"2016-02-09T19:48:48Z","git_url":"git://github.com/graphframes/graphframes.git","ssh_url":"git@github.com:graphframes/graphframes.git","clone_url":"https://github.com/graphframes/graphframes.git","svn_url":"https://github.com/graphframes/graphframes","homepage":null,"size":401,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":1,"forks":2,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/graphframes/graphframes/pulls/4"},"html":{"href":"https://github.com/graphframes/graphframes/pull/4"},"issue":{"href":"https://api.github.com/repos/graphframes/graphframes/issues/4"},"comments":{"href":"https://api.github.com/repos/graphframes/graphframes/issues/4/comments"},"review_comments":{"href":"https://api.github.com/repos/graphframes/graphframes/pulls/4/comments"},"review_comment":{"href":"https://api.github.com/repos/graphframes/graphframes/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/graphframes/graphframes/pulls/4/commits"},"statuses":{"href":"https://api.github.com/repos/graphframes/graphframes/statuses/d4033501fa740593b7f83741c55cab2a1e2dc1c2"}}}}