MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Finding Clusters

  • To: mathgroup at smc.vnet.net
  • Subject: [mg104558] Re: [mg104515] Finding Clusters
  • From: mante <claude.mante at univmed.fr>
  • Date: Wed, 4 Nov 2009 01:32:18 -0500 (EST)
  • References: <200911030751.CAA01018@smc.vnet.net>

fd a écrit :
> All.
>
> I have a list which represents some natural event. These events are
> listed pair-wise, which corresponds to event happening within certain
> time interval from each other, as below
>
> event={{1,2},{1,3},{3,4},{5,6},{7,8},{8,10}}
>
> I wish to find a thread of events, i.e. if event A is related to B and
> B to C, I wish to group {A,B,C} together. For the example above I
> would have
>
> {{1,2,3,4},{5,6},{7,8,10}}
>
> This would correspond to do a Graph Plot and identifying the parts
> which are disconnected It should be simple but I'm really finding it
> troublesome.
>
>   
The 1st point is to build a convenient distance :
    Dist01[list1_, list2_] := If[Length@Union[list1, list2] < 4, 0, 1];
then compute the distance matrix:
    Adj = Outer[Dist01, event, event, 1];
and you get the graph:
    GraphPlot[1 - Adj, VertexLabeling -> True]

You can also use another strategy :
    Cls = FindClusters[event, DistanceFunction -> Dist01];
    Map[Composition[Union, Flatten], Cls]

-- 
*********************************

    Claude Manté, IR CNRS

UMR CNRS 6117 LMGEM
http://www.com.univ-mrs.fr/LMGEM/

Centre d'Océanologie de Marseille
Campus de Luminy, Case 901
13288 MARSEILLE Cedex 09
tel : (+33) 491 829 127
fax : (+33) 491 829 119

HdR: http://hal.archives-ouvertes.fr/

********************************* 



  • Prev by Date: Re: Conventional way of doing "struct"-like things?
  • Next by Date: Re: ForAll testing equality, and Limit evaluating wrong
  • Previous by thread: Re: Finding Clusters
  • Next by thread: Re: Re: Finding Clusters