Skip to content
Snippets Groups Projects
visibility_LFR_graphs.py 4.63 KiB

import numpy as np
import matplotlib.pyplot as plt

def lire_fichier_donnees(filename):
    file = open(filename, 'r')
    
    file.readline().rstrip('\n\r')  #on oublie les 2 premieres lignes
    file.readline().rstrip('\n\r')
    file.readline().rstrip('\n\r')
    file.readline().rstrip('\n\r')
    
    nb_ligne = 0
    
    ligne = file.readline().rstrip('\n\r')
    file.readline().rstrip('\n\r')
    
    vis_del_edges_true = 0
    vis_del_edges_false = 0
    
    vis_red_aware_true = 0
    vis_red_aware_false = 0
    
    vis_greedy_true = 0
    vis_greedy_false = 0
    
    while ligne:
        nb_ligne += 1
        l = ligne.split()
        
        #print(l)
        
        vis_del_edges_true += float(l[1][0:-1])
        vis_del_edges_false += float(l[3][0:-1])
        
        vis_red_aware_true += float(l[5][0:-1])
        vis_red_aware_false += float(l[7][0:-1])
        
        vis_greedy_true += float(l[9][0:-1])
        vis_greedy_false += float(l[11][0:-1])
        
        
        ligne = file.readline().rstrip('\n\r')
        file.readline().rstrip('\n\r')
    
    file.close()
    
    return np.array([vis_del_edges_true,vis_del_edges_false,vis_red_aware_true,vis_red_aware_false,vis_greedy_true,vis_greedy_false])/nb_ligne



vis_del_edges_true = []
vis_del_edges_false = []

vis_red_aware_true = []
vis_red_aware_false = []

vis_greedy_true = []
vis_greedy_false = []

liste_mus = [20,22,24,26,28,30,32,34,37,39,41,43,45,47,49,51,53,55,56,59,61,63,66,68,70,72,74,76,78,80]

for mu in liste_mus:
    l = lire_fichier_donnees("results\\LFR_graphs\\LFR_graph_vis_300n_"+str(mu)+"mu.txt")
    vis_del_edges_true.append(l[0])
    vis_del_edges_false.append(l[1])
    
    vis_red_aware_true.append(l[2])
    vis_red_aware_false.append(l[3])
    
    vis_greedy_true.append(l[4])
    vis_greedy_false.append(l[5])

"""
comp_baseline_true = np.array(comp_baseline_true)-1000
comp_baseline_false = np.array(comp_baseline_false)-1000
comp_red_aware_true = np.array(comp_red_aware_true)-1000
comp_red_aware_false = np.array(comp_red_aware_false)-1000
comp_greedy_true = np.array(comp_greedy_true)+1000
comp_greedy_false = np.array(comp_greedy_false)+1000
"""

x = 0.01*np.array(liste_mus)
x_max = len(x)

text_size = 18
avec_legend = False

plt.figure()
plt.title("Visibility with pre-processing",fontsize=text_size)
plt.plot(x,[1 for i in range(x_max)],color="red",label="Quick")
plt.plot(x,vis_red_aware_true,color="blue",label="Quick_redundancy_aware")
plt.plot(x,vis_del_edges_true,color="green",label="Quick_delete_covered_edges")
plt.plot(x,vis_greedy_true,color="orange",label="Greedy_quasi_cliques")
axes = plt.gca()
axes.set_ylim(0,1.1)
if avec_legend:
    plt.legend()
plt.savefig("figures\\LFR_graphs\\all_with_vis.png",format='png')


plt.figure()
plt.title("Visibility without pre-processing",fontsize=text_size)
plt.plot(x,[1 for i in range(x_max)],color="red",label="Quick")
plt.plot(x,vis_red_aware_false,color="blue",label="Quick_redundancy_aware")
plt.plot(x,vis_del_edges_false,color="green",label="Quick_delete_covered_edges")
plt.plot(x,vis_greedy_false,color="orange",label="Greedy_quasi_cliques")
axes = plt.gca()
axes.set_ylim(0,1.1)
if avec_legend:
    plt.legend()
plt.savefig("figures\\LFR_graphs\\all_without_vis.png",format='png')

plt.figure()
plt.title("Quick visibility",fontsize=text_size)
plt.plot(x,[1 for i in range(x_max)],color="red",label="with pre-processing")
plt.plot(x,[1 for i in range(x_max)],color="blue",label="without pre-processing")
axes = plt.gca()
axes.set_ylim(0,1.1)
if avec_legend:
    plt.legend()
plt.savefig("figures\\LFR_graphs\\quick_vis.png",format='png')

plt.figure()
plt.title("Quick_redundancy_aware visibility",fontsize=text_size)
plt.plot(x,vis_red_aware_true,color="red",label="with pre-processing")
plt.plot(x,vis_red_aware_false,color="blue",label="without pre-processing")
axes = plt.gca()
axes.set_ylim(0,1.1)
if avec_legend:
    plt.legend()
plt.savefig("figures\\LFR_graphs\\red_aware_vis.png",format='png')

plt.figure()
plt.title("Quick_delete_covered_edges visibility",fontsize=text_size)
plt.plot(x,vis_del_edges_true,color="red",label="with pre-processing")
plt.plot(x,vis_del_edges_false,color="blue",label="without pre-processing")
axes = plt.gca()
axes.set_ylim(0,1.1)
if avec_legend:
    plt.legend()
plt.savefig("figures\\LFR_graphs\\del_edges_vis.png",format='png')

plt.figure()
plt.title("Greedy_quasi_cliques visibility",fontsize=text_size)
plt.plot(x,vis_greedy_true,color="red",label="with pre-processing")
plt.plot(x,vis_greedy_false,color="blue",label="without pre-processing")
axes = plt.gca()
axes.set_ylim(0,1.1)
if avec_legend:
    plt.legend()
plt.savefig("figures\\LFR_graphs\\greedy_vis.png",format='png')