Ex3 SMA

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

EXPERIMENT – 3

AIM:
Social Network Structure
THEORY:
Node-level properties
Node-level properties focus on one node and its position in the network. Some important node
properties include degree centrality, betweenness centrality, eigenvector centrality, and structural
holes.

 Degree Centrality
Degree centrality of a node in a network measures the number of links a node has to other
nodes In a Facebook network, for example, this will measure the number friendship ties a user
has. In a Twitter network, it will equate to the number of followers a user has. In a directed
network, degree can be either in-degree or out-degree. In-degree is the number of incoming
links a node in a network receives. For example, in a Twitter network, in-degree represents
the number of followers a person has. Out-degree represents that number of out links a node
sends. In a Twitter network, for example, the number of people a person follows represents
out-degree of a person (node). In certain networks, such as a Twitter network, in-degree
(number of followers a person has) is a more important measure of a node’s influence than
out-degree (number of people a person follows).

 Betweenness Centrality
Betweenness centrality is related to the centrality (or position) of a node in a network. The
nodes with high betweenness centrality have the ability to control or facilitate collaboration
or flow of information due to their central position in the network. In a Facebook friendship
network, for example, the users who occupy the central position are better positioned to
control the flow of social media content.

BEA106_Juhilee Tushar Patil


 Eigenvector Centrality
Eigenvector centrality measures the importance of a node based on its connections with other
important nodes in a network. It can provide an understanding of a node’s networking ability
relative to that of others.

 Structural Holes
A node that is connected to users who are themselves not directly connected has the
opportunity to mediate between them and profit from this mediation. In a social media
network, some users, because of their network position, may have an advantage or
disadvantage in terms of opportunities to form and propagate information. New ideas and
information mostly come from structure holes (or week ties) that exist in a network. A user
with more week ties can receive novel ideas and information from remote network clusters.

Network-level properties
Network properties provide insight into the overall structure and health of a network. Important
network-level properties include clustering coefficient, density, diameter, average degree, and
components.

 Clustering Coefficient
The clustering coefficient of a network is the degree to which nodes in a network tend to
cluster or group together.

 Density
The density of a network deals with a number of links in a network. Density can be calculated
as the number of links present in a network divided by the number of all possible links between
pairs of nodes in a network (for an undirected network, the number of all possible links can
be calculated as n (n – 1)/2); where n is the number of nodes in a network). A fully connected
network, in which each node is connected to every other node, will have a density of 1.

 Components
Components of a network are the isolated sub-networks that connect within, but are
disconnected between, sub-networks. In a connected component, all nodes are connected and
reachable, but there is no path between a node in the component and any node not in the

BEA106_Juhilee Tushar Patil


component. The main or largest component of a network is the component with the largest
number of nodes

 Diameter
The diameter of a network is the largest of all the calculated shortest path between any pair of
nodes in a network, and it can provide an idea of how long it would take for some
information/ideas/message to pass through the network.

 Average Degree
The average degree centrality measures the average number of links among nodes in a
network.

Code:
import networkx
import networkx as nx
import matplotlib.pyplot as plt
G = nx.Graph()
G.add_node(1)
G.add_node(2)
G.add_node(3)
G.add_node(4)
G.add_node(5)
Output:

G.add_edge(1, 5)
G.add_edge(1, 2)
G.add_edge(1, 3)
G.add_edge(4, 3)
G.add_edge(5, 4)
G.add_edge(2, 3)
Output:

BEA106_Juhilee Tushar Patil


import networkx as nx
G=nx.graph()
G.nodes()
G.edges()
Output:

Import matplotlib.pyplot as plt


Nx.draw(G)
Plt.show

nx.draw(G,with_labels=1)
plt.show()

G=nx.gnp_random_graph(10,0.5)

BEA106_Juhilee Tushar Patil


nx.draw(G)

nx.draw(G,with_labels=1)
plt.show()

nx.degree(G)
Output:

nx.degree_centrality(G)

BEA106_Juhilee Tushar Patil


m_influential=nx.degree_centrality(G)
for w in sorted(m_influential,key=m_influential.get,reverse=True):
print(w,m_influential[w])

nx.eigenvector_centrality(G)

m_imp_link= nx.eigenvector_centrality(G)
for w in sorted(m_imp_link, key=m_imp_link.get,reverse=True):
print(w,m_imp_link[w])

nx.betweenness_centrality(G)

BEA106_Juhilee Tushar Patil


plt.figure(figsize=(10,10))
nx.draw(G,with_labels=1)
plt.show()

nx.clustering(G)

Conclusion: Network analysis varies based on attributes and goals. Understanding network
structure and key participants offers insights in social networks, infrastructure planning, and
communication frameworks.

BEA106_Juhilee Tushar Patil

You might also like