Is there an algorithm to determine the number of elements in contiguous regions? -
i have set of points placed in 2 dimensional euclidean space. if distance between 2 points closer predetermined cut-off radius, considered neighbours. calculate number of elements in contiguous regions (for example, let's 1 , 2 neighbours. if 2 , 3 neighbours, 3 , 4, have 4 elements next each other).
i have been googling hell day , have run lot of keywords kd-tree, k means clustering, graph traversal, flood fill , connected-component analysis, can't learn them @ point. need direction focus efforts in correct direction.
your problem seems connected component analysis!
the first thing represent data graph , there tons of libraries that. let's take example in python: can use networkx or graph-tool. straightforward point can represented node. concerning edges have several solutions.
you can brute-force comparisons compares points each others. run in o(n * (n-1) /2), ok if dataset small. if dataset big can use different approximate algorithms (kd-tree, ball-tree), implemented in flann or scikit-learn. note scikit-learn give brute-force comparison.
the goal here create edge (a link) between 2 nodes (points) if distance lower threshold.
once add nodes , edges in graph, can run connected component algorithm gives connected components of graph. connected component continuous set of nodes linked edges.
note once problem represented graph, 70 years of graph theory comes rescue. can check if regions have same shape others using subgraph isomorphism. can check importance of each point in each component centrality measures. can partition continuous subregions without need threshold edges using graph partitioning.
you can have live example of continuous graph cut multiple partitions on blog.
for sake of argument: here example of several connected components belonging in same graph (with self-edges).
Comments
Post a Comment