forked from Pometry/Raphtory
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* init taint algo * add vertex in read_vec_partitions * impl generic taint convergence * add test * more tests * more tests * init taint notebook * init taint notebook * impl py test * impl generic taint notebook * impl load stablecoin rust * add taint tracking * fix lotr and modify generic taint apis * impl loader for stablecoins * revive this if need be * simplify stable coin impl * impl generic taint generic over string and u64 * impl stablecoin fetch and tests * create default dir * create default dir * accept data dir as args * create dirs always * add err msg
- Loading branch information
1 parent
b52ae91
commit e212a34
Showing
20 changed files
with
1,062 additions
and
284 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"id": "5e76e492-a0b9-4199-8c46-bb10d1b15db2", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"{'5': [(6, 13, '2')], '1': [(0, 11, '1')], '2': [(2, 12, '1'), (2, 11, '1'), (0, 11, '2')], '4': [(5, 12, '2')]}Time taken to complete step 1 = 0\n", | ||
"\n", | ||
"Time taken to check convergence = 0\n", | ||
"Completed 1 steps in 0 secs\n", | ||
"Time taken to complete step 1 = 0\n", | ||
"Time taken to check convergence = 0\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"from raphtory import Graph\n", | ||
"from raphtory import algorithms\n", | ||
"\n", | ||
"# actual data\n", | ||
"g = Graph(1)\n", | ||
"g.add_edge(10, 1, 3, {})\n", | ||
"g.add_edge(11, 1, 2, {})\n", | ||
"g.add_edge(12, 1, 2, {})\n", | ||
"g.add_edge(9, 1, 2, {})\n", | ||
"g.add_edge(12, 2, 4, {})\n", | ||
"g.add_edge(13, 2, 5, {})\n", | ||
"g.add_edge(14, 5, 5, {})\n", | ||
"g.add_edge(14, 5, 4, {})\n", | ||
"g.add_edge(5, 4, 6, {})\n", | ||
"g.add_edge(15, 4, 7, {})\n", | ||
"g.add_edge(10, 4, 7, {})\n", | ||
"g.add_edge(10, 5, 8, {})\n", | ||
"\n", | ||
"actual = algorithms.generic_taint(g, 20, 11, [1, 2], [4, 5])\n", | ||
"expected = {\n", | ||
" '1': [(0, 11, '1')],\n", | ||
" '2': [(2, 12, '1'), (2, 11, '1'), (0, 11, '2')],\n", | ||
" '4': [(5, 12, '2')],\n", | ||
" '5': [(6, 13, '2')],\n", | ||
"}\n", | ||
"\n", | ||
"assert (actual == expected)\n", | ||
"\n", | ||
"print(actual)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "719e89be-da1f-4662-8055-1c1ee658116a", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python [conda env:pyraphtory] *", | ||
"language": "python", | ||
"name": "conda-env-pyraphtory-py" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.10.9" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
use std::env; | ||
use std::path::Path; | ||
use raphtory::algorithms::generic_taint::generic_taint; | ||
use raphtory::db::view_api::*; | ||
use raphtory::graph_loader::example::stable_coins::stable_coin_graph; | ||
use serde::Deserialize; | ||
use std::time::Instant; | ||
use raphtory::algorithms::pagerank::unweighted_page_rank; | ||
|
||
#[derive(Deserialize, std::fmt::Debug)] | ||
pub struct StableCoin { | ||
block_number: String, | ||
transaction_index: u32, | ||
from_address: String, | ||
to_address: String, | ||
time_stamp: i64, | ||
contract_address: String, | ||
value: f64, | ||
} | ||
|
||
fn main() { | ||
let args: Vec<String> = env::args().collect(); | ||
|
||
let data_dir = if args.len() < 2 { | ||
None | ||
} else { | ||
Some(args.get(1).unwrap().to_string()) | ||
}; | ||
|
||
let g = stable_coin_graph(data_dir, 1); | ||
|
||
assert_eq!(g.num_vertices(), 1523333); | ||
assert_eq!(g.num_edges(), 2871269); | ||
|
||
println!("Pagerank"); | ||
let now = Instant::now(); | ||
let _ = unweighted_page_rank(&g, i64::MIN..i64::MAX, 20); | ||
println!("Time taken: {} secs", now.elapsed().as_secs()); | ||
|
||
let now = Instant::now(); | ||
let _ = unweighted_page_rank(&g.layer("0xdac17f958d2ee523a2206206994597c13d831ec7").unwrap(), i64::MIN..i64::MAX, 20); | ||
println!("Time taken: {} secs", now.elapsed().as_secs()); | ||
|
||
println!("Generic taint"); | ||
let now = Instant::now(); | ||
let _ = generic_taint( | ||
&g.layer("0xdac17f958d2ee523a2206206994597c13d831ec7").unwrap(), | ||
20, | ||
1651105815, | ||
vec!["0xd30b438df65f4f788563b2b3611bd6059bff4ad9"], | ||
vec![], | ||
); | ||
println!("Time taken: {}", now.elapsed().as_secs()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.