MESSAGE
DATE | 2017-02-09 |
FROM | Ruben Safir
|
SUBJECT | Re: [Learn] Does this look like a Euler Path to you?
|
From learn-bounces-at-nylxs.com Thu Feb 9 23:41:03 2017 Return-Path: X-Original-To: archive-at-mrbrklyn.com Delivered-To: archive-at-mrbrklyn.com Received: from www.mrbrklyn.com (www.mrbrklyn.com [96.57.23.82]) by mrbrklyn.com (Postfix) with ESMTP id B2253161312; Thu, 9 Feb 2017 23:41:03 -0500 (EST) X-Original-To: learn-at-nylxs.com Delivered-To: learn-at-nylxs.com Received: from [10.0.0.62] (flatbush.mrbrklyn.com [10.0.0.62]) by mrbrklyn.com (Postfix) with ESMTP id 2B8EC160E77 for ; Thu, 9 Feb 2017 23:41:01 -0500 (EST) To: learn-at-nylxs.com References: <28100c8f-84dd-5a9c-a0a7-dfd08d2cec11-at-mrbrklyn.com> From: Ruben Safir Message-ID: Date: Thu, 9 Feb 2017 23:41:00 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0 MIME-Version: 1.0 In-Reply-To: <28100c8f-84dd-5a9c-a0a7-dfd08d2cec11-at-mrbrklyn.com> Subject: Re: [Learn] Does this look like a Euler Path to you? X-BeenThere: learn-at-nylxs.com X-Mailman-Version: 2.1.17 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: learn-bounces-at-nylxs.com Sender: "Learn"
this might look better
http://www.geeksforgeeks.org/eulerian-path-and-circuit/
On 02/09/2017 11:18 PM, Ruben Safir wrote: > I'm looking at this and thinking, how can it even work. > > graph[x-1][y-1] ++; > > this is undefined all together... > It came from here. I wanted to add a code example to the paper without > writing it myself. > > http://samplecodebank.blogspot.com/2011/04/eulerian-path-in-c.html > > > #include > #include > > using namespace std; > > int graph[100][100]; > int n, x, y, steps; > list path; > > void walk(int pos){ > for(int i = 0; i < n; i++){ > if(graph[pos][i] > 0){ > graph[pos][i] --; > graph[i][pos] --; > walk(i); > break; > } > } > path.push_back(pos+1); > > } > > int main(){ > > cin >> n; > for(int i = 0; i < n; i++){ > cin >> x >> y; > graph[x-1][y-1] ++; //we are using zero index > } > walk(0); > while(!path.empty()){ > cout << path.back() << ' '; > path.pop_back(); > } > } > >
-- So many immigrant groups have swept through our town that Brooklyn, like Atlantis, reaches mythological proportions in the mind of the world - RI Safir 1998 http://www.mrbrklyn.com
DRM is THEFT - We are the STAKEHOLDERS - RI Safir 2002 http://www.nylxs.com - Leadership Development in Free Software http://www2.mrbrklyn.com/resources - Unpublished Archive http://www.coinhangout.com - coins! http://www.brooklyn-living.com
Being so tracked is for FARM ANIMALS and and extermination camps, but incompatible with living as a free human being. -RI Safir 2013 _______________________________________________ Learn mailing list Learn-at-nylxs.com http://lists.mrbrklyn.com/mailman/listinfo/learn
|
|