Skip to content

Instantly share code, notes, and snippets.

@davidrajm
Created November 21, 2024 14:08
Show Gist options
  • Save davidrajm/41d91f7265f680aa84e4207a01c3a18d to your computer and use it in GitHub Desktop.
Save davidrajm/41d91f7265f680aa84e4207a01c3a18d to your computer and use it in GitHub Desktop.
import random
def generate_social_network(num_people=10, num_connections=15):
people = [f"Person_{i}" for i in range(num_people)]
connections = []
for _ in range(num_connections):
person1, person2 = random.sample(people, 2)
if (person1, person2) not in connections and (person2, person1) not in connections:
connections.append((person1, person2))
return people, connections
if __name__ == "__main__":
people, connections = generate_social_network()
print("People:")
print(people)
print("\nConnections:")
print(connections)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment