Skip to content

Latest commit

 

History

History
109 lines (69 loc) · 5.79 KB

README.md

File metadata and controls

109 lines (69 loc) · 5.79 KB

Social-Network-Simulator

A man once said:

If you want to learn a new language start with simple syntax ans then implement Data Structures in that language

Well, that's what I was doing when I dived into python. I started implementing list, linked list, graph etc. I wanted to develop a project that will use all these concepts, so that I can develop better understanding of these concepts. Ever thought how Facebook, Linked-in, Instagram worked? Well, I have and that's what I wanted to develop.

This project simulates a "Social Network", where you can:

  • Make friends
  • Follow and un-follow people
  • Create, like and delete posts

How to run?

You have to run "SocialSim.py". No additional packages are required, this project only uses features that are present standard python distribution.

usage

As you can see there are two modesin which you can use this program, details are as follow:

Interactive mode

In this mode, user can interact with the program and will have to provide input at each step as he/she wants, this is how a interactive mode looks like:

intr

Load Network

Using this function you can create a network, there are further two more options:

load

Load new network

If you want to load a new network from a network file you should use this option. Sample run of loading from text file:

load new network

As you can see the network is loaded when we print the network it prints as expected. Remember Format of the network input should be exactly same as the network.txt file that is provided.

Load saved network

If you have created a network and made some changes, saved the network using Save network. You can load the graph from the saved pickle file.

saved

Set Probabilities

It is probability in percentage(%), that how much likely a person will follow another person, or much likely a person will like the post. If you think this application as a "Disease spread simulation", this parameter will mean that how much is likely for a healthy person get affected by the disease.

pro

Node Operations

As the graph is a linked-list of a linked-lists, so, A node is representing a person in the network. If you want to:

Sign-up in the network

insert

Get removed from the network delete

Find a friend in network

found

Edge Operations

Edge represent a connection between various persons in the network. If you want to:

Add a friend We will make "Rex" a friend of "Imran khan". add

Remove a friend We will remove "Rex" as a friend of "Imran khan". remov

New Post

Its just like making a new post and publishing it. Now, how many will like this post and how many will follow the person in return, depends on the Probabilities we set earlier (remember ???) post

Display Network

Should I tell what this option will do ? display

Display Statistics

This option will display various stats like:

  • Number of posts made by a person
  • Post ordered by their popularity
  • Number of likes, friends, friends of etc

stata

Update

As we are in simulation mode, we have to update the network manually. What does this update means? You have created a post, now people will start liking the post as you update the network. In other terms, it is a mean of progressing through time. update

Save Network

You have made changes to your network and wants to save the network for future use, don't worry I got you covered. Use this option to save the network as a pickle file. optn 9

Exit

Done spending hours and hours on my network and now wants to go to sleep ? Use this option to exit.

Simulation mode

You don't have time to manually create posts, follow, unfollow people and want to automate things. Use events.txt to save all the events and run a simulation on them. Events file can have events of adding a friend, removing a friend, posting, liking etc. See the events.txt for more information. Remember Your events file should be in same format as the given events.txt

Once you have run the simulation a Simulation_Log.txt file will appear that will contains various stats and other logs sim