find cycles in an undirected graph with GAMS

Dear GAMS users,

have you ever coded an algorithm to find cycles in an undirected graph with GAMS? If so, could you share it? Otherwise, any help is most welcome :slight_smile:

Best regards

Fede


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.

Fede: Hi, I would find that useful. So I offer my help to develop/test. Feel free to write me if you want to work together.

Regards
Claudio

On Thu, Feb 26, 2015 at 2:45 PM, Federico Perea wrote:

Dear GAMS users,

have you ever coded an algorithm to find cycles in an undirected graph with GAMS? If so, could you share it? Otherwise, any help is most welcome :slight_smile:

Best regards

Fede


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.

\

To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.

Hello Claudio,

apparently, the best way to approach the problem is by means of the Depth-first search algorithm

Any idea on how to start?

Regards

Fede




On Mon, Mar 2, 2015 at 7:03 PM, Claudio Delpino wrote:

Fede: Hi, I would find that useful. So I offer my help to develop/test. Feel free to write me if you want to work together.

Regards
Claudio

On Thu, Feb 26, 2015 at 2:45 PM, Federico Perea wrote:

Dear GAMS users,

have you ever coded an algorithm to find cycles in an undirected graph with GAMS? If so, could you share it? Otherwise, any help is most welcome :slight_smile:

Best regards

Fede


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.

\

To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.

\

To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.

Fede,

Sometimes it’s easiest to move the data from GAMS to another environment and implement some data analysis there. Since depth-first-search (DFS) is quite simple when implemented recursively, I implemented a little code in R to return the number of connected components and the number of such components with cycles in them. The GAMS code and R script are attached.

To get this started I used our Data Utilities Model Library, specifically model invert1 from datalib. It contained all the GDX back and forth: I just changed the algorithmic details in the R script that came with the invert1 example. There are other examples in datalib relevant to Matlab, Excel, Access, etc., etc.

-Steve

On Mon, Mar 9, 2015 at 5:37 PM, Federico Perea wrote:

Hello Claudio,

apparently, the best way to approach the problem is by means of the Depth-first search algorithm

Any idea on how to start?

Regards

Fede




On Mon, Mar 2, 2015 at 7:03 PM, Claudio Delpino wrote:

Fede: Hi, I would find that useful. So I offer my help to develop/test. Feel free to write me if you want to work together.

Regards
Claudio

On Thu, Feb 26, 2015 at 2:45 PM, Federico Perea wrote:

Dear GAMS users,

have you ever coded an algorithm to find cycles in an undirected graph with GAMS? If so, could you share it? Otherwise, any help is most welcome :slight_smile:

Best regards

Fede


cycleDetect.gms (813 Bytes)
cycleDetect.r (1.93 KB)

Hi
The r package igraph has an algorithm already implemented for the lazy among us… (Also dijkstra and so on)
Renger


Sent from my Samsung Note 4


-------- Original message --------
From: Steven Dirkse
Date: 10/03/2015 21:08 (GMT+01:00)
To: gamsworld@googlegroups.com
Subject: Re: find cycles in an undirected graph with GAMS

Fede,

Sometimes it’s easiest to move the data from GAMS to another environment and implement some data analysis there. Since depth-first-search (DFS) is quite simple when implemented recursively, I implemented a little code in R to return the number of connected components and the number of such components with cycles in them. The GAMS code and R script are attached.

To get this started I used our Data Utilities Model Library, specifically model invert1 from datalib. It contained all the GDX back and forth: I just changed the algorithmic details in the R script that came with the invert1 example. There are other examples in datalib relevant to Matlab, Excel, Access, etc., etc.

-Steve

On Mon, Mar 9, 2015 at 5:37 PM, Federico Perea wrote:

Hello Claudio,

apparently, the best way to approach the problem is by means of the Depth-first search algorithm

Any idea on how to start?

Regards

Fede




On Mon, Mar 2, 2015 at 7:03 PM, Claudio Delpino wrote:

Fede: Hi, I would find that useful. So I offer my help to develop/test. Feel free to write me if you want to work together.

Regards
Claudio

On Thu, Feb 26, 2015 at 2:45 PM, Federico Perea wrote:

Dear GAMS users,

have you ever coded an algorithm to find cycles in an undirected graph with GAMS? If so, could you share it? Otherwise, any help is most welcome :slight_smile:

Best regards

Fede


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.

\

To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.

\

To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.



\

Steven Dirkse, Ph.D.
GAMS Development Corp., Washington DC
Voice: (202)342-0180 Fax: (202)342-0181
sdirkse@gams.com
http://www.gams.com


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.

Thank you guys! I am not an r-user myself, but I will have a look at Steven code and see what I can get :slight_smile:

Regards

Fede

On Tue, Mar 10, 2015 at 9:58 PM, Renger van Nieuwkoop wrote:

Hi
The r package igraph has an algorithm already implemented for the lazy among us… (Also dijkstra and so on)
Renger


Sent from my Samsung Note 4


-------- Original message --------
From: Steven Dirkse
Date: 10/03/2015 21:08 (GMT+01:00)
To: gamsworld@googlegroups.com
Subject: Re: find cycles in an undirected graph with GAMS

Fede,

Sometimes it’s easiest to move the data from GAMS to another environment and implement some data analysis there. Since depth-first-search (DFS) is quite simple when implemented recursively, I implemented a little code in R to return the number of connected components and the number of such components with cycles in them. The GAMS code and R script are attached.

To get this started I used our Data Utilities Model Library, specifically model invert1 from datalib. It contained all the GDX back and forth: I just changed the algorithmic details in the R script that came with the invert1 example. There are other examples in datalib relevant to Matlab, Excel, Access, etc., etc.

-Steve

On Mon, Mar 9, 2015 at 5:37 PM, Federico Perea wrote:

Hello Claudio,

apparently, the best way to approach the problem is by means of the Depth-first search algorithm

Any idea on how to start?

Regards

Fede




On Mon, Mar 2, 2015 at 7:03 PM, Claudio Delpino wrote:

Fede: Hi, I would find that useful. So I offer my help to develop/test. Feel free to write me if you want to work together.

Regards
Claudio

On Thu, Feb 26, 2015 at 2:45 PM, Federico Perea wrote:

Dear GAMS users,

have you ever coded an algorithm to find cycles in an undirected graph with GAMS? If so, could you share it? Otherwise, any help is most welcome :slight_smile:

Best regards

Fede


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.

\

To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.

\

To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.



\

Steven Dirkse, Ph.D.
GAMS Development Corp., Washington DC
Voice: (202)342-0180 Fax: (202)342-0181
sdirkse@gams.com
http://www.gams.com


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.

\

To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.