Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1ZTZ1r-0000pM-Fn for pgsql-committers@arkaria.postgresql.org; Sun, 23 Aug 2015 17:25:59 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1ZTZ1r-0003gL-0u for pgsql-committers@arkaria.postgresql.org; Sun, 23 Aug 2015 17:25:59 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1ZTZ1q-0003eP-CK for pgsql-committers@postgresql.org; Sun, 23 Aug 2015 17:25:58 +0000 Received: from mail.anarazel.de ([217.115.131.40]) by makus.postgresql.org with esmtp (Exim 4.84) (envelope-from ) id 1ZTZ1n-0004jF-Lp for pgsql-committers@postgresql.org; Sun, 23 Aug 2015 17:25:57 +0000 Received: by mail.anarazel.de (Postfix, from userid 108) id B1751860003; Sun, 23 Aug 2015 19:25:53 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on mail X-Spam-Level: X-Spam-Status: No, score=-4.4 required=5.0 tests=ALL_TRUSTED,BAYES_00 autolearn=ham version=3.2.5 Received: from anarazel.de (p5DDC515C.dip0.t-ipconnect.de [93.220.81.92]) (Authenticated sender: andres@anarazel.de) by mail.anarazel.de (Postfix) with ESMTPSA id 2878C860002; Sun, 23 Aug 2015 19:25:47 +0200 (CEST) Received: by anarazel.de (Postfix, from userid 1000) id B088C101367; Sun, 23 Aug 2015 19:25:46 +0200 (CEST) Date: Sun, 23 Aug 2015 19:25:46 +0200 From: Andres Freund To: Tom Lane Cc: pgsql-committers@postgresql.org Subject: Re: pgsql: Avoid use of float arithmetic in bipartite_match.c. Message-ID: <20150823172546.GI8552@awork2.anarazel.de> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Pg-Spam-Score: -5.4 (-----) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-committers Precedence: bulk Sender: pgsql-committers-owner@postgresql.org 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 -- Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-committers