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
impl ConGraph
pub fn new() -> ConGraph
Sourcepub fn add_nodes(&mut self, num_nodes: usize) -> Vec<u32>
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.
Sourcepub fn remove_node(&mut self, node: u32)
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.
Sourcepub fn remove_nodes(&mut self, nodes: Vec<u32>)
pub fn remove_nodes(&mut self, nodes: Vec<u32>)
Removes a collection of nodes and any resulting empty edges.
Sourcepub fn add_edge(&mut self, nodes: impl AsRef<[u32]>) -> u64
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
EdgeIDstorage type
pub fn remove_edge(&mut self, edge_id: u64)
Sourcepub fn cut(&self, cut_nodes: impl AsRef<[u32]>) -> usize
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.
Sourcepub fn to_disk(&self, path: &Path)
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.
pub fn from_file(path: &Path) -> Option<Self>
Trait Implementations§
Source§impl<'de> Deserialize<'de> for ConGraph
impl<'de> Deserialize<'de> for ConGraph
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl HyperGraph for ConGraph
impl HyperGraph for ConGraph
type NodeID = u32
type EdgeID = u64
Source§fn query_edge(&self, edge: &Self::EdgeID) -> Option<Vec<Self::NodeID>>
fn query_edge(&self, edge: &Self::EdgeID) -> Option<Vec<Self::NodeID>>
EdgeIDSource§fn containing_edges_of_nodes(
&self,
nodes: impl AsRef<[Self::NodeID]>,
) -> Vec<Self::EdgeID>
fn containing_edges_of_nodes( &self, nodes: impl AsRef<[Self::NodeID]>, ) -> Vec<Self::EdgeID>
Source§fn containing_edges(&self, edge: &Self::EdgeID) -> Vec<Self::EdgeID>
fn containing_edges(&self, edge: &Self::EdgeID) -> Vec<Self::EdgeID>
Source§fn link(&self, edge: &Self::EdgeID) -> Vec<(Self::EdgeID, Vec<Self::NodeID>)>
fn link(&self, edge: &Self::EdgeID) -> Vec<(Self::EdgeID, Vec<Self::NodeID>)>
Source§fn link_of_nodes(
&self,
nodes: impl AsRef<[Self::NodeID]>,
) -> Vec<(Self::EdgeID, Vec<Self::NodeID>)>
fn link_of_nodes( &self, nodes: impl AsRef<[Self::NodeID]>, ) -> Vec<(Self::EdgeID, Vec<Self::NodeID>)>
Source§fn maximal_edges(&self, edge_id: &Self::EdgeID) -> Vec<Self::EdgeID>
fn maximal_edges(&self, edge_id: &Self::EdgeID) -> Vec<Self::EdgeID>
Source§fn maximal_edges_of_nodes(
&self,
nodes: impl AsRef<[Self::NodeID]>,
) -> Vec<Self::EdgeID>
fn maximal_edges_of_nodes( &self, nodes: impl AsRef<[Self::NodeID]>, ) -> Vec<Self::EdgeID>
Source§fn edges_of_size(&self, card: usize) -> Vec<Self::EdgeID>
fn edges_of_size(&self, card: usize) -> Vec<Self::EdgeID>
Source§fn skeleton(&self, cardinality: usize) -> Vec<Self::EdgeID>
fn skeleton(&self, cardinality: usize) -> Vec<Self::EdgeID>
cardinality. Takes Theta(|E|) time.Source§fn boundary_up(&self, edge_id: &Self::EdgeID) -> Vec<Vec<Self::NodeID>>
fn boundary_up(&self, edge_id: &Self::EdgeID) -> Vec<Vec<Self::NodeID>>
boundary_up(1) would give
vec![2, 3].Source§fn boundary_down(&self, edge_id: &Self::EdgeID) -> Vec<Vec<Self::NodeID>>
fn boundary_down(&self, edge_id: &Self::EdgeID) -> Vec<Vec<Self::NodeID>>
Auto Trait Implementations§
impl Freeze for ConGraph
impl RefUnwindSafe for ConGraph
impl Send for ConGraph
impl Sync for ConGraph
impl Unpin for ConGraph
impl UnwindSafe for ConGraph
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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>
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