Social network analysis with Python

What do we need?

  • Motivation.
  • Data.
  • Tools.
  • Example.

Motivation

Understanding a bit about social networks  APIs and create visualization over real data.

Data

Tools

  • Python (pandas,networkx,matplotlib...).
  • Twitter API.

Example

  • Details.
  • Results.

Un-Pruned graph

Prunning

remove = []
for node in G.nodes():
if G.degree(node) < 2:
remove.append(node)

G.remove_nodes_from(remove)

Pruned graph

Graph info

Number of nodes: 1277
Number of edges: 11512
Average degree:  18.0298

 

Some coloring...

Centrality

This indicators identify the most important vertices within a graph.

highest degree

map=[]

for node in G.nodes():
    map.append(G.degree(node))
    map.append(G.degree(node))

draw_network with: node_color=map , node_size=map

Highest degrees

Degree centrality

color_map=[]

size_map= []

test = nx.degree_centrality(G)

for node in G.nodes():
    size_map.append(G.degree(node))
    color_map.append(test[node])

draw_network with: node_color=map , node_size=size_map

Degree centrality

Code at:

Social network analisis

By gabriel munoz

Social network analisis

  • 214