﻿import networkx as nx
import matplotlib.pyplot as plt

G1=nx.Graph()

G1.add_nodes_from(["Adèle","Bryan","Camel","Denis"])

G1.add_edges_from([("Adèle","Bryan"),("Adèle","Camel"),("Adèle","Denis"), ("Bryan","Denis")])



def Trace(G):
    options = {'with_labels' : True, 'font_weight' : 'bold', 'node_color' : 'white', 'node_size' :1500, 'width' :3}
    nx.draw_circular(G, **options)
    plt.show()

G2=nx.Graph()

G2.add_nodes_from("ABCDE")

G2.add_edges_from(["AB","AD","BC","BD","BE","CB","CE"])

def Trace2(G):
    options = {'with_labels' : True, 'font_weight' : 'bold', 'node_color' : 'white', 'node_size' :1500, 'width' :3}
    plt.subplot(131)
    nx.draw_random(G, **options)
    plt.subplot(132)
    nx.draw_circular(G, **options)
    plt.subplot(133)
    nx.draw_spring(G, **options)
    plt.show()

DG1 = nx.DiGraph()
DG1.add_nodes_from("ABCDE")
DG1.add_edges_from(["AB","AE","AC","ED"])


#Test d'un graphe aléatoire: Clustering

from random import *
G3=nx.Graph()
G3.add_nodes_from(range(100))

for a in G3.nodes():
    for b in G3.nodes():
        x=random()
        if x<0.4 and a%10==b%10:
            G3.add_edge(a,b)
        elif x<0.01:
            G3.add_edge(a,b)

def Trace3(G):
    options = {'node_color' : 'black', 'node_size' :5, 'width' :1}
    plt.subplot(121)
    nx.draw_random(G, **options)
    plt.subplot(122)
    nx.draw_spring(G, **options)
    plt.show()

#Test d'un graphe aléatoire: Influanceurs

from random import *
G4=nx.Graph()
G4.add_nodes_from(range(100))

for a in G4.nodes():
    for b in G4.nodes():
        x=random()
        if x<0.4 and a<10:
            G4.add_edge(a,b)
        elif x<0.01:
            G4.add_edge(a,b)

def Trace4(G):
    options = {'node_color' : 'black', 'node_size' :5, 'width' :1}
    plt.subplot(121)
    nx.draw_random(G, **options)
    plt.subplot(122)
    nx.draw_shell(G, nlist=[range(10),range(10,100)], **options)
    plt.show()

