Graphes bipartis sous forme de matrices

Analyse de réseaux intermédiaire en Python

Eric Ma

Data Carpentry instructor and author of nxviz package

Représentation matricielle

  • Lignes : nœuds d'une partition
  • Colonnes : nœuds de l'autre partition
  • Cellules : 1 si arête présente, sinon 0
Analyse de réseaux intermédiaire en Python

Représentation matricielle

ch2-2.006.png

Analyse de réseaux intermédiaire en Python

Exemple de code

cust_nodes = [n for n in G.nodes() if G.nodes[n]
                 ['bipartite'] == 'customers']
prod_nodes = [n for n in G.nodes() if G.nodes[n]
                 ['bipartite'] == 'products']

mat = nx.bipartite.biadjacency_matrix(G, row_order=cust_nodes, column_order=prod_nodes)
mat
<3x2 sparse matrix of type '<class 'numpy.int64'>'
with 3 stored elements in Compressed Sparse Row format>
Analyse de réseaux intermédiaire en Python

Projection matricielle

  • Projection calculable par multiplication de matrices

ch2-2.014.png

Analyse de réseaux intermédiaire en Python

Projection matricielle

  • Projection calculable par multiplication de matrices

ch2-2.015.png

Analyse de réseaux intermédiaire en Python

Projection matricielle

  • Projection calculable par multiplication de matrices

ch2-2.016.png

Analyse de réseaux intermédiaire en Python

Projection matricielle

  • Projection calculable par multiplication de matrices

ch2-2.017.png

Analyse de réseaux intermédiaire en Python

Projection matricielle

  • Projection calculable par multiplication de matrices

ch2-2.018.png

Analyse de réseaux intermédiaire en Python

Projection matricielle

  • Projection calculable par multiplication de matrices

ch2-2.019.png

Analyse de réseaux intermédiaire en Python

Projection matricielle

  • Projection calculable par multiplication de matrices

ch2-2.020.png

Analyse de réseaux intermédiaire en Python

Projection matricielle

  • Projection calculable par multiplication de matrices

ch2-2.021.png

Analyse de réseaux intermédiaire en Python

Projection matricielle

  • Projection calculable par multiplication de matrices

ch2-2.022.png

Analyse de réseaux intermédiaire en Python

Projection matricielle

  • Projection calculable par multiplication de matrices

ch2-2.023.png

Analyse de réseaux intermédiaire en Python

Projection matricielle

  • Projection calculable par multiplication de matrices

ch2-2.024.png

Analyse de réseaux intermédiaire en Python

Projection matricielle

  • Projection calculable par multiplication de matrices

ch2-2.025.png

Analyse de réseaux intermédiaire en Python

Multiplication de matrices en Python

mat @ mat.T
<5x5 sparse matrix of type '<class 'numpy.int64'>'
 with 23 stored elements in Compressed Sparse Row format>
mat.T @ mat
<10x10 sparse matrix of type '<class 'numpy.int64'>'
 with 50 stored elements in Compressed Sparse Column format>
Analyse de réseaux intermédiaire en Python

Passons à la pratique !

Analyse de réseaux intermédiaire en Python

Preparing Video For Download...