Getting group of nodes

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Getting group of nodes

Alexandre Bergel-4
Hi!

I haven't closely followed the status of the moose algo. I am looking for a way to get group of interconnected nodes.

A simple test would be:

testCycle1
        | view |
        view := MOViewRenderer new.
        view nodes: (1 to: 5).
        view edges: {1 -> 2. 2 -> 3 . 4 -> 5} from: #key to: #value.
        view treeLayout.
        window := view open.

        self assert: (view root numberOfDistinctGroups = 2).
        self assert: (view root distinctGroups first includesAllOf: (1 to: 3)).
        self assert: (view root distinctGroups second includesAllOf: (4 to: 5)).

Is there some material that I can use to code #numberOfDistinctGroups and #distinctGroups ?

Cheers,
Alexandre


_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev
Reply | Threaded
Open this post in threaded view
|

Re: Getting group of nodes

Tudor Girba
Do I understand correctly that you are looking for identifying  
connected components?

In this case, you probably want the MOKruskal algorithm. Take a look  
at the description here:
http://www.moosetechnology.org/tools/moosealgos/graph

Simon, am I right?

Doru


On 10 Jun 2010, at 00:58, Alexandre Bergel wrote:

> Hi!
>
> I haven't closely followed the status of the moose algo. I am  
> looking for a way to get group of interconnected nodes.
>
> A simple test would be:
>
> testCycle1
> | view |
> view := MOViewRenderer new.
> view nodes: (1 to: 5).
> view edges: {1 -> 2. 2 -> 3 . 4 -> 5} from: #key to: #value.
> view treeLayout.
> window := view open.
>
> self assert: (view root numberOfDistinctGroups = 2).
> self assert: (view root distinctGroups first includesAllOf: (1 to:  
> 3)).
> self assert: (view root distinctGroups second includesAllOf: (4 to:  
> 5)).
>
> Is there some material that I can use to code  
> #numberOfDistinctGroups and #distinctGroups ?
>
> Cheers,
> Alexandre
>
>
> _______________________________________________
> Moose-dev mailing list
> [hidden email]
> https://www.iam.unibe.ch/mailman/listinfo/moose-dev

--
www.tudorgirba.com

"Yesterday is a fact.
  Tomorrow is a possibility.
  Today is a challenge."



_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev
Reply | Threaded
Open this post in threaded view
|

Re: Getting group of nodes

Simon Denier-3

On 10 juin 2010, at 20:29, Tudor Girba wrote:

> Do I understand correctly that you are looking for identifying connected components?
>
> In this case, you probably want the MOKruskal algorithm. Take a look at the description here:
> http://www.moosetechnology.org/tools/moosealgos/graph
>
> Simon, am I right?

MOKruskal will return edges to build some trees, not the components.

Nothing out of the box, but it's pretty easy to use MODisjointSetNode and a graph traversal to do that.

nodes do: [:n|
        n makeSet ].
nodes do: [:n|
        n nextNodes do: [:next |
                n union: next ]]
nodes inject: Dictionary new into: [:d :n |
        (d at: n find ifAbsentPut: [OrderedCollection new]) add: n ]

should return a map where each value is a connected component


>
> Doru
>
>
> On 10 Jun 2010, at 00:58, Alexandre Bergel wrote:
>
>> Hi!
>>
>> I haven't closely followed the status of the moose algo. I am looking for a way to get group of interconnected nodes.
>>
>> A simple test would be:
>>
>> testCycle1
>> | view |
>> view := MOViewRenderer new.
>> view nodes: (1 to: 5).
>> view edges: {1 -> 2. 2 -> 3 . 4 -> 5} from: #key to: #value.
>> view treeLayout.
>> window := view open.
>>
>> self assert: (view root numberOfDistinctGroups = 2).
>> self assert: (view root distinctGroups first includesAllOf: (1 to: 3)).
>> self assert: (view root distinctGroups second includesAllOf: (4 to: 5)).
>>
>> Is there some material that I can use to code #numberOfDistinctGroups and #distinctGroups ?
>>
>> Cheers,
>> Alexandre
>>
>>
>> _______________________________________________
>> Moose-dev mailing list
>> [hidden email]
>> https://www.iam.unibe.ch/mailman/listinfo/moose-dev
>
> --
> www.tudorgirba.com
>
> "Yesterday is a fact.
> Tomorrow is a possibility.
> Today is a challenge."
>
>
>
> _______________________________________________
> Moose-dev mailing list
> [hidden email]
> https://www.iam.unibe.ch/mailman/listinfo/moose-dev

--
 Simon




_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev
Reply | Threaded
Open this post in threaded view
|

Re: Getting group of nodes

Alexandre Bergel-4
> MOKruskal will return edges to build some trees, not the components.
>
> Nothing out of the box, but it's pretty easy to use MODisjointSetNode and a graph traversal to do that.
>
> nodes do: [:n|
> n makeSet ].
> nodes do: [:n|
> n nextNodes do: [:next |
> n union: next ]]
> nodes inject: Dictionary new into: [:d :n |
> (d at: n find ifAbsentPut: [OrderedCollection new]) add: n ]
>
> should return a map where each value is a connected component

I have no idea how to use this.
I tried:
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
| g |
g := MOGraphStructure new.
g nodeClass: MODisjointSetNode.
g edgeClass: MOGraphEdge.
g nodes: (1 to: 5).
g edges: {1 -> 2. 2 -> 3 . 4 -> 5} from: #key to: #value.
g nodes do: [:n|
        n makeSet ].
g nodes do: [:n|
        n nextNodes do: [:next |
                n union: next ]].
g nodes inject: Dictionary new into: [:d :n |
        (d at: n find ifAbsentPut: [OrderedCollection new]) add: n ]
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

There are 5 implementors of nextNodes: MASndNode, MATNodeNode, MOHitsNode, MOLayerNode, MOTarjanNode.

What should I do?

Alexandre


>
>
>>
>> Doru
>>
>>
>> On 10 Jun 2010, at 00:58, Alexandre Bergel wrote:
>>
>>> Hi!
>>>
>>> I haven't closely followed the status of the moose algo. I am looking for a way to get group of interconnected nodes.
>>>
>>> A simple test would be:
>>>
>>> testCycle1
>>> | view |
>>> view := MOViewRenderer new.
>>> view nodes: (1 to: 5).
>>> view edges: {1 -> 2. 2 -> 3 . 4 -> 5} from: #key to: #value.
>>> view treeLayout.
>>> window := view open.
>>>
>>> self assert: (view root numberOfDistinctGroups = 2).
>>> self assert: (view root distinctGroups first includesAllOf: (1 to: 3)).
>>> self assert: (view root distinctGroups second includesAllOf: (4 to: 5)).
>>>
>>> Is there some material that I can use to code #numberOfDistinctGroups and #distinctGroups ?
>>>
>>> Cheers,
>>> Alexandre
>>>
>>>
>>> _______________________________________________
>>> Moose-dev mailing list
>>> [hidden email]
>>> https://www.iam.unibe.ch/mailman/listinfo/moose-dev
>>
>> --
>> www.tudorgirba.com
>>
>> "Yesterday is a fact.
>> Tomorrow is a possibility.
>> Today is a challenge."
>>
>>
>>
>> _______________________________________________
>> Moose-dev mailing list
>> [hidden email]
>> https://www.iam.unibe.ch/mailman/listinfo/moose-dev
>
> --
> Simon
>
>
>
>
> _______________________________________________
> Moose-dev mailing list
> [hidden email]
> https://www.iam.unibe.ch/mailman/listinfo/moose-dev


_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev
Reply | Threaded
Open this post in threaded view
|

Re: Getting group of nodes

Simon Denier-3


Ok I defined a MADisjointSets algorithm to do what you need (indeed forgets that I needed some node with nextNodes)

See tests in MADisjointSetsTest


On 11 juin 2010, at 01:20, Alexandre Bergel wrote:

>> MOKruskal will return edges to build some trees, not the components.
>>
>> Nothing out of the box, but it's pretty easy to use MODisjointSetNode and a graph traversal to do that.
>>
>> nodes do: [:n|
>> n makeSet ].
>> nodes do: [:n|
>> n nextNodes do: [:next |
>> n union: next ]]
>> nodes inject: Dictionary new into: [:d :n |
>> (d at: n find ifAbsentPut: [OrderedCollection new]) add: n ]
>>
>> should return a map where each value is a connected component
>
> I have no idea how to use this.
> I tried:
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
> | g |
> g := MOGraphStructure new.
> g nodeClass: MODisjointSetNode.
> g edgeClass: MOGraphEdge.
> g nodes: (1 to: 5).
> g edges: {1 -> 2. 2 -> 3 . 4 -> 5} from: #key to: #value.
> g nodes do: [:n|
> n makeSet ].
> g nodes do: [:n|
> n nextNodes do: [:next |
> n union: next ]].
> g nodes inject: Dictionary new into: [:d :n |
> (d at: n find ifAbsentPut: [OrderedCollection new]) add: n ]
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
>
> There are 5 implementors of nextNodes: MASndNode, MATNodeNode, MOHitsNode, MOLayerNode, MOTarjanNode.
>
> What should I do?
>
> Alexandre
>
>
>>
>>
>>>
>>> Doru
>>>
>>>
>>> On 10 Jun 2010, at 00:58, Alexandre Bergel wrote:
>>>
>>>> Hi!
>>>>
>>>> I haven't closely followed the status of the moose algo. I am looking for a way to get group of interconnected nodes.
>>>>
>>>> A simple test would be:
>>>>
>>>> testCycle1
>>>> | view |
>>>> view := MOViewRenderer new.
>>>> view nodes: (1 to: 5).
>>>> view edges: {1 -> 2. 2 -> 3 . 4 -> 5} from: #key to: #value.
>>>> view treeLayout.
>>>> window := view open.
>>>>
>>>> self assert: (view root numberOfDistinctGroups = 2).
>>>> self assert: (view root distinctGroups first includesAllOf: (1 to: 3)).
>>>> self assert: (view root distinctGroups second includesAllOf: (4 to: 5)).
>>>>
>>>> Is there some material that I can use to code #numberOfDistinctGroups and #distinctGroups ?
>>>>
>>>> Cheers,
>>>> Alexandre
>>>>
>>>>
>>>> _______________________________________________
>>>> Moose-dev mailing list
>>>> [hidden email]
>>>> https://www.iam.unibe.ch/mailman/listinfo/moose-dev
>>>
>>> --
>>> www.tudorgirba.com
>>>
>>> "Yesterday is a fact.
>>> Tomorrow is a possibility.
>>> Today is a challenge."
>>>
>>>
>>>
>>> _______________________________________________
>>> Moose-dev mailing list
>>> [hidden email]
>>> https://www.iam.unibe.ch/mailman/listinfo/moose-dev
>>
>> --
>> Simon
>>
>>
>>
>>
>> _______________________________________________
>> Moose-dev mailing list
>> [hidden email]
>> https://www.iam.unibe.ch/mailman/listinfo/moose-dev
>
>
> _______________________________________________
> Moose-dev mailing list
> [hidden email]
> https://www.iam.unibe.ch/mailman/listinfo/moose-dev

--
 Simon




_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev
Reply | Threaded
Open this post in threaded view
|

Re: Getting group of nodes

Alexandre Bergel-4
Thanks Simon. It works, this is really really cool.

For some reason, I wasn't able to install the test in my image. I have an error (cf screenshot). The problem comes from Monticello probably.
But I was able to browse the code directly on squeaksource. Am I the only one to experience this?

In any case, your lib is excellent.

Cheers,
Alexandre




On 11 Jun 2010, at 05:22, Simon Denier wrote:

>
>
> Ok I defined a MADisjointSets algorithm to do what you need (indeed forgets that I needed some node with nextNodes)
>
> See tests in MADisjointSetsTest
>
>
> On 11 juin 2010, at 01:20, Alexandre Bergel wrote:
>
>>> MOKruskal will return edges to build some trees, not the components.
>>>
>>> Nothing out of the box, but it's pretty easy to use MODisjointSetNode and a graph traversal to do that.
>>>
>>> nodes do: [:n|
>>> n makeSet ].
>>> nodes do: [:n|
>>> n nextNodes do: [:next |
>>> n union: next ]]
>>> nodes inject: Dictionary new into: [:d :n |
>>> (d at: n find ifAbsentPut: [OrderedCollection new]) add: n ]
>>>
>>> should return a map where each value is a connected component
>>
>> I have no idea how to use this.
>> I tried:
>> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
>> | g |
>> g := MOGraphStructure new.
>> g nodeClass: MODisjointSetNode.
>> g edgeClass: MOGraphEdge.
>> g nodes: (1 to: 5).
>> g edges: {1 -> 2. 2 -> 3 . 4 -> 5} from: #key to: #value.
>> g nodes do: [:n|
>> n makeSet ].
>> g nodes do: [:n|
>> n nextNodes do: [:next |
>> n union: next ]].
>> g nodes inject: Dictionary new into: [:d :n |
>> (d at: n find ifAbsentPut: [OrderedCollection new]) add: n ]
>> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
>>
>> There are 5 implementors of nextNodes: MASndNode, MATNodeNode, MOHitsNode, MOLayerNode, MOTarjanNode.
>>
>> What should I do?
>>
>> Alexandre
>>
>>
>>>
>>>
>>>>
>>>> Doru
>>>>
>>>>
>>>> On 10 Jun 2010, at 00:58, Alexandre Bergel wrote:
>>>>
>>>>> Hi!
>>>>>
>>>>> I haven't closely followed the status of the moose algo. I am looking for a way to get group of interconnected nodes.
>>>>>
>>>>> A simple test would be:
>>>>>
>>>>> testCycle1
>>>>> | view |
>>>>> view := MOViewRenderer new.
>>>>> view nodes: (1 to: 5).
>>>>> view edges: {1 -> 2. 2 -> 3 . 4 -> 5} from: #key to: #value.
>>>>> view treeLayout.
>>>>> window := view open.
>>>>>
>>>>> self assert: (view root numberOfDistinctGroups = 2).
>>>>> self assert: (view root distinctGroups first includesAllOf: (1 to: 3)).
>>>>> self assert: (view root distinctGroups second includesAllOf: (4 to: 5)).
>>>>>
>>>>> Is there some material that I can use to code #numberOfDistinctGroups and #distinctGroups ?
>>>>>
>>>>> Cheers,
>>>>> Alexandre
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> Moose-dev mailing list
>>>>> [hidden email]
>>>>> https://www.iam.unibe.ch/mailman/listinfo/moose-dev
>>>>
>>>> --
>>>> www.tudorgirba.com
>>>>
>>>> "Yesterday is a fact.
>>>> Tomorrow is a possibility.
>>>> Today is a challenge."
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> Moose-dev mailing list
>>>> [hidden email]
>>>> https://www.iam.unibe.ch/mailman/listinfo/moose-dev
>>>
>>> --
>>> Simon
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> Moose-dev mailing list
>>> [hidden email]
>>> https://www.iam.unibe.ch/mailman/listinfo/moose-dev
>>
>>
>> _______________________________________________
>> Moose-dev mailing list
>> [hidden email]
>> https://www.iam.unibe.ch/mailman/listinfo/moose-dev
>
> --
> Simon
>
>
>
>
> _______________________________________________
> Moose-dev mailing list
> [hidden email]
> https://www.iam.unibe.ch/mailman/listinfo/moose-dev

_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev

Screen shot 2010-06-11 at 09.29.22.png (171K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Getting group of nodes

Tudor Girba
Hi,

Indeed, the library is really cool :).

Cheers,
Doru


On 11 Jun 2010, at 15:30, Alexandre Bergel wrote:

> Thanks Simon. It works, this is really really cool.
>
> For some reason, I wasn't able to install the test in my image. I  
> have an error (cf screenshot). The problem comes from Monticello  
> probably.
> But I was able to browse the code directly on squeaksource. Am I the  
> only one to experience this?
>
> In any case, your lib is excellent.
>
> Cheers,
> Alexandre
>
> <Screen shot 2010-06-11 at 09.29.22.png>
>
> On 11 Jun 2010, at 05:22, Simon Denier wrote:
>
>>
>>
>> Ok I defined a MADisjointSets algorithm to do what you need (indeed  
>> forgets that I needed some node with nextNodes)
>>
>> See tests in MADisjointSetsTest
>>
>>
>> On 11 juin 2010, at 01:20, Alexandre Bergel wrote:
>>
>>>> MOKruskal will return edges to build some trees, not the  
>>>> components.
>>>>
>>>> Nothing out of the box, but it's pretty easy to use  
>>>> MODisjointSetNode and a graph traversal to do that.
>>>>
>>>> nodes do: [:n|
>>>> n makeSet ].
>>>> nodes do: [:n|
>>>> n nextNodes do: [:next |
>>>> n union: next ]]
>>>> nodes inject: Dictionary new into: [:d :n |
>>>> (d at: n find ifAbsentPut: [OrderedCollection new]) add: n ]
>>>>
>>>> should return a map where each value is a connected component
>>>
>>> I have no idea how to use this.
>>> I tried:
>>> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
>>> | g |
>>> g := MOGraphStructure new.
>>> g nodeClass: MODisjointSetNode.
>>> g edgeClass: MOGraphEdge.
>>> g nodes: (1 to: 5).
>>> g edges: {1 -> 2. 2 -> 3 . 4 -> 5} from: #key to: #value.
>>> g nodes do: [:n|
>>> n makeSet ].
>>> g nodes do: [:n|
>>> n nextNodes do: [:next |
>>> n union: next ]].
>>> g nodes inject: Dictionary new into: [:d :n |
>>> (d at: n find ifAbsentPut: [OrderedCollection new]) add: n ]
>>> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
>>>
>>> There are 5 implementors of nextNodes: MASndNode, MATNodeNode,  
>>> MOHitsNode, MOLayerNode, MOTarjanNode.
>>>
>>> What should I do?
>>>
>>> Alexandre
>>>
>>>
>>>>
>>>>
>>>>>
>>>>> Doru
>>>>>
>>>>>
>>>>> On 10 Jun 2010, at 00:58, Alexandre Bergel wrote:
>>>>>
>>>>>> Hi!
>>>>>>
>>>>>> I haven't closely followed the status of the moose algo. I am  
>>>>>> looking for a way to get group of interconnected nodes.
>>>>>>
>>>>>> A simple test would be:
>>>>>>
>>>>>> testCycle1
>>>>>> | view |
>>>>>> view := MOViewRenderer new.
>>>>>> view nodes: (1 to: 5).
>>>>>> view edges: {1 -> 2. 2 -> 3 . 4 -> 5} from: #key to: #value.
>>>>>> view treeLayout.
>>>>>> window := view open.
>>>>>>
>>>>>> self assert: (view root numberOfDistinctGroups = 2).
>>>>>> self assert: (view root distinctGroups first includesAllOf: (1  
>>>>>> to: 3)).
>>>>>> self assert: (view root distinctGroups second includesAllOf:  
>>>>>> (4 to: 5)).
>>>>>>
>>>>>> Is there some material that I can use to code  
>>>>>> #numberOfDistinctGroups and #distinctGroups ?
>>>>>>
>>>>>> Cheers,
>>>>>> Alexandre
>>>>>>
>>>>>>
>>>>>> _______________________________________________
>>>>>> Moose-dev mailing list
>>>>>> [hidden email]
>>>>>> https://www.iam.unibe.ch/mailman/listinfo/moose-dev
>>>>>
>>>>> --
>>>>> www.tudorgirba.com
>>>>>
>>>>> "Yesterday is a fact.
>>>>> Tomorrow is a possibility.
>>>>> Today is a challenge."
>>>>>
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> Moose-dev mailing list
>>>>> [hidden email]
>>>>> https://www.iam.unibe.ch/mailman/listinfo/moose-dev
>>>>
>>>> --
>>>> Simon
>>>>
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> Moose-dev mailing list
>>>> [hidden email]
>>>> https://www.iam.unibe.ch/mailman/listinfo/moose-dev
>>>
>>>
>>> _______________________________________________
>>> Moose-dev mailing list
>>> [hidden email]
>>> https://www.iam.unibe.ch/mailman/listinfo/moose-dev
>>
>> --
>> Simon
>>
>>
>>
>>
>> _______________________________________________
>> Moose-dev mailing list
>> [hidden email]
>> https://www.iam.unibe.ch/mailman/listinfo/moose-dev
>
> _______________________________________________
> Moose-dev mailing list
> [hidden email]
> https://www.iam.unibe.ch/mailman/listinfo/moose-dev

--
www.tudorgirba.com

"What we can governs what we wish."



_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev
Reply | Threaded
Open this post in threaded view
|

Re: Getting group of nodes

Simon Denier-3
In reply to this post by Alexandre Bergel-4

On 11 juin 2010, at 15:30, Alexandre Bergel wrote:

> Thanks Simon. It works, this is really really cool.
>
> For some reason, I wasn't able to install the test in my image. I have an error (cf screenshot). The problem comes from Monticello probably.
> But I was able to browse the code directly on squeaksource. Am I the only one to experience this?

No problem here.

This kind of problem seems to happen from time to time with squeaksource. Try again?

>
> In any case, your lib is excellent.
>
> Cheers,
> Alexandre
>
> <Screen shot 2010-06-11 at 09.29.22.png>
>
> On 11 Jun 2010, at 05:22, Simon Denier wrote:
>
>>
>>
>> Ok I defined a MADisjointSets algorithm to do what you need (indeed forgets that I needed some node with nextNodes)
>>
>> See tests in MADisjointSetsTest
>>
>>
>> On 11 juin 2010, at 01:20, Alexandre Bergel wrote:
>>
>>>> MOKruskal will return edges to build some trees, not the components.
>>>>
>>>> Nothing out of the box, but it's pretty easy to use MODisjointSetNode and a graph traversal to do that.
>>>>
>>>> nodes do: [:n|
>>>> n makeSet ].
>>>> nodes do: [:n|
>>>> n nextNodes do: [:next |
>>>> n union: next ]]
>>>> nodes inject: Dictionary new into: [:d :n |
>>>> (d at: n find ifAbsentPut: [OrderedCollection new]) add: n ]
>>>>
>>>> should return a map where each value is a connected component
>>>
>>> I have no idea how to use this.
>>> I tried:
>>> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
>>> | g |
>>> g := MOGraphStructure new.
>>> g nodeClass: MODisjointSetNode.
>>> g edgeClass: MOGraphEdge.
>>> g nodes: (1 to: 5).
>>> g edges: {1 -> 2. 2 -> 3 . 4 -> 5} from: #key to: #value.
>>> g nodes do: [:n|
>>> n makeSet ].
>>> g nodes do: [:n|
>>> n nextNodes do: [:next |
>>> n union: next ]].
>>> g nodes inject: Dictionary new into: [:d :n |
>>> (d at: n find ifAbsentPut: [OrderedCollection new]) add: n ]
>>> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
>>>
>>> There are 5 implementors of nextNodes: MASndNode, MATNodeNode, MOHitsNode, MOLayerNode, MOTarjanNode.
>>>
>>> What should I do?
>>>
>>> Alexandre
>>>
>>>
>>>>
>>>>
>>>>>
>>>>> Doru
>>>>>
>>>>>
>>>>> On 10 Jun 2010, at 00:58, Alexandre Bergel wrote:
>>>>>
>>>>>> Hi!
>>>>>>
>>>>>> I haven't closely followed the status of the moose algo. I am looking for a way to get group of interconnected nodes.
>>>>>>
>>>>>> A simple test would be:
>>>>>>
>>>>>> testCycle1
>>>>>> | view |
>>>>>> view := MOViewRenderer new.
>>>>>> view nodes: (1 to: 5).
>>>>>> view edges: {1 -> 2. 2 -> 3 . 4 -> 5} from: #key to: #value.
>>>>>> view treeLayout.
>>>>>> window := view open.
>>>>>>
>>>>>> self assert: (view root numberOfDistinctGroups = 2).
>>>>>> self assert: (view root distinctGroups first includesAllOf: (1 to: 3)).
>>>>>> self assert: (view root distinctGroups second includesAllOf: (4 to: 5)).
>>>>>>
>>>>>> Is there some material that I can use to code #numberOfDistinctGroups and #distinctGroups ?
>>>>>>
>>>>>> Cheers,
>>>>>> Alexandre
>>>>>>
>>>>>>
>>>>>> _______________________________________________
>>>>>> Moose-dev mailing list
>>>>>> [hidden email]
>>>>>> https://www.iam.unibe.ch/mailman/listinfo/moose-dev
>>>>>
>>>>> --
>>>>> www.tudorgirba.com
>>>>>
>>>>> "Yesterday is a fact.
>>>>> Tomorrow is a possibility.
>>>>> Today is a challenge."
>>>>>
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> Moose-dev mailing list
>>>>> [hidden email]
>>>>> https://www.iam.unibe.ch/mailman/listinfo/moose-dev
>>>>
>>>> --
>>>> Simon
>>>>
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> Moose-dev mailing list
>>>> [hidden email]
>>>> https://www.iam.unibe.ch/mailman/listinfo/moose-dev
>>>
>>>
>>> _______________________________________________
>>> Moose-dev mailing list
>>> [hidden email]
>>> https://www.iam.unibe.ch/mailman/listinfo/moose-dev
>>
>> --
>> Simon
>>
>>
>>
>>
>> _______________________________________________
>> Moose-dev mailing list
>> [hidden email]
>> https://www.iam.unibe.ch/mailman/listinfo/moose-dev
>
> _______________________________________________
> Moose-dev mailing list
> [hidden email]
> https://www.iam.unibe.ch/mailman/listinfo/moose-dev

--
 Simon




_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev
Reply | Threaded
Open this post in threaded view
|

Re: Getting group of nodes

Alexandre Bergel-4
> No problem here.
>
> This kind of problem seems to happen from time to time with squeaksource. Try again?

I still have the problem.
Strange...

Cheers,
Alexandre

>
>>
>> In any case, your lib is excellent.
>>
>> Cheers,
>> Alexandre
>>
>> <Screen shot 2010-06-11 at 09.29.22.png>
>>
>> On 11 Jun 2010, at 05:22, Simon Denier wrote:
>>
>>>
>>>
>>> Ok I defined a MADisjointSets algorithm to do what you need (indeed forgets that I needed some node with nextNodes)
>>>
>>> See tests in MADisjointSetsTest
>>>
>>>
>>> On 11 juin 2010, at 01:20, Alexandre Bergel wrote:
>>>
>>>>> MOKruskal will return edges to build some trees, not the components.
>>>>>
>>>>> Nothing out of the box, but it's pretty easy to use MODisjointSetNode and a graph traversal to do that.
>>>>>
>>>>> nodes do: [:n|
>>>>> n makeSet ].
>>>>> nodes do: [:n|
>>>>> n nextNodes do: [:next |
>>>>> n union: next ]]
>>>>> nodes inject: Dictionary new into: [:d :n |
>>>>> (d at: n find ifAbsentPut: [OrderedCollection new]) add: n ]
>>>>>
>>>>> should return a map where each value is a connected component
>>>>
>>>> I have no idea how to use this.
>>>> I tried:
>>>> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
>>>> | g |
>>>> g := MOGraphStructure new.
>>>> g nodeClass: MODisjointSetNode.
>>>> g edgeClass: MOGraphEdge.
>>>> g nodes: (1 to: 5).
>>>> g edges: {1 -> 2. 2 -> 3 . 4 -> 5} from: #key to: #value.
>>>> g nodes do: [:n|
>>>> n makeSet ].
>>>> g nodes do: [:n|
>>>> n nextNodes do: [:next |
>>>> n union: next ]].
>>>> g nodes inject: Dictionary new into: [:d :n |
>>>> (d at: n find ifAbsentPut: [OrderedCollection new]) add: n ]
>>>> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
>>>>
>>>> There are 5 implementors of nextNodes: MASndNode, MATNodeNode, MOHitsNode, MOLayerNode, MOTarjanNode.
>>>>
>>>> What should I do?
>>>>
>>>> Alexandre
>>>>
>>>>
>>>>>
>>>>>
>>>>>>
>>>>>> Doru
>>>>>>
>>>>>>
>>>>>> On 10 Jun 2010, at 00:58, Alexandre Bergel wrote:
>>>>>>
>>>>>>> Hi!
>>>>>>>
>>>>>>> I haven't closely followed the status of the moose algo. I am looking for a way to get group of interconnected nodes.
>>>>>>>
>>>>>>> A simple test would be:
>>>>>>>
>>>>>>> testCycle1
>>>>>>> | view |
>>>>>>> view := MOViewRenderer new.
>>>>>>> view nodes: (1 to: 5).
>>>>>>> view edges: {1 -> 2. 2 -> 3 . 4 -> 5} from: #key to: #value.
>>>>>>> view treeLayout.
>>>>>>> window := view open.
>>>>>>>
>>>>>>> self assert: (view root numberOfDistinctGroups = 2).
>>>>>>> self assert: (view root distinctGroups first includesAllOf: (1 to: 3)).
>>>>>>> self assert: (view root distinctGroups second includesAllOf: (4 to: 5)).
>>>>>>>
>>>>>>> Is there some material that I can use to code #numberOfDistinctGroups and #distinctGroups ?
>>>>>>>
>>>>>>> Cheers,
>>>>>>> Alexandre
>>>>>>>
>>>>>>>
>>>>>>> _______________________________________________
>>>>>>> Moose-dev mailing list
>>>>>>> [hidden email]
>>>>>>> https://www.iam.unibe.ch/mailman/listinfo/moose-dev
>>>>>>
>>>>>> --
>>>>>> www.tudorgirba.com
>>>>>>
>>>>>> "Yesterday is a fact.
>>>>>> Tomorrow is a possibility.
>>>>>> Today is a challenge."
>>>>>>
>>>>>>
>>>>>>
>>>>>> _______________________________________________
>>>>>> Moose-dev mailing list
>>>>>> [hidden email]
>>>>>> https://www.iam.unibe.ch/mailman/listinfo/moose-dev
>>>>>
>>>>> --
>>>>> Simon
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> Moose-dev mailing list
>>>>> [hidden email]
>>>>> https://www.iam.unibe.ch/mailman/listinfo/moose-dev
>>>>
>>>>
>>>> _______________________________________________
>>>> Moose-dev mailing list
>>>> [hidden email]
>>>> https://www.iam.unibe.ch/mailman/listinfo/moose-dev
>>>
>>> --
>>> Simon
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> Moose-dev mailing list
>>> [hidden email]
>>> https://www.iam.unibe.ch/mailman/listinfo/moose-dev
>>
>> _______________________________________________
>> Moose-dev mailing list
>> [hidden email]
>> https://www.iam.unibe.ch/mailman/listinfo/moose-dev
>
> --
> Simon
>
>
>
>
> _______________________________________________
> Moose-dev mailing list
> [hidden email]
> https://www.iam.unibe.ch/mailman/listinfo/moose-dev


_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev