首页 > 其他分享 >Re: finding all cycles in a graph

Re: finding all cycles in a graph

时间:2023-06-08 14:36:03浏览次数:42  
标签:graph number Re octave finding cycles

ref: https://cs.stackexchange.com/questions/7216/find-the-simple-cycles-in-a-directed-graph

Re: finding all cycles in a graph
From: Juan Pablo Carbajal
Subject: Re: finding all cycles in a graph
Date: Wed, 25 Jan 2012 19:43:48 +0100
On Wed, Jan 25, 2012 at 2:52 PM, Moreno Marzolla
address@hidden wrote:

On 01/24/2012 08:55 PM, Francesco Potortì wrote:

First of all, thanks to you and to those that have answered previously.

Has anyone an Octave program for finding all cycles in a graph?

You're of course aware that there are exponentially many cycles in
general? There usually are better ways to accomplish whatever you need
than looking for all cycles of a graph.

That's what I suspect too. I have been made this request by a colleague
of mine, and anyway I think it may be a useful way of starting to
understand the problem, which anyway involves small graphs only.

Hello,

you might be interested in the algorithm described here:

Donald B. Johnson, "Finding all the elementary circuits of a directed
graph", SIAM J. Comput vol. 4 n. 1 march 1975

http://dutta.csc.ncsu.edu/csc791_spring07/wrap/circuits_johnson.pdf

The running time is O( (n+e)(c+1) ) where n=number of nodes, e=number of
edges, c=number of elementary circuits in the graph. However, as said above,
there can be an exponential number of elementary loops in the graph.

I don't know if there are Octave implementations of the algorithm above.

Moreno.

--
Moreno Marzolla
EMail: address@hidden
WWW : http://www.moreno.marzolla.name/


Help-octave mailing list
address@hidden
https://mailman.cae.wisc.edu/listinfo/help-octave

Hi Francesco & Paolo,

Definitely the '75 algorithm is worth to be checked. In case you want
to see my code (disclaimer: naive, and highly non-efficient
implementation) of the '68 paper you can get it from here
http://octave.svn.sf.net/viewvc/octave/trunk/octave-forge/main/geometry/devel/graphs/

Here a example of use:

% Create adjacency matrix (in any way you want. I use unvech from the
package general >= 1.2.2 to create a symmetric matrix)
v=round(rand(1,10)>0.4);
A=unvech(v);

[x y]=find(A==1);
i=sub2ind(size(A),x,y);
B=A;
B(i)=y;
Ac=graph2cell(A,'adj');
Bc=graph2cell(B,'varadj');
P=cellmatprod(Bc,Ac);
[P cycles]=simplepath(P);

As you can see even the interface is not the best.

If you re-implement or improve the code, please let us know.

Cheers,

标签:graph,number,Re,octave,finding,cycles
From: https://www.cnblogs.com/uceec00/p/17466361.html

相关文章

  • 在 macOS Catalina 10.15 搭建 PHP 开发环境包括PHP的redis扩展
    2019年10月8日,苹果公司正式发布了新一代macOS,版本为Catalina(11.15)。macOSCatalina预装了Ruby(2.6.3)、PHP(7.3.9)、Perl(5.18.4)、Python(2.7.16)等常用的脚本语言,以及Apache(2.4.41)Web服务器。需要注意的是,在新版本中,zsh已取代bash成为新版操作系统中的......
  • redis 基本数据类型
     所有数据都以唯一key字符串作为名称,而value只是数据类型的差异。所以,针对key的命令都是通用的。方便演示,采用docker镜像,可以选择redis:latest镜像,这里我选择了带布隆过虑器的redis镜像。 dockerrun-p6379:6379--nameredis-dredislabs/rebloom:latestd......
  • Android问题解决:android.util.Base64.encode 导致签名不匹配 SignatureDoesNotMatch
    文章目录前文:遇到问题一问:为什么SignatureDoesNotMatch二问:为什么SignatureDoesNotMatch三问:Signature请求参数为什么多了%0A四问:Signature为什么多了换行五问:android.util.Base64.encode的用法前文:遇到问题在折腾《ESP32-C3入门教程——导读》时,需要对接阿里云物联网平台。想要......
  • LightOJ - 1042 Secret Origins (模拟)水
    TimeLimit: 500MSMemoryLimit: 32768KB64bitIOFormat: %lld&%lluLightOJ-1042SecretOriginsSubmit StatusDescriptionThisisthetaleofZephyr,thegreatesttimetravelertheworldwillneverknow.EventhosewhoareawareofZephyr'sexiste......
  • CodeForces - 658A Bear and Reverse Radewoosh (模拟)水
    TimeLimit: 2000MS MemoryLimit: 262144KB 64bitIOFormat: %I64d&%I64uCodeForces-658ABearandReverseRadewooshSubmit StatusDescriptionLimakandRadewoosharegoingtocompeteagainsteachotherintheupcomingalgorithmiccontest.Theyareequ......
  • GStreamer
    overview​ gstreamer是一个支持Windows,Linux,Android,iOS的跨平台的多媒体框架。​ 本文和后续关于gstreamer的开发环境(只针对ubuntu,其他平台参考官方文档):​ ubuntu20.04.1focalAPI​ GstBus(gstreamer.freedesktop.org)安装环境官方安装教程:InstallingonLinux(gstr......
  • springboot - feign.FeignException$BadRequest: [400] during [GET] to [http:
    ERROR失败原因:、feign.FeignException$BadRequest:[400]during[GET]to[http://方法?携带的请求头条件。。。。。[ManualStockControllerFeign#deleteManualStockTaskByIds(List)]:<!doctypehtml><htmllang="en"><head><title>HTTPStatus400–Bad......
  • redis应用场景--缓存过期时间
    缓存可以有效的提高关键数据的获取速度,使得不必要每次查询数据库,避免了数据库被击穿。主动更新:需要知道这份数据的实效时间点,然后在那个时间点到来时重新更新数据,可能是查询数据库,也可能是访问第三接口,在获得数据之后,更新redis缓存。被动更新:程序每次都去redis获取数......
  • js hook RequestHeader
       //==UserScript==//@namexhr_setRequestHeader//@namespacehttp://tampermonkey.net///@version0.1//@descriptiontrytotakeovertheworld!//@authorYou//@matchhttps://ppzh.jd.com/octopusbrandweb/brand/view......
  • wsexplorer——windows下的抓包工具 可以直接抓进程对应的网络流量
    软件标签:WSExplorer抓包工具  wsexplorer1.5版本是一款非常实用的抓包工具,用户能够直接通过软件直接获取更多的数据,同时还设计了选择功能,只需挑选自己需要的数据,需要的用户快来绿色资源网下载吧!wsexplorer抓包工具简介:wsexplorer是最好用的抓包工具,1.5版本添加新功能,分离二进......