caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Kenneth Adam Miller <kennethadammiller@gmail.com>
To: caml users <caml-list@inria.fr>
Subject: [Caml-list] OCamlgraph Strongly Connected components
Date: Wed, 8 Mar 2017 13:09:31 -0500	[thread overview]
Message-ID: <CAK7rcp_7gUCgy-uhDMJPDyqCLKhYKEvnTia4RrRZXx_M=ggBdw@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1385 bytes --]

The following code produces a non-empty list, and I don't think that it
should:

module G = Imperative.Digraph.ConcreteBidirectional(struct
...
end)

module StrongComponents = Components.Make(G)

let cfg = G.create () in
Insn_cfg.G.add_edge insn_cfg zero one;
(* just any two nodes above; that's all you need to know *)
let components = Insn_cfg.StrongComponents.scc_list cfg in
assert_equal [] components

(* Failure above! Why?? *)

The way I understand strongly connected components to work is that, for any
node to be in a component, there must be a path from itself to itself. The
following should yield [zero ; one] ---

let cfg = G.create () in
Insn_cfg.G.add_edge insn_cfg zero one;
Insn_cfg.G.add_edge insn_cfg one zero;
(* just any two nodes above; that's all you need to know *)
let components = Insn_cfg.StrongComponents.scc_list cfg in
assert_equal [zero; one] components (* don't care about order here
seriously *)


Is there a module or utility function that I could use as I would expect
the above example to behave, or do I need to filter the lists returned by
components using something like a dominator, to check to see that every
node dominates itself or some such? Also, why does strongly connected
components behave unexpectedly here? Is it my understanding that's off, or
that the implementation is one among several definitions of strongly
connected component?

[-- Attachment #2: Type: text/html, Size: 1661 bytes --]

             reply	other threads:[~2017-03-08 18:09 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-08 18:09 Kenneth Adam Miller [this message]
2017-03-08 18:15 ` Kenneth Adam Miller
2017-03-13  9:45   ` Ben Millwood
2017-03-13 12:18     ` Kenneth Adam Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAK7rcp_7gUCgy-uhDMJPDyqCLKhYKEvnTia4RrRZXx_M=ggBdw@mail.gmail.com' \
    --to=kennethadammiller@gmail.com \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).