pub struct HeterogeneousAdjacency {
pub by_relation: Vec<Vec<(usize, usize)>>,
pub by_node_type: HashMap<(usize, usize), Vec<usize>>,
pub n_relations: usize,
pub n_node_types: usize,
}Expand description
Compact adjacency representation for heterogeneous graphs.
Stores edges both:
- Per relation type:
by_relation[r]= list of(src, dst)edges with relation typer. - Per
(src_node_type, dst_node_type)pair:by_node_type[(ts, tt)]= list of all node indicessrcthat have at least one edge to a node of typett.
Fields§
§by_relation: Vec<Vec<(usize, usize)>>Adjacency list per relation type: by_relation[r] = Vec<(src, dst)>.
by_node_type: HashMap<(usize, usize), Vec<usize>>Nodes per (src_type, dst_type) pair.
by_node_type[(src_type, dst_type)] contains the source node indices
for edges going from a node of src_type to a node of dst_type.
n_relations: usizeNumber of relation types
n_node_types: usizeNumber of node types
Implementations§
Source§impl HeterogeneousAdjacency
impl HeterogeneousAdjacency
Sourcepub fn from_typed_edges(
n_relations: usize,
n_node_types: usize,
node_types: &[usize],
typed_edges: &[(usize, usize, usize)],
) -> Self
pub fn from_typed_edges( n_relations: usize, n_node_types: usize, node_types: &[usize], typed_edges: &[(usize, usize, usize)], ) -> Self
Construct a HeterogeneousAdjacency from a list of typed edges.
§Arguments
n_relations– Total number of distinct relation types.n_node_types– Total number of distinct node types.node_types– Node type assignment for every node(len = n_nodes).typed_edges– List of(src, rel_type, dst)directed edges.
Sourcepub fn edges_for_relation(&self, r: usize) -> &[(usize, usize)]
pub fn edges_for_relation(&self, r: usize) -> &[(usize, usize)]
Return an iterator over all (src, dst) pairs for relation r.
Sourcepub fn sources_by_type(&self, src_type: usize, dst_type: usize) -> &[usize]
pub fn sources_by_type(&self, src_type: usize, dst_type: usize) -> &[usize]
Return all source node indices going to nodes of type dst_type from
nodes of type src_type.
Trait Implementations§
Source§impl Clone for HeterogeneousAdjacency
impl Clone for HeterogeneousAdjacency
Source§fn clone(&self) -> HeterogeneousAdjacency
fn clone(&self) -> HeterogeneousAdjacency
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for HeterogeneousAdjacency
impl RefUnwindSafe for HeterogeneousAdjacency
impl Send for HeterogeneousAdjacency
impl Sync for HeterogeneousAdjacency
impl Unpin for HeterogeneousAdjacency
impl UnsafeUnpin for HeterogeneousAdjacency
impl UnwindSafe for HeterogeneousAdjacency
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more