Skip to main content

Edges

Struct Edges 

Source
pub struct Edges { /* private fields */ }
Expand description

A list of edges of a graph, each with its source, target and edge index. Algorithms such as back_edges::of and Biconnectivity::bridges return it.

The edge at position p, in 0..count(), is source_nodes()[p] -> target_nodes()[p], and edge_indices()[p] is its edge index in the graph the algorithm ran on. The edge index finds the data of the edge in the caller’s arrays indexed by edge index, without a search. Here, the back edges of the calls between the methods of a program are its recursive calls. names holds the names of the methods, and site_count holds the number of call sites of each call, by edge index:

let recursive = back_edges::of(&calls);
for p in 0..recursive.count() as usize {
    let caller = recursive.source_nodes()[p];
    let callee = recursive.target_nodes()[p];
    let edge = recursive.edge_indices()[p];
    writeln!(
        out,
        "{} -> {}: {}",
        names[caller as usize], names[callee as usize], site_count[edge as usize]
    )?;
}
// parse -> parse: 2
// format -> format: 1

Each function that returns Edges says in which order the edges come. GraphBuilder::add_edges adds them to a graph under construction.

The three lists are slices that cannot be modified - Java returns unmodifiable IntLists. Instances are immutable and safe to share between threads (Send and Sync).

Memory: 12 bytes per edge.

Implementations§

Source§

impl Edges

Source

pub fn of(edge_types: &EdgeTypes, edge_type: EdgeType) -> Edges

Returns the edges of one type from an edge classification, in edge index order.

Each call goes through every edge, however few have the type: call it once per type and keep the result.

Time: O(node_count + edge_count). Memory: 12 bytes per edge of the result.

Source

pub fn source_nodes(&self) -> &[u32]

Returns the source of each edge, by position.

Time: O(1).

Source

pub fn target_nodes(&self) -> &[u32]

Returns the target of each edge, by position.

Time: O(1).

Source

pub fn edge_indices(&self) -> &[u32]

Returns the edge index of each edge in the graph the algorithm ran on, by position.

Time: O(1).

Source

pub fn count(&self) -> u32

Returns the number of edges.

Time: O(1).

Source

pub fn is_empty(&self) -> bool

Returns whether there are no edges. Equivalent to count() == 0.

Time: O(1).

Trait Implementations§

Source§

impl Clone for Edges

Source§

fn clone(&self) -> Edges

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Edges

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for Edges

Source§

fn default() -> Edges

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

impl Eq for Edges

Source§

impl Hash for Edges

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Edges

Source§

fn eq(&self, other: &Edges) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Edges

Auto Trait Implementations§

§

impl Freeze for Edges

§

impl RefUnwindSafe for Edges

§

impl Send for Edges

§

impl Sync for Edges

§

impl Unpin for Edges

§

impl UnsafeUnpin for Edges

§

impl UnwindSafe for Edges

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.