Skip to content

Commit

Permalink
change to internal id instead of id method
Browse files Browse the repository at this point in the history
  • Loading branch information
narnolddd committed Jun 3, 2024
1 parent bbbf399 commit c3fbb44
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions raphtory/src/algorithms/motifs/global_temporal_three_node_motifs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use crate::{
},
};
use itertools::Itertools;
use raphtory_api::core::entities::VID;
use rustc_hash::FxHashSet;
use std::collections::HashMap;

Expand All @@ -28,22 +29,22 @@ where
G: StaticGraphViewOps,
{
let two_n_c = twonode_motif_count(evv, deltas.clone());
let neigh_map: HashMap<u64, usize> = evv
let neigh_map: HashMap<VID, usize> = evv
.neighbours()
.into_iter()
.enumerate()
.map(|(num, nb)| (nb.id(), num))
.map(|(num, nb)| (nb.node, num))
.collect();
let events = evv
.edges()
.iter()
.map(|e| e.explode())
.kmerge_by(|e1, e2| e1.time_and_index() < e2.time_and_index())
.map(|edge| {
if edge.src().id() == evv.id() {
star_event(neigh_map[&edge.dst().id()], 1, edge.time().unwrap())
if edge.src().node == evv.node {
star_event(neigh_map[&edge.dst().node], 1, edge.time().unwrap())
} else {
star_event(neigh_map[&edge.src().id()], 0, edge.time().unwrap())
star_event(neigh_map[&edge.src().node], 0, edge.time().unwrap())
}
})
.collect::<Vec<StarEvent>>();
Expand Down Expand Up @@ -78,9 +79,9 @@ where
let mut results = deltas.iter().map(|_| [0; 8]).collect::<Vec<[usize; 8]>>();

for nb in evv.neighbours().into_iter() {
let nb_id = nb.id();
let out = evv.graph().edge(evv.id(), nb_id);
let inc = evv.graph().edge(nb_id, evv.id());
let nb_id = nb.node;
let out = evv.graph().edge(evv.node, nb_id);
let inc = evv.graph().edge(nb_id, evv.node);
let events: Vec<TwoNodeEvent> = out
.iter()
.flat_map(|e| e.explode())
Expand All @@ -89,7 +90,7 @@ where
})
.map(|e| {
two_node_event(
if e.src().id() == evv.id() { 1 } else { 0 },
if e.src().node == evv.node { 1 } else { 0 },
e.time().unwrap(),
)
})
Expand Down Expand Up @@ -119,7 +120,7 @@ where
Context::from(&kcore_subgraph);

// Triangle Accumulator
let neighbours_set = accumulators::hash_set::<u64>(0);
let neighbours_set = accumulators::hash_set::<VID>(0);
ctx_subgraph.agg(neighbours_set);

let tri_mc = deltas
Expand All @@ -137,8 +138,8 @@ where

let neighbourhood_update_step = ATask::new(move |u: &mut EvalNodeView<NodeSubgraph<G>, ()>| {
for v in u.neighbours() {
if u.id() > v.id() {
v.update(&neighbours_set, u.id());
if u.node > v.node {
v.update(&neighbours_set, u.node);
}
}
Step::Continue
Expand All @@ -147,7 +148,7 @@ where
let intersection_compute_step = ATask::new(move |u: &mut EvalNodeView<NodeSubgraph<G>, ()>| {
for v in u.neighbours() {
// Find triangles on the UV edge
if u.id() > v.id() {
if u.node > v.node {
let intersection_nbs = {
match (
u.entry(&neighbours_set)
Expand All @@ -172,7 +173,7 @@ where
intersection_nbs.iter().for_each(|w| {
// For each triangle, run the triangle count.

let all_exploded = vec![u.id(), v.id(), *w]
let all_exploded = vec![u.node, v.node, *w]
.into_iter()
.sorted()
.permutations(2)
Expand All @@ -185,8 +186,8 @@ where
})
.kmerge_by(|e1, e2| e1.time_and_index() < e2.time_and_index())
.map(|e| {
let (src_id, dst_id) = (e.src().id(), e.dst().id());
let uid = u.id();
let (src_id, dst_id) = (e.src().node, e.dst().node);
let uid = u.node;
if src_id == *w {
new_triangle_edge(
false,
Expand Down

0 comments on commit c3fbb44

Please sign in to comment.