Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id C56E9200C65 for ; Fri, 14 Apr 2017 20:19:46 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id C445D160B8A; Fri, 14 Apr 2017 18:19:46 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 2061C160B8C for ; Fri, 14 Apr 2017 20:19:45 +0200 (CEST) Received: (qmail 61315 invoked by uid 500); 14 Apr 2017 18:19:40 -0000 Mailing-List: contact dev-help@madlib.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@madlib.incubator.apache.org Delivered-To: mailing list dev@madlib.incubator.apache.org Received: (qmail 61261 invoked by uid 99); 14 Apr 2017 18:19:38 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 14 Apr 2017 18:19:38 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 4CF2D18FCFB for ; Fri, 14 Apr 2017 18:19:38 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -3.221 X-Spam-Level: X-Spam-Status: No, score=-3.221 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-0.001] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id BVx_nqkiLXXW for ; Fri, 14 Apr 2017 18:19:37 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with SMTP id 645585FB49 for ; Fri, 14 Apr 2017 18:19:36 +0000 (UTC) Received: (qmail 61222 invoked by uid 99); 14 Apr 2017 18:19:35 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 14 Apr 2017 18:19:35 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 6BD1DDFFD7; Fri, 14 Apr 2017 18:19:35 +0000 (UTC) From: njayaram2 To: dev@madlib.incubator.apache.org Reply-To: dev@madlib.incubator.apache.org References: In-Reply-To: Subject: [GitHub] incubator-madlib pull request #113: Graph: Add grouping support to SSSP Content-Type: text/plain Message-Id: <20170414181935.6BD1DDFFD7@git1-us-west.apache.org> Date: Fri, 14 Apr 2017 18:19:35 +0000 (UTC) archived-at: Fri, 14 Apr 2017 18:19:46 -0000 Github user njayaram2 commented on a diff in the pull request: https://github.com/apache/incubator-madlib/pull/113#discussion_r111605403 --- Diff: src/ports/postgres/modules/graph/sssp.py_in --- @@ -378,15 +685,73 @@ weight : The total weight of the shortest path from the source vertex parent : The parent of this vertex in the shortest path from source. Will use "parent" for column naming. -The graph_sssp_get_path function will return an INT array that contains the -shortest path from the initial source vertex to the desired destination vertex. +# The graph_sssp_get_path function will return an INT array that contains the +# shortest path from the initial source vertex to the desired destination vertex. +# """ + elif message.lower() in ("example", "examples"): + help_string = """ +---------------------------------------------------------------------------- + EXAMPLES +---------------------------------------------------------------------------- +-- Create a graph, represented as vertex and edge tables. +DROP TABLE IF EXISTS vertex,edge,out,out_summary,out_path; +CREATE TABLE vertex( + id INTEGER + ); +CREATE TABLE edge( + src INTEGER, + dest INTEGER, + weight DOUBLE PRECISION +); + +INSERT INTO vertex VALUES +(0), +(1), +(2), +(3), +(4), +(5), +(6), +(7) +; +INSERT INTO edge VALUES +(0, 1, 1), +(0, 2, 1), +(0, 4, 10), +(1, 2, 2), +(1, 3, 10), +(2, 3, 1), +(2, 5, 1), +(2, 6, 3), +(3, 0, 1), +(4, 0, -2), +(5, 6, 1), +(6, 7, 1) +; + +-- Compute the SSSP: +DROP TABLE IF EXISTS pagerank_out; +SELECT madlib.graph_sssp( + 'vertex', -- Vertex table + 'id', -- Vertix id column + 'edge', -- Edge table + 'src=src, dest=dest, weight=weight', -- Comma delimted string of edge arguments + 0, -- The source vertex + 'out' -- Output table of SSSP +); +-- View the SSSP costs for every vertex: +SELECT * FROM out ORDER BY id; + +-- View the actual shortest path for a vertex: +SELECT graph_sssp_get_path('out',5,'out_path'); +SELECT * FROM out_path; --- End diff -- We should have an example with grouping in the online docs too. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastructure@apache.org or file a JIRA ticket with INFRA. ---