ConGraph

Struct ConGraph 

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

A connectivity only hypergraph object. Essentially a wrapper around HGraph with simpler add nodes/edges and simpler serialization to and from disk.

Implementations§

Source§

impl ConGraph

Source

pub fn new() -> ConGraph

Source

pub fn add_node(&mut self) -> u32

Panics if new node cannot be added.

Source

pub fn add_nodes(&mut self, num_nodes: usize) -> Vec<u32>

Adds num_nodes nodes to the graph, returning a vector containing the nodes created. panics if it runs out of nodes to allocate.

Source

pub fn remove_node(&mut self, node: u32)

Removes the node and any empty edges if the provided node is the last on in the edge. Singleton edges are allowed. For example, if you remove 2 from the edge {1, 2} the graph will retain the edge {1} so that way further nodes can be added back to the edge. If 1 is then removed the empty edge will be deleted.

Source

pub fn remove_nodes(&mut self, nodes: Vec<u32>)

Removes a collection of nodes and any resulting empty edges.

Source

pub fn nodes(&self) -> Vec<u32>

All node IDs that are currently in use.

Source

pub fn add_edge(&mut self, nodes: impl AsRef<[u32]>) -> u64

Creates an undirected edge among the given nodes with duplicate nodes removed. Duplicate edges are not allowed.

§panics
  • If not all nodes are present in the hypergraph
  • If you run out of possible id’s usable with the EdgeID storage type
Source

pub fn remove_edge(&mut self, edge_id: u64)

Source

pub fn find_id<E>(&self, nodes: E) -> Option<u64>
where E: AsRef<[u32]>,

In case you forget it :)

Source

pub fn edges(&self) -> Vec<u64>

All edge IDs currently in use within the hypergraph.

Source

pub fn cut(&self, cut_nodes: impl AsRef<[u32]>) -> usize

Computes the number of edges that have one vertex in the provided cut_nodes and one in the remaining set. For example, an edge with only support on the cut_nodes would not count. Neither would an edge without any nodes in cut_nodes. The type ToSet is any collection that can be converted to a sparse set representation.

Source

pub fn to_disk(&self, path: &Path)

Saves the disk in the same format as the graph is displayed. panics if the path is incorrect or the file cannot be written.

Source

pub fn from_file(path: &Path) -> Option<Self>

Trait Implementations§

Source§

impl Clone for ConGraph

Source§

fn clone(&self) -> ConGraph

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for ConGraph

Source§

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

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

impl Default for ConGraph

Source§

fn default() -> Self

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

impl<'de> Deserialize<'de> for ConGraph

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for ConGraph

Source§

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

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

impl FromStr for ConGraph

Source§

type Err = String

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl HyperGraph for ConGraph

Source§

type NodeID = u32

Source§

type EdgeID = u64

Source§

fn query_edge(&self, edge: &Self::EdgeID) -> Option<Vec<Self::NodeID>>

Retrieve the nodes associated with the given EdgeID
Source§

fn containing_edges_of_nodes( &self, nodes: impl AsRef<[Self::NodeID]>, ) -> Vec<Self::EdgeID>

Find all edge ids such that the given nodes are a subset or equal to the edge.
Source§

fn containing_edges(&self, edge: &Self::EdgeID) -> Vec<Self::EdgeID>

Find all edges such that the nodes of a given edge are a strict subset of.
Computes the link of the provided nodes by pairs of edge ids and what the link of the provided nodes are within the associated id. Ex: If the graph has edges {1, 2, 3}, {2, 3, 4}, {3, 4, 5}, and {2, 3} with ids 1,2, 3, and 4 respectively, then the link of edge_id = 4 would be vec![(1, [1]), (2, [2])].
Computes the link of the provided nodes by pairs of edge ids and what the link of the provided nodes are within the associated id. Ex: If the graph has edges {1, 2, 3}, {2, 3, 4}, and {3, 4, 5}, with ids 1,2, and 3 respectively, then the link of [3] would be vec![(1, [1, 2]), (2, [2, 4]), (3, [4, 5])].
Source§

fn maximal_edges(&self, edge_id: &Self::EdgeID) -> Vec<Self::EdgeID>

Finds the edges containing the edge associated with the provided ID that are not contained in any other edge. If the edge of the provided ID is maximal, it is not included in its return. Ex: {1, 2, 3}, {1,2, 3, 4}, {1, 2, 3, 4, 5} and you give the id of {1, 2, 3}, then the id of {1, 2, 3, 4, 5} will be returned.
Source§

fn maximal_edges_of_nodes( &self, nodes: impl AsRef<[Self::NodeID]>, ) -> Vec<Self::EdgeID>

Finds all edges containing provided nodes that are not contained in any other edge. If the provided nodes are a maximal edge, then that edges ID is returned.
Source§

fn edges_of_size(&self, card: usize) -> Vec<Self::EdgeID>

Warning: Has to filter all edges so takes Theta(|E|) time.
Source§

fn skeleton(&self, cardinality: usize) -> Vec<Self::EdgeID>

Returns the edges that have cardinality less than or equal to the input cardinality. Takes Theta(|E|) time.
Source§

fn boundary_up(&self, edge_id: &Self::EdgeID) -> Vec<Vec<Self::NodeID>>

Returns edges that constitute the boundary up operator, which adds a single node to the provided edge. Example: If a graph has edges {1, 2}, {1,2, 3}, {1,2,4}, and {1, 2, 3, 4} with ids 1, 2, 3, and 4 respectively, then boundary_up(1) would give vec![2, 3].
Source§

fn boundary_down(&self, edge_id: &Self::EdgeID) -> Vec<Vec<Self::NodeID>>

Finds the edges that are the same as the provided edge_id but have a single node removed. For example, {1, 2} would be in boundary_down of {1, 2, 3} if both edges were present. Returns an empty vec if the edge_id is incorrect.
Source§

fn boundary_up_of_nodes( &self, nodes: impl AsRef<[Self::NodeID]>, ) -> Vec<Vec<Self::NodeID>>

Finds all edges which contain one more node than the provided node.
Source§

fn boundary_down_of_nodes( &self, nodes: impl AsRef<[Self::NodeID]>, ) -> Vec<Vec<Self::NodeID>>

Finds all edges that have one node removed from the provided nodes.
Source§

impl Serialize for ConGraph

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. 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> 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> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,