Question: This assignment aims to enhance your practical expertise in Python programming through the application of class - learned concepts to generate graphical representations. These representations
This assignment aims to enhance your practical expertise in Python programming through the application of classlearned concepts to generate graphical representations. These representations aid in identifying critical edges and nodes. The program's specific tasks include computing cluster coefficients and neighborhood overlaps within an input graph. Furthermore, the graphs will be partitioned to emphasize primary groups and store it in a new graph. Mastery of these skills will not only reinforce your programming capabilities, essential for upcoming assignments but also heighten your proficiency and competitiveness in the dynamic field of Computer Science.
Requirement
The assignment requires that you create the Python program that runs in a terminal. The program accepts optional parameters. The syntax to run the program is shown in the following line:
python graphanalysis.py graphfile.gml components n plot CNPverifyhomophily verifybalancedgraph output outgraphfile.gml
Description of Parameters
This is the command to execute the Python script graphanalysis.py located in the current directory and reads the file graphfile.gml Here, graphfile.gml is the file that will be used for the analysis and the format is Graph Modelling Language gml which describes the graph's structure with attributes. The program should read the attributes of the nodes and edges in the file.
components n
Specifies that the graph should be partitioned into n components. This divides the graph into n subgraphs or clusters. Compute the betweenness and remove the edge with the highest value. Repeat this process until you have n components.
plot CNP
Determines how the graph should be plotted.
C: If this option is selected, the script will plot the graph highlighting clustering coefficients which measure how nodes are tightly grouped
The Cluster coefficient is proportional to its size. Let clustermin, and clustermax be the min and max cluster coefficients, and let cv be the clustering coefficient of node v and pv cv clusterminclustermax clustermin of node v The siz v is proportional to pv Let maxpixel and minpixel be the minimum and maximum pixel sizes of the nodes. Therefore, the node v will have size minpixel pvmaxpixel minpixel
The color of v is proportional to the degree. Similar as before, let dv be the degree of node v max be the maximum degree in the graph. Let sv dvmax be the size of node v The RGB color of v is set to sv so the node with the lowest degree is Blue and the node with the highest degree is Magenta.
N: If this option is selected, the script will plot the graph highlighting neighborhood overlap which measures how much overlap there is between neighborhoods of adjacent nodes Similar to the clustering coefficient.
P: If this option is selected, the script will color the node according to the attribute if it is assigned, or a default color if not.
verifyhomophily
Tests for homophily in the graph based on the assigned node colors using the Student ttest. Homophily measures whether nodes with the same color are more likely to be connected.
verifybalancedgraph
Check if the graph is balanced based on the assigned edge signs. A balanced graph is one where the signs on the edges are consistent with the node attributes.
output outgraphfile.gml
Specify the file to which the final graph and results should be saved. In this case, outgraphfile.gml is the output file that will receive the updated graph datathe node attributes and edge attributes should be also saved in the outgraphfile.gml
Examples
python graphanalysis.py graphfile.gml components plot C output outgraphfile.gml
Read graphfile.gml and partition it into connected components, plot the graph and highlight the clustering coefficient, and save the graph in outgraphfile.gml
python graphanalysis.py homophily.gml plot P verifyhomophily
Read homophily.gml plot the graph and verify if there is evidence of homophily in the graph
python graphanalysis.py balancedgraph.gml plot P verifybalancedgraph
Read balancedgraph.gml plot the graph and verify if there is the graph is balanced
Evaluation:
Your implementation will be evaluated based on correctness, efficiency, clarity of code, and the quality of graph visualization. Ensure your program handles edge cases such as empty graphs, nonexistent files, and invalid inputs gracefully.
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
