Pagerank

Struct Pagerank 

Source
pub struct Pagerank<T>
where T: Eq + Hash + Clone,
{ /* private fields */ }
Expand description

PageRank structure.

Implementations§

Source§

impl<T> Pagerank<T>
where T: Eq + Hash + Clone,

Source

pub fn new() -> Pagerank<T>

Creates a new instance

Source

pub fn set_damping_factor(&mut self, factor: u8) -> Result<(), String>

Sets the dumping factor. A value between 0 and 100 is expected.

Source

pub fn add_edge(&mut self, source: T, target: T)

Adds an node between two nodes

Source

pub fn get_score(&self, node: T) -> Option<f64>

Returns the current score of a gien node

Source

pub fn get_in_edges(&self, node: T) -> Option<usize>

Returns the number of in edges for the given node

Source

pub fn get_out_edges(&self, node: T) -> Option<usize>

Returns the number of out edges for the given node

Source

pub fn get_or_create_node(&mut self, node: T) -> usize

Returns the node_id for a given node name

Source

pub fn calculate_with_convergence(&mut self, convergence: f64) -> i32

Calculates PageRank with custom convergence

Source

pub fn calculate(&mut self) -> i32

Calculates pagerank with custom convergence

Source

pub fn nodes(&self) -> Vec<(&T, f64)>

Return all nodes, sorted by their pagerank

Source

pub fn calculate_step(&mut self) -> f64

Calculates a single iteration of the PageRank

Source

pub fn len_nodes_with_in_edges(&mut self) -> usize

Len of all edges

Source

pub fn len(&self) -> usize

Return the number of vertices/nodes in the current graph

Source

pub fn len_node(&self) -> usize

Returns the number of edges in the current graph

Source

pub fn is_empty(&self) -> bool

If the graph is empty

Trait Implementations§

Source§

impl<T> Default for Pagerank<T>
where T: Eq + Hash + Clone,

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<T> Freeze for Pagerank<T>

§

impl<T> RefUnwindSafe for Pagerank<T>
where T: RefUnwindSafe,

§

impl<T> Send for Pagerank<T>
where T: Send,

§

impl<T> Sync for Pagerank<T>
where T: Sync,

§

impl<T> Unpin for Pagerank<T>
where T: Unpin,

§

impl<T> UnwindSafe for Pagerank<T>
where T: UnwindSafe,

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, 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.