Bipartite Graphen

Fortgeschrittene Netzwerkanalyse in Python

Eric Ma

Data Carpentry instructor and author of nxviz package

Bipartite Graphen

  • Graph in zwei Mengen aufgeteilt
  • Knoten verbinden sich nur mit Knoten der anderen Menge
  • Gegensatz: „unipartit“
Fortgeschrittene Netzwerkanalyse in Python

Bipartite Graphen: Beispiel

ch1-2.007.png

Fortgeschrittene Netzwerkanalyse in Python

Bipartite Graphen in NetworkX

import networkx as nx
G = nx.Graph()

numbers = range(3) G.add_nodes_from(numbers, bipartite='customers')
letters = ['a', 'b'] G.add_nodes_from(letters, bipartite='products')
Fortgeschrittene Netzwerkanalyse in Python

Bipartite Graphen in NetworkX

list(G.nodes(data=True))
[(0, {'bipartite': 'customers'}),
 (1, {'bipartite': 'customers'}),
 (2, {'bipartite': 'customers'}),
 ('b', {'bipartite': 'products'}),
 ('a', {'bipartite': 'products'})]
Fortgeschrittene Netzwerkanalyse in Python

Degree Centrality

  • Definition: $$\frac{\text{Anzahl Nachbarn}}{\text{Anzahl möglicher Nachbarn}}$$
  • Anzahl möglicher Nachbarn hängt vom Graphtyp ab
Fortgeschrittene Netzwerkanalyse in Python

Bipartite Zentralitätsmaße

  • Nenner: Anzahl Knoten in der Gegenpartition statt aller anderen Knoten

ch1-2.021.png

Fortgeschrittene Netzwerkanalyse in Python

Graphen filtern

cust_nodes = [n for n, d in G.nodes(data=True) if  
                  d['bipartite'] == 'customers']
cust_nodes
[(0, {'bipartite': 'customers'}),
 (1, {'bipartite': 'customers'}),
 (2, {'bipartite': 'customers'})]
nx.bipartite.degree_centrality(G, cust_nodes)
{0: 0.5,
 1: 0.5,
 2: 1.0,
 'a': 0.333,
 'b': 1.0}
Fortgeschrittene Netzwerkanalyse in Python

Lass uns üben!

Fortgeschrittene Netzwerkanalyse in Python

Preparing Video For Download...