pub struct Graph {
pub num_nodes: usize,
pub num_edges: usize,
pub edges: Vec<(usize, usize)>,
pub node_features: Tensor,
pub edge_features: Option<Tensor>,
/* private fields */
}Expand description
Graph structure for GNN operations
Fields§
§num_nodes: usizeNumber of nodes
num_edges: usizeNumber of edges
edges: Vec<(usize, usize)>Edge list: (source, target) pairs
node_features: TensorNode features [num_nodes, feature_dim]
edge_features: Option<Tensor>Edge features [num_edges, edge_feature_dim] (optional)
Implementations§
Source§impl Graph
impl Graph
Sourcepub fn new(edges: Vec<(usize, usize)>, node_features: Tensor) -> Self
pub fn new(edges: Vec<(usize, usize)>, node_features: Tensor) -> Self
Create a new graph from edge list and node features
Sourcepub fn with_edge_features(self, edge_features: Tensor) -> Self
pub fn with_edge_features(self, edge_features: Tensor) -> Self
Add edge features
Sourcepub fn normalized_adjacency(&self) -> Tensor
pub fn normalized_adjacency(&self) -> Tensor
Compute normalized adjacency matrix (for GCN)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Graph
impl !RefUnwindSafe for Graph
impl Send for Graph
impl Sync for Graph
impl Unpin for Graph
impl !UnwindSafe for Graph
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