caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] OCamlgraph Strongly Connected components
@ 2017-03-08 18:09 Kenneth Adam Miller
  2017-03-08 18:15 ` Kenneth Adam Miller
  0 siblings, 1 reply; 4+ messages in thread
From: Kenneth Adam Miller @ 2017-03-08 18:09 UTC (permalink / raw)
  To: caml users

[-- 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 --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Caml-list] OCamlgraph Strongly Connected components
  2017-03-08 18:09 [Caml-list] OCamlgraph Strongly Connected components Kenneth Adam Miller
@ 2017-03-08 18:15 ` Kenneth Adam Miller
  2017-03-13  9:45   ` Ben Millwood
  0 siblings, 1 reply; 4+ messages in thread
From: Kenneth Adam Miller @ 2017-03-08 18:15 UTC (permalink / raw)
  To: caml users

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

I found what I was looking for, sorry.

I can just filter the components that are of size one out quickly.

On Wed, Mar 8, 2017 at 1:09 PM, Kenneth Adam Miller <
kennethadammiller@gmail.com> wrote:

> 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: 2202 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Caml-list] OCamlgraph Strongly Connected components
  2017-03-08 18:15 ` Kenneth Adam Miller
@ 2017-03-13  9:45   ` Ben Millwood
  2017-03-13 12:18     ` Kenneth Adam Miller
  0 siblings, 1 reply; 4+ messages in thread
From: Ben Millwood @ 2017-03-13  9:45 UTC (permalink / raw)
  To: Kenneth Adam Miller; +Cc: caml users

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

This makes sense if you permit paths to be length 0, and thus every node
automatically has a path to itself. This is conceptually nice because it
means that "in the same strongly connected component" is an equivalence
relation / partition of the graph.

On 9 March 2017 at 02:15, Kenneth Adam Miller <kennethadammiller@gmail.com>
wrote:

> I found what I was looking for, sorry.
>
> I can just filter the components that are of size one out quickly.
>
> On Wed, Mar 8, 2017 at 1:09 PM, Kenneth Adam Miller <
> kennethadammiller@gmail.com> wrote:
>
>> 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: 2946 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Caml-list] OCamlgraph Strongly Connected components
  2017-03-13  9:45   ` Ben Millwood
@ 2017-03-13 12:18     ` Kenneth Adam Miller
  0 siblings, 0 replies; 4+ messages in thread
From: Kenneth Adam Miller @ 2017-03-13 12:18 UTC (permalink / raw)
  To: Ben Millwood; +Cc: caml users

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

I actually just meant that I did not want single node sized components, and
that I would operate over the others, dropping those.

What I was getting effectively included all nodes of a graph at some point
in what was returned, and I was executing an analyses that looked within
the components to remove other nodes. It was failing to remove the nodes
because of that.

On Mar 13, 2017 5:46 AM, "Ben Millwood" <bmillwood@janestreet.com> wrote:

> This makes sense if you permit paths to be length 0, and thus every node
> automatically has a path to itself. This is conceptually nice because it
> means that "in the same strongly connected component" is an equivalence
> relation / partition of the graph.
>
> On 9 March 2017 at 02:15, Kenneth Adam Miller <kennethadammiller@gmail.com
> > wrote:
>
>> I found what I was looking for, sorry.
>>
>> I can just filter the components that are of size one out quickly.
>>
>> On Wed, Mar 8, 2017 at 1:09 PM, Kenneth Adam Miller <
>> kennethadammiller@gmail.com> wrote:
>>
>>> 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: 3765 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-03-13 12:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-08 18:09 [Caml-list] OCamlgraph Strongly Connected components Kenneth Adam Miller
2017-03-08 18:15 ` Kenneth Adam Miller
2017-03-13  9:45   ` Ben Millwood
2017-03-13 12:18     ` Kenneth Adam Miller

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).