pub struct NodeFeatures {
pub features: Vec<Vec<usize>>,
pub start_addrs: Vec<u64>,
}Fields§
§features: Vec<Vec<usize>>§start_addrs: Vec<u64>Implementations§
Source§impl NodeFeatures
impl NodeFeatures
Sourcepub fn new(file_name: &str) -> Result<Self, Box<dyn Error>>
pub fn new(file_name: &str) -> Result<Self, Box<dyn Error>>
§Arguments
- file_name - The name of the file to read
§return
- NodeFeatures - The features of the nodes
§Description
Reads a file containing a list of features for each node. note each line of file contains a dense format of a node feature example file format: 0 1 0 1 0 1 1 1 0
the result node feature will be stored as csr format
§example
ⓘ
use std::fs::File;
use std::io::{Read,Write};
use gcn_agg::node_features::NodeFeatures;
let data = "0 0 1 0 1 0\n1 0 0 1 1 1\n1 1 0 0 0 1\n";
let file_name = "test_data/node_features.txt";
// write the data to the file
let mut file = File::create(file_name)?;
file.write_all(data.as_bytes())?;
let node_features = NodeFeatures::from(file_name);
assert_eq!(node_features.len(), 3);
assert_eq!(node_features.get_features(0).len(), 2);
assert_eq!(node_features.get_features(1).len(), 4);
assert_eq!(node_features.get_features(2).len(), 3);
assert_eq!(node_features.get_features(0)[0], 2);
assert_eq!(node_features.get_features(0)[1], 4);
assert_eq!(node_features.get_features(1)[0], 0);
assert_eq!(node_features.get_features(1)[1], 3);
assert_eq!(node_features.get_features(1)[2], 4);
assert_eq!(node_features.get_features(1)[3], 5);
assert_eq!(node_features.get_features(2)[0], 0);
assert_eq!(node_features.get_features(2)[1], 1);
assert_eq!(node_features.get_features(2)[2], 5);
// delete the file
std::fs::remove_file(file_name)?;
Trait Implementations§
Auto Trait Implementations§
impl Freeze for NodeFeatures
impl RefUnwindSafe for NodeFeatures
impl Send for NodeFeatures
impl Sync for NodeFeatures
impl Unpin for NodeFeatures
impl UnwindSafe for NodeFeatures
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> 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