reductionista commented on a change in pull request #486: Graph: Filter out 
infinite paths
URL: https://github.com/apache/madlib/pull/486#discussion_r390627982
 
 

 ##########
 File path: src/ports/postgres/modules/graph/measures.py_in
 ##########
 @@ -184,10 +184,7 @@ class Graph(object):
                 -- Filtering 'Infinity' occurs in CASE instead of WHERE clause
                 -- so that the edge is part of the average value i.e. part of
                 -- the count of paths but zero addition to sum of distances.
-                AVG(CASE WHEN {e.weight} = 'Infinity'::double precision
-                            THEN 0::double precision
-                            ELSE {e.weight}::double precision
-                    END) as avg_path_length
+                AVG({e.weight}::double precision) as avg_path_length
 
 Review comment:
   Sounds good to me!
   
   Also backing up this decision, I just noticed this:
   ```
   postgres=# select madlib.graph_avg_path_length();
                                graph_avg_path_length
   
-------------------------------------------------------------------------------
   
    This function computes the average of the shortest paths between each pair 
of
    vertices. Average path length is based on "reachable target vertices", so it
    ignores infinite-length paths between vertices that are not connected.
   
    For more details:
        SELECT madlib.graph_avg_path_length('usage')
   
   (1 row)
   ```
   Pretty clear the previous behavior was a bug!  Glad we've fixed it.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to