Skip to content

Commit

Permalink
restruct io
Browse files Browse the repository at this point in the history
  • Loading branch information
shivamka1 committed Jun 21, 2024
1 parent 330890c commit 116d26c
Show file tree
Hide file tree
Showing 27 changed files with 66 additions and 62 deletions.
2 changes: 1 addition & 1 deletion examples/rust/src/bin/bench/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use raphtory::{
algorithms::centrality::pagerank::unweighted_page_rank,
graph_loader::source::csv_loader::CsvLoader, prelude::*,
io::csv_loader::CsvLoader, prelude::*,
};
use serde::Deserialize;
use std::{
Expand Down
2 changes: 1 addition & 1 deletion examples/rust/src/bin/btc/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#![allow(dead_code)]

use chrono::{DateTime, Utc};
use raphtory::{core::utils::hashing, graph_loader::source::csv_loader::CsvLoader, prelude::*};
use raphtory::{core::utils::hashing, io::csv_loader::CsvLoader, prelude::*};
use regex::Regex;
use serde::Deserialize;
use std::{
Expand Down
2 changes: 1 addition & 1 deletion examples/rust/src/bin/crypto/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use raphtory::{
pathing::temporal_reachability::temporally_reachable_nodes,
},
db::api::view::*,
graph_loader::example::stable_coins::stable_coin_graph,
graph_loader::stable_coins::stable_coin_graph,
};
use std::{env, time::Instant};

Expand Down
2 changes: 1 addition & 1 deletion examples/rust/src/bin/hulongbay/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use raphtory::{
triangle_count::triangle_count,
},
},
graph_loader::source::csv_loader::CsvLoader,
io::csv_loader::CsvLoader,
prelude::*,
};
use regex::Regex;
Expand Down
2 changes: 1 addition & 1 deletion examples/rust/src/bin/lotr/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use raphtory::{
algorithms::pathing::temporal_reachability::temporally_reachable_nodes, core::utils::hashing,
graph_loader::source::csv_loader::CsvLoader, prelude::*,
io::csv_loader::CsvLoader, prelude::*,
};
use serde::Deserialize;
use std::{
Expand Down
2 changes: 1 addition & 1 deletion examples/rust/src/bin/pokec/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use raphtory::{
centrality::pagerank::unweighted_page_rank, components::weakly_connected_components,
},
db::{api::mutation::AdditionOps, graph::graph::Graph},
graph_loader::source::csv_loader::CsvLoader,
io::csv_loader::CsvLoader,
prelude::*,
};
use serde::Deserialize;
Expand Down
6 changes: 3 additions & 3 deletions raphtory-benchmark/benches/algobench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub fn local_triangle_count_analysis(c: &mut Criterion) {
let mut group = c.benchmark_group("local_triangle_count");
group.sample_size(10);
bench(&mut group, "local_triangle_count", None, |b| {
let g = raphtory::graph_loader::example::lotr_graph::lotr_graph();
let g = raphtory::graph_loader::lotr_graph::lotr_graph();
let windowed_graph = g.window(i64::MIN, i64::MAX);

b.iter(|| {
Expand All @@ -42,7 +42,7 @@ pub fn local_clustering_coefficient_analysis(c: &mut Criterion) {
let mut group = c.benchmark_group("local_clustering_coefficient");

bench(&mut group, "local_clustering_coefficient", None, |b| {
let g: Graph = raphtory::graph_loader::example::lotr_graph::lotr_graph();
let g: Graph = raphtory::graph_loader::lotr_graph::lotr_graph();

b.iter(|| local_clustering_coefficient(&g, "Gandalf"))
});
Expand Down Expand Up @@ -123,7 +123,7 @@ pub fn temporal_motifs(c: &mut Criterion) {
let mut group = c.benchmark_group("temporal_motifs");

bench(&mut group, "temporal_motifs", None, |b| {
let g: Graph = raphtory::graph_loader::example::lotr_graph::lotr_graph();
let g: Graph = raphtory::graph_loader::lotr_graph::lotr_graph();

b.iter(|| global_temporal_three_node_motif(&g, 100, None))
});
Expand Down
2 changes: 1 addition & 1 deletion raphtory-benchmark/benches/arrow_algobench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pub fn local_triangle_count_analysis(c: &mut Criterion) {
let mut group = c.benchmark_group("local_triangle_count");
group.sample_size(10);
bench(&mut group, "local_triangle_count", None, |b| {
let g = raphtory::graph_loader::example::lotr_graph::lotr_graph();
let g = raphtory::graph_loader::lotr_graph::lotr_graph();
let test_dir = TempDir::new().unwrap();
let g = g.persist_as_disk_graph(test_dir.path()).unwrap();
let windowed_graph = g.window(i64::MIN, i64::MAX);
Expand Down
2 changes: 1 addition & 1 deletion raphtory-benchmark/benches/base.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::common::{bootstrap_graph, run_analysis_benchmarks, run_large_ingestion_benchmarks};
use criterion::{criterion_group, criterion_main, Criterion, Throughput};
use raphtory::{graph_loader::example::lotr_graph::lotr_graph, prelude::*};
use raphtory::{graph_loader::lotr_graph::lotr_graph, prelude::*};

mod common;

Expand Down
11 changes: 6 additions & 5 deletions raphtory-benchmark/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ use raphtory::{
algorithms::{
centrality::pagerank::unweighted_page_rank, components::weakly_connected_components,
},
graph_loader::{fetch_file, source::csv_loader::CsvLoader},
graph_loader::fetch_file,
io::csv_loader::CsvLoader,
prelude::{AdditionOps, Graph, GraphViewOps, NodeViewOps, NO_PROPS},
};
use std::{
Expand All @@ -16,10 +17,10 @@ use std::{
};

#[derive(Parser, Debug)]
#[command(author, version, about, long_about = None )]
#[command(author, version, about, long_about = None)]
struct Args {
/// Set if the file has a header, default is False
#[arg(long, action=ArgAction::SetTrue)]
#[arg(long, action = ArgAction::SetTrue)]
header: bool,

/// Delimiter of the csv file
Expand All @@ -43,11 +44,11 @@ struct Args {
time_column: i32,

/// Download default files
#[arg(long, action=ArgAction::SetTrue)]
#[arg(long, action = ArgAction::SetTrue)]
download: bool,

/// Debug to print more info to the screen
#[arg(long, action=ArgAction::SetTrue)]
#[arg(long, action = ArgAction::SetTrue)]
debug: bool,

/// Set the number of locks for the node and edge storage
Expand Down
2 changes: 1 addition & 1 deletion raphtory/src/algorithms/community_detection/louvain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ mod test {
#[cfg(feature = "io")]
#[test]
fn lfr_test() {
use crate::graph_loader::source::csv_loader::CsvLoader;
use crate::io::csv_loader::CsvLoader;
use serde::{Deserialize, Serialize};
use std::path::PathBuf;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::{graph_loader::source::csv_loader::CsvLoader, prelude::*};
use crate::{io::csv_loader::CsvLoader, prelude::*};
use chrono::DateTime;
use serde::Deserialize;
use std::{fs, path::PathBuf, time::Instant};
Expand Down
7 changes: 0 additions & 7 deletions raphtory/src/graph_loader/example/mod.rs

This file was deleted.

File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
//!
//! Example:
//! ```rust
//! use raphtory::graph_loader::example::lotr_graph::lotr_graph;
//! use raphtory::graph_loader::lotr_graph::lotr_graph;
//! use raphtory::prelude::*;
//!
//! let graph = lotr_graph();
Expand All @@ -22,11 +22,12 @@
//! println!("The graph has {:?} edges", graph.count_edges());
//! ```
use crate::{
graph_loader::{fetch_file, source::csv_loader::CsvLoader},
graph_loader::fetch_file,
prelude::*,
};
use serde::Deserialize;
use std::path::PathBuf;
use crate::io::csv_loader::CsvLoader;

#[derive(Deserialize, std::fmt::Debug)]
pub struct Lotr {
Expand Down
27 changes: 16 additions & 11 deletions raphtory/src/graph_loader/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
//! ```rust
//! use raphtory::algorithms::metrics::degree::average_degree;
//! use raphtory::prelude::*;
//! use raphtory::graph_loader::example::lotr_graph::lotr_graph;
//! use raphtory::graph_loader::lotr_graph::lotr_graph;
//!
//! let graph = lotr_graph();
//!
Expand All @@ -32,7 +32,7 @@
//! ```no_run
//! use std::time::Instant;
//! use serde::Deserialize;
//! use raphtory::graph_loader::source::csv_loader::CsvLoader;
//! use raphtory::io::csv_loader::CsvLoader;
//! use raphtory::prelude::*;
//!
//! let data_dir = "/tmp/lotr.csv";
Expand Down Expand Up @@ -105,8 +105,13 @@ use std::{
};
use zip::read::ZipArchive;

pub mod example;
pub mod source;
pub mod company_house;
pub mod karate_club;
pub mod lotr_graph;
pub mod neo4j_examples;
pub mod reddit_hyperlinks;
pub mod stable_coins;
pub mod sx_superuser_graph;

pub fn fetch_file(
name: &str,
Expand Down Expand Up @@ -177,13 +182,13 @@ mod graph_loader_test {

#[test]
fn test_lotr_load_graph() {
let g = crate::graph_loader::example::lotr_graph::lotr_graph();
let g = crate::graph_loader::lotr_graph::lotr_graph();
assert_eq!(g.count_edges(), 701);
}

#[test]
fn test_graph_at() {
let g = crate::graph_loader::example::lotr_graph::lotr_graph();
let g = crate::graph_loader::lotr_graph::lotr_graph();

let g_at_empty = g.at(1);
let g_astart = g.at(7059);
Expand All @@ -196,7 +201,7 @@ mod graph_loader_test {

#[test]
fn test_karate_graph() {
let g = crate::graph_loader::example::karate_club::karate_club_graph();
let g = crate::graph_loader::karate_club::karate_club_graph();
assert_eq!(g.count_nodes(), 34);
assert_eq!(g.count_edges(), 155);
}
Expand All @@ -205,7 +210,7 @@ mod graph_loader_test {
fn db_lotr() {
let g = Graph::new();

let data_dir = crate::graph_loader::example::lotr_graph::lotr_file()
let data_dir = crate::graph_loader::lotr_graph::lotr_file()
.expect("Failed to get lotr.csv file");

fn parse_record(rec: &StringRecord) -> Option<(String, String, i64)> {
Expand Down Expand Up @@ -244,7 +249,7 @@ mod graph_loader_test {

#[test]
fn test_all_degrees_window() {
let g = crate::graph_loader::example::lotr_graph::lotr_graph();
let g = crate::graph_loader::lotr_graph::lotr_graph();

assert_eq!(g.count_edges(), 701);
assert_eq!(g.node("Gandalf").unwrap().degree(), 49);
Expand All @@ -263,7 +268,7 @@ mod graph_loader_test {

#[test]
fn test_all_neighbours_window() {
let g = crate::graph_loader::example::lotr_graph::lotr_graph();
let g = crate::graph_loader::lotr_graph::lotr_graph();

assert_eq!(g.count_edges(), 701);
assert_eq!(g.node("Gandalf").unwrap().neighbours().iter().count(), 49);
Expand Down Expand Up @@ -316,7 +321,7 @@ mod graph_loader_test {

#[test]
fn test_all_edges_window() {
let g = crate::graph_loader::example::lotr_graph::lotr_graph();
let g = crate::graph_loader::lotr_graph::lotr_graph();

assert_eq!(g.count_edges(), 701);
assert_eq!(g.node("Gandalf").unwrap().edges().iter().count(), 59);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{
db::{api::mutation::AdditionOps, graph::graph as rap},
graph_loader::source::neo4j_loader::Neo4JConnection,
io::neo4j_loader::Neo4JConnection,
prelude::{IntoProp, NO_PROPS},
};
use neo4rs::*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
//!
//! Example:
//! ```no_run
//! use raphtory::graph_loader::example::reddit_hyperlinks::reddit_graph;
//! use raphtory::graph_loader::reddit_hyperlinks::reddit_graph;
//! use raphtory::prelude::*;
//!
//! let graph = reddit_graph(120, false);
Expand Down Expand Up @@ -158,7 +158,7 @@ pub fn generate_reddit_graph(path: PathBuf) -> Graph {
mod reddit_test {
use crate::{
db::api::view::*,
graph_loader::example::reddit_hyperlinks::{reddit_file, reddit_graph},
graph_loader::reddit_hyperlinks::{reddit_file, reddit_graph},
};

#[test]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
use crate::{
graph_loader::{fetch_file, source::csv_loader::CsvLoader, unzip_file},
graph_loader::{fetch_file, unzip_file},
prelude::*,
};
use chrono::DateTime;
use regex::Regex;
use serde::Deserialize;
use std::{collections::HashMap, fs, path::PathBuf, time::Instant};
use crate::io::csv_loader::CsvLoader;

#[allow(dead_code)]
#[derive(Deserialize, std::fmt::Debug)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
//!
//! Example:
//! ```no_run
//! use raphtory::graph_loader::example::sx_superuser_graph::sx_superuser_graph;
//! use raphtory::graph_loader::sx_superuser_graph::sx_superuser_graph;
//! use raphtory::prelude::*;
//!
//! let graph = sx_superuser_graph().unwrap();
Expand All @@ -46,11 +46,12 @@
//! ```
use crate::{
graph_loader::{fetch_file, source::csv_loader::CsvLoader},
graph_loader::fetch_file,
prelude::*,
};
use serde::Deserialize;
use std::path::PathBuf;
use crate::io::csv_loader::CsvLoader;

#[derive(Deserialize, std::fmt::Debug)]
pub struct TEdge {
Expand Down Expand Up @@ -90,7 +91,7 @@ pub fn sx_superuser_graph() -> Result<Graph, Box<dyn std::error::Error>> {

#[cfg(test)]
mod sx_superuser_test {
use crate::graph_loader::example::sx_superuser_graph::{sx_superuser_file, sx_superuser_graph};
use crate::graph_loader::sx_superuser_graph::{sx_superuser_file, sx_superuser_graph};

#[test]
#[ignore] // don't hit SNAP by default
Expand Down
Loading

0 comments on commit 116d26c

Please sign in to comment.