Skip to content

πŸ€– Simulation

Jop Molenaar edited this page Jun 19, 2024 · 11 revisions

File: Meesterproef-SNSimulation/js/Person.js

Step function

The person class has a couple of functions where this.step is one of them. node.step() fires a couple of functions to simulate like they have their own behavior.

The functions that the step() fires will be explained a little bit more right here.

    step(nodes, links) {
        this.readSocialMediaPost(nodes, links);
        this.forwardSocialMediaPost(links);
        this.manageRelationships(links);
        this.addFriendThroughContent(links);
        this.moveNode(links);
    }

The step function gets fired for every single person node in the network. The step fires a couple of functions to let the person execute their own behaviour. All nodes do the same, but in some places, the social score plays a crucial role that decides if the person executes that action or not.

  1. A person reads one social media post from the network.
  2. If they like a post (this is based on the acceptanceDistance in Person.js, if this is a high number, the node will like more posts), they forward the post to all the friends they have (this is based on the social score. The higher the social score, the higher the chances that the person sends the post).
  3. If the post is sent to the friends, all the friends receive a post in the receiveSocialMediaPost function. With some calculations, the score between the friend and the post is decided. This affects the relationship between the friend and the sender.
  4. After that, the function for managing relationships with friends and info links is fired. This function looks at the score of the friendships and decides if it upgrades them to info links or breaks the friendship.
  5. Next, the person looks for new friends to make. It looks in their positive posts for readers who also liked that post. If the node finds one, they become friends (this is also based on the social score. If the social score is higher, the higher the chances are that they become friends).
  6. In the end, the node moves to their liked posts, info links, and friends. How fast it moves is based on the stepDistance.

Explanation on how the data is stored

The paramters of the step() are nodes and links: The nodes map consists of persons and posts and the links map contain all edges. The difference between persons and posts is the type, but also other data is stored in that node.

Person and post nodes are stored in nodes and link nodes are stored in links in the app.js, and look like this:

map: 
    key() = // id of the node 
    values() = // whole node

In a person node you can find other maps like friends, items and infoLinks. And in a post node you can find the map readers for example. In both nodes, the same principal is used but the values() look a little different.

map: 
    key() = // id of the node 
    values() = {
            person: // the whole node, 
            score: // the score of the relationship or if they liked a post or not
        }

Design rational

Clone this wiki locally