Find all "connected" neighbors to a location

Reply
New Contributor
Posts: 2

Find all "connected" neighbors to a location

Say I have the following 4 houses with the distances between them

 

GHI 35ft ABC 20ft DEF 40ft JKL 100ft XYZ 10 ft WTH

 

Identifying each neighbor within 40ft is quite simple, however I want to identify each connected neighbor within 40 ft. So here GHI & JKL, ABC & JKL, etc. would all be neighbors as there is always less than or equal to 40 ft between them. XYZ would only be neighbors with WTH.

 

Essentially I would like the following resulting table

 

Location 1 - Neighbor 1 - Distance to Neighbor 1 - Neighbor 2 - Distance to Neighbor 2 - Neighbor 3 - Distance to Neighbor 3

ABC - DEF - 20ft - GHI - 35ft - JKL 40ft

DEF - ABC - 20ft - GHI - 35ft - JKL - 40ft

GHI - ABC -  35ft - DEF -  20ft - JKL - 40ft

JKL - DEF - 40ft - ABC - 20ft - GHI - 35 ft

XYZ - WTH - 10ft - - - -

WTH - XYZ - 10ft - - - -

 

 

Thanks in advance

Respected Advisor
Posts: 4,824

Re: Find all "connected" neighbors to a location

You can't solve this problem with distances only, unless you have the distances between every house pairs. It is usually simpler to start with house locations. You can then locate every pair which is within 40ft and use SAS/OR OPTNET to find the connected components of houses within 40ft.

PG
New Contributor
Posts: 2

Re: Find all "connected" neighbors to a location

I do have the distances between each house pair (well the 100 closest houses to not have a massive dataset). How could I proceed with that info?

Sadly I do not have access to SAS/OR Smiley Sad
Respected Advisor
Posts: 4,824

Re: Find all "connected" neighbors to a location

First, select all pairs closer than 40 ft apart, then use my macro at 

 

https://communities.sas.com/t5/General-SAS-Programming/Finding-all-connected-components-in-a-graph/m...

 

Good luck!

 

PG
Ask a Question
Discussion stats
  • 3 replies
  • 242 views
  • 0 likes
  • 2 in conversation