Struct NodeFeatures

Source
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

Source

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)?;
Source§

impl NodeFeatures

Source

pub fn get_features(&self, node_id: usize) -> &Vec<usize>

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Trait Implementations§

Source§

impl Debug for NodeFeatures

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V