Re: pgsql: Avoid use of float arithmetic in bipartite_match.c.

From: Andres Freund <andres(at)anarazel(dot)de>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-committers(at)postgresql(dot)org
Subject: Re: pgsql: Avoid use of float arithmetic in bipartite_match.c.
Date: 2015-08-23 17:25:46
Message-ID: 20150823172546.GI8552@awork2.anarazel.de
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Hi,

On 2015-08-23 17:02:35 +0000, Tom Lane wrote:
> Avoid use of float arithmetic in bipartite_match.c.
>
> Since the distances used in this algorithm are small integers (not more
> than the size of the U set, in fact), there is no good reason to use float
> arithmetic for them. Use short ints instead: they're smaller, faster, and
> require no special portability assumptions.

Yea, makes sense. Thanks.

> In passing, make a few other small adjustments to make the code match
> usual Postgres coding style a bit better.

Not sure why you replaced n by k? Anyway, it's not a complete
replacement afaics:
/*
* Given a bipartite graph consisting of nodes U numbered 1..nU, nodes V
* numbered 1..nV, and an adjacency map of undirected edges in the form
- * adjacency[u] = [n, v1, v2, v3, ... vn], we wish to find a "maximum
+ * adjacency[u] = [k, v1, v2, v3, ... vk], we wish to find a "maximum
* cardinality matching", which is defined as follows: a matching is a subset
* of the original edges such that no node has more than one edge, and a
* matching has maximum cardinality if there exists no other matching with a

the nodes are 1..n, so the adjacency list should be as well (or the
other way round).

Andres

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2015-08-23 17:30:45 Re: pgsql: Avoid use of float arithmetic in bipartite_match.c.
Previous Message Tom Lane 2015-08-23 17:02:35 pgsql: Avoid use of float arithmetic in bipartite_match.c.