<commit_before>extern crate rand;
extern crate time;
extern crate timely;
extern crate differential_dataflow;

use timely::dataflow::*;
use timely::dataflow::operators::*;

use rand::{Rng, SeedableRng, StdRng};

use differential_dataflow::collection_trace::lookup::UnsignedInt;
use differential_dataflow::collection_trace::LeastUpperBound;
use differential_dataflow::operators::*;

fn main() {

    // define a new computational scope, in which to run BFS
    timely::execute_from_args(std::env::args(), |computation| {
        let start = time::precise_time_s();

        // define BFS dataflow; return handles to roots and edges inputs
        let (mut roots, mut graph) = computation.scoped(|scope| {

            let (edge_input, graph) = scope.new_input();
            let (node_input, roots) = scope.new_input();

            let dists = bfs(&graph, &roots);    // determine distances to each graph node

            dists.map(|((_,s),w)| (s,w))        // keep only the distances, not node ids
                 .consolidate(|x| *x)           // aggregate into one record per distance
                 .inspect_batch(move |t, x| {   // print up something neat for each update
                     println!("observed at {:?}:", t);
                     println!("elapsed: {}s", time::precise_time_s() - (start + t.inner as f64));
                     for y in x {
                         println!("\t{:?}", y);
                     }
                 });

            (node_input, edge_input)
        });

        let nodes = 10u32; // the u32 helps type inference understand what nodes are
        let edges = 20;

        let seed: &[_] = &[1, 2, 3, 4];
        let mut rng1: StdRng = SeedableRng::from_seed(seed);    // rng for edge additions
        let mut _rng2: StdRng = SeedableRng::from_seed(seed);    // rng for edge deletions

        println!("performing BFS on {} nodes, {} edges:", nodes, edges);<commit_msg>fixing bfs<commit_after>extern crate rand;
extern crate time;
extern crate timely;
extern crate differential_dataflow;

use timely::dataflow::*;
use timely::dataflow::operators::*;

use rand::{Rng, SeedableRng, StdRng};

use differential_dataflow::collection_trace::lookup::UnsignedInt;
use differential_dataflow::collection_trace::LeastUpperBound;
use differential_dataflow::operators::*;

fn main() {

    // define a new computational scope, in which to run BFS
    timely::execute_from_args(std::env::args(), |computation| {
        let start = time::precise_time_s();

        // define BFS dataflow; return handles to roots and edges inputs
        let (mut roots, mut graph) = computation.scoped(|scope| {

            let (edge_input, graph) = scope.new_input();
            let (node_input, roots) = scope.new_input();

            let dists = bfs(&graph, &roots);    // determine distances to each graph node

            dists.map(|((_,s),w)| (s,w))        // keep only the distances, not node ids
                 .consolidate(|x| *x)           // aggregate into one record per distance
                 .inspect_batch(move |t, x| {   // print up something neat for each update
                     println!("observed at {:?}:", t);
                     println!("elapsed: {}s", time::precise_time_s() - (start + t.inner as f64));
                     for y in x {
                         println!("\t{:?}", y);
                     }
                 });

            (node_input, edge_input)
        });

        let nodes = 100_000_000u32; // the u32 helps type inference understand what nodes are
        let edges = 200_000_000;

        let seed: &[_] = &[1, 2, 3, 4];
        let mut rng1: StdRng = SeedableRng::from_seed(seed);    // rng for edge additions
        let mut _rng2: StdRng = SeedableRng::from_seed(seed);    // rng for edge deletions

        println!("performing BFS on {} nodes, {} edges:", nodes, edges);
{'fraction_non_alphanumeric': 0.12664771258723184, 'fraction_numerical': 0.011889377100025847, 'mean_word_length': 2.3535528596187176, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4690109', 'n_tokens_mistral': 1196, 'n_tokens_neox': 1103, 'n_words': 336}