Question: Create a C + + program that will read in the text file containing graph specifications and display the required results after performing operations on
Create a C program that will read in the text file containing graph specifications and display the required results after performing operations on the graph. The program should be able to create the directed graph from the input file and output the results according to the InDegree of Centrality.
As social networking is very popular among people, there is a huge interest in the study of extracting information from these networks, the socalled social network analysis SNA The usage of social network analysis, however, is far beyond that of Facebook or Twitter. The principle of SNA can be applied to other things; such as finding the source and flow of an infectious disease, and scheduling the optimal productionmarket distribution for a globalized company.
The basic structure of SNA is a graph. To evaluate the characteristics of a graph and the nodes inside, people gradually develop a set of metrics, some of them are:
In an undirected graph, the degree centrality of the ith node denoted by CDi is the node degree number of edges connected to this node denoted by degi
CDi degi
We can interpret this as the how connected' this node is in general sense. In a directed graph, the indegree of centrality comes in two types: the indegree centrality and the outdegree centrality.
The indegree centrality is number of edges that are coming to the node.
The outdegree centrality uses the number of edges that are coming out of the node.
Dataset Description: Social network Accounts and their friends
You will be provided with the accounts with their friends and for each friend hishers friends etc. By using these data, build up a graph and calculate the InDegree of Centrality for each account.
A sample of the input data is:
github johnstewart github microsoft microsoft oracle
The two columns are defining the relationship between two accounts. The account in the second column is following the account in the first column. Thus, this is a directed graph. The edge goes from the account in the second column to the account in the first column second first
Read in data
The data is in the format of:
Name Name Namex Namey
For each line there will be two usernames separated by three spaces. Each username is no longer than characters and contain only alphanumeric charactersletters AZ az numbers with the exception of underscores. For each name, change every UPPERcase to lowercase.
For you to decide
Define an accountgraph class representing each node in the graph. For this class, there are some essential concepts that must be captured:
name: store a username
followers: other users following this account
following: other users that this account is following
The created account class objects need to be stored properly. Decide a way to store this list of all users from input data sets; class definitions are up to you, but the fundamental structure will reflect a directed graph with nodes and edges.
Calculate the indegree centrality for all accounts. Once the indegree centrality has been calculated for each account we want to find the most connected account in the graph. This should be the account with the largest indegree of centrality. If there is a tie, break it with alphabetical order. Once this account has been found we want to find all of the accounts who are within a depth of from the most connected account root account and sort the remaining accounts excluding the most connected user alphabetically.
For the root account the account with the largest indegree centrality find all following accounts within the depth of of the root account, regardless of whether they are being followed by that root account. It is okay to have usernames that are duplicate entries, eg alexdownie follows microsoft, and alexdownie follows twitter, and twitter follows microsoft, if the root account is microsoft, alexdownie will show up two times When exploring, use indegree not outdegree ie look for people following that node.
The program should output the tree of all accounts within a depth of of the root account. Note that the global name list does not have to be in alphabetical order, therefore you are not supposed to implement a backtracking scheme to preserve the global alphabetical rank.
The list should be printed in alphabetical order for each one of the accounts The output written should be in the following format:
The root user is Name, with indegree centrality of N There are M users in the social network. usernamedistance usernamedistance
where Name is the name as entered in the file N is the indegree centrality and M is the number of users in the social network. The users should be sorted alphabetically by name. username should be the root user. distance is the depth of that username.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
