From up2

Main: BD4

Streaming

 import random

 import csv

 .......à définir pour lire un fichier


 edge_list = read_edge_from_file(file_input)

 #m stores the number of edges in windows. m[0] is the number of edges in the first window

 m=[0]

 #i is the index of the windows: 0,1,2,...

 i=0

 sample = []

 for index, edge in enumerate(edge_list):

    m[i] += 1

    if index < k:

        sample.append(edge)

    else:

        j = random.randint(0, index)

        if j < k:

           del sample[j]

           sample.append(edge)


 print(sample)

Code Réservoir lisant dt_b.csv

Fichier dt_b.csv

Retrieved from http://www.up2.fr/index.php?n=Main.BD4
Page last modified on October 24, 2018, at 10:35 PM