0

I'm trying to populate a database with sample data, and I'm hoping there's an algorithm out there that can speed up this process.

I have a database of sample people and I need to create a sample network of friend pairings. For example person 1 might be be friends with person 2,3,4, and 7, and person 2 would obviously be friends with person 1, but not necessarily with any of the others.

I'm hoping to find a way to automate the process of creating these randomly generated list of friends within certain parameters, like minimum and maximum number of friends.

Does something like this exist or could someone point me in the right direction?

Sam
  • 1,233
  • 1
  • 9
  • 16

1 Answers1

0

So I'm not if this is the ideal solution, but it worked for me. Generally the steps were:

Start with an array of people.

Copy the array and shuffle it.

Give each person in the first array a random number (within a range) of random friends (second array).

Remove the person from their own list of friends.

Iterate through each person in each friend list and see if the owner of the list is in their friend's list and if not, add it.

I used a pool of 1000 people, with and initial range of friends of 3-10, and after adding the reciprocals the final average was about 5-27, which was good enough for me.

Sam
  • 1,233
  • 1
  • 9
  • 16