Message Boards Message Boards


[HACKATHON] Analysis of Russian Social Network VKontakte

Posted 11 months ago
1 Reply
5 Total Likes


We are living in the era of technologies when everything is fast and quick changing. Sometimes we don't have time to "clean up" our networks. Someone can say that we are lazy, but if we can make technologies and our knowledge work for us, why not? Our purpose was to analyse part of the popular Russian social networking service - "Вконтакте" (VKontakte, meaning InContact). It is a standard situation when network administrators block pages of those people who break the social network rules. Some users in one day can decide that they don't want to "spend their lives on the Internet" and delete their pages. And here we are. One day you check your list of friends and understand that some of them have been blocked or deleted. Do you want to spend your time cleaning up your list of friends? We don't think so. But our programme can help you with this.

Description of our work

First of all, you need to get a list of the user's friends' IDs, which you can receive with a simple the GET method request.

Import["" <> userID <> 
   "&access_token=" <> token <> "&v=5.78", "RawJSON"] // Short

userID - user identification.

token - a system object representing the subject of access control operations.

Receive the output in the form of an Association.

<|response -> <|count -> 209, items -> {92070, 119121, 238683, 1266876, 1292342,<<199>>, 323263490, 328646963, 341263802, 395195137, 433885152}|>|>

From which select the list of IDs.

friendsResponse = 
  Import["" <> userID <>
     "&access_token=" <> token <> "&v=5.78", "RawJSON"];
friendIds = friendsResponse["response"]["items"];

Then we get additional information about each user with the help of users.get. It is worth to notice that in the user_ids parameter, you can work with a list of IDs, for this list should be comma separated.

informationResponse = 
  Import["" <> 
    StringRiffle[friendIds, ","] <> "&access_token=" <> token <> 
    "&v=5.78&fields=photo_max", "RawJSON"];
friends = informationResponse["response"];

Information about each user is in the followed form:

<|"id" -> 219746518, "first_name" -> "Олег", "last_name" -> "Дудник", 
 "photo_max" -> 

If a user has been deleted, he will have the field deactivated with meaning deleted:

<|"id" -> 207385, "first_name" -> "DELETED", "last_name" -> "", 
 "deactivated" -> "deleted", 
 "photo_max" -> ""|> 

If a user has been blocked, he will have the field deactivated with meaning blocked:

<|"id" -> 10789003, "first_name" -> "Вита", 
 "last_name" -> "Свиридова", "deactivated" -> "banned", 
 "photo_max" -> ""|> 

In this way, we should delete from the list of friends those who have the field deactivated.

To delete the user with the particular ID, it is necessary to execute GET request:

"" <> id <> "&access_token=" <> token <> "&v = 5.78"

Graphical part of the work

Receive IDs of friends of the chosen user and transform it into the edge list.

Get the graph:

enter image description here

It doesn't include valuable data, and it's hard to read it. Let's do the following actions:

  1. Receive the number of messages between users. They are going to be weights of edges.
  2. To make the graph more readable we will change the length of each edge according to its weight. Then each edge rotate to the random angle Make it with the help of a rotation matrix.

    friendsVisuo[edgeListVisuo_, edgeWeightsVisuo_] := 
     Module[{coord1 = 
             VertexCoordinates -> 
                  Cos@i}, {Cos@i, -Sin@i}}, {i, Length@edgeListVisuo}], 
             VertexLabels -> "Name"], #}, VertexCoordinates] & /@ 
           VertexCoordinates -> 
                Cos@i}, {Cos@i, -Sin@i}}, {i, Length@edgeListVisuo}], 
           VertexLabels -> "$"]]},
       Table[Graphics[{Pink, Opacity[0.3], EdgeForm[{Thick, Blue}], 
          Disk[First@coord1, i^2]}], {i, 5}], 
        VertexCoordinates -> 
            edgeWeightsVisuo[[i]]}.{{Sin@i, Cos@i}, {Cos@i, -Sin@i}}, {i, 
           Length@edgeListVisuo}], VertexLabels -> "Name"], 
       ImageSize -> Full]]

ed - the list of edges. Also, draw 3 concentric translucent circles for better visualization. This is the result: enter image description here

If we use data from a social network, we can get a more pleasant look: enter image description here


It was our first hackathon, and we are pleased that we had the opportunity to participate in it, to work and communicate with people from Wolfram Research.We had all the facilities to work with comfort like the place, wi - fi, sockets, food. No doubt we will participate next time!

enter image description here - Congratulations! This post is now a Staff Pick as distinguished by a badge on your profile! Thank you, keep it coming!

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract