pub struct BipartiteGraph {
pub graph: Graph,
pub types: Vec<bool>,
}Expand description
A graph together with its vertex types: the output of the bipartite constructors and generators of this module.
Vertices with type false form the first class, vertices with type
true the second one. The fields are public: take them apart freely
(or use into_parts).
Fields§
§graph: GraphThe graph.
types: Vec<bool>The type of each vertex, indexed by vertex id.
Implementations§
Source§impl BipartiteGraph
impl BipartiteGraph
Sourcepub fn new(
types: Vec<bool>,
edges: &[(VertexId, VertexId)],
directed: bool,
) -> Result<Self>
pub fn new( types: Vec<bool>, edges: &[(VertexId, VertexId)], directed: bool, ) -> Result<Self>
Creates a bipartite graph from vertex types and a list of edges,
checking that every edge connects vertices of different types
(igraph_create_bipartite).
The number of vertices is types.len(). See Graph::create_bipartite.
§Errors
ErrorKind::InvalidValue if an edge
joins two vertices of the same type, or
ErrorKind::InvalidVertexId if an
endpoint is out of range.
§Examples
use igraph::bipartite::BipartiteGraph;
let b = BipartiteGraph::new(vec![false, true, false], &[(0, 1), (2, 1)], false).unwrap();
assert_eq!(b.part(true), vec![1]);
assert!(BipartiteGraph::new(vec![false, false], &[(0, 1)], false).is_err());Sourcepub fn from_graph(graph: Graph) -> Result<Option<Self>>
pub fn from_graph(graph: Graph) -> Result<Option<Self>>
Wraps graph with a 2-coloring found by Graph::bipartite_types,
or returns Ok(None) if the graph is not bipartite.
§Examples
use igraph::{bipartite::BipartiteGraph, prelude::*};
let square = Graph::from_edges(&[(0, 1), (1, 2), (2, 3), (3, 0)], 4, false).unwrap();
let b = BipartiteGraph::from_graph(square).unwrap().unwrap();
assert_eq!(b.types, vec![false, true, false, true]);
let triangle = Graph::from_edges(&[(0, 1), (1, 2), (2, 0)], 3, false).unwrap();
assert!(BipartiteGraph::from_graph(triangle).unwrap().is_none());Sourcepub fn into_parts(self) -> (Graph, Vec<bool>)
pub fn into_parts(self) -> (Graph, Vec<bool>)
Splits self into the graph and its types.
Sourcepub fn part(&self, kind: bool) -> Vec<VertexId> ⓘ
pub fn part(&self, kind: bool) -> Vec<VertexId> ⓘ
The ids of the vertices having type kind, in increasing order.
Sourcepub fn part_sizes(&self) -> (usize, usize)
pub fn part_sizes(&self) -> (usize, usize)
The number of vertices of type false and of type true.
Sourcepub fn projection(&self) -> Result<BipartiteProjection>
pub fn projection(&self) -> Result<BipartiteProjection>
Both one-mode projections, see Graph::bipartite_projection.
Sourcepub fn biadjacency(&self, weights: Option<&[f64]>) -> Result<Biadjacency>
pub fn biadjacency(&self, weights: Option<&[f64]>) -> Result<Biadjacency>
The bipartite adjacency matrix, see Graph::get_biadjacency.
Sourcepub fn maximum_matching(
&self,
weights: Option<&[f64]>,
) -> Result<BipartiteMatching>
pub fn maximum_matching( &self, weights: Option<&[f64]>, ) -> Result<BipartiteMatching>
A maximum (weighted) matching, see Graph::maximum_bipartite_matching.
Trait Implementations§
Source§impl Clone for BipartiteGraph
impl Clone for BipartiteGraph
Source§fn clone(&self) -> BipartiteGraph
fn clone(&self) -> BipartiteGraph
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for BipartiteGraph
impl Debug for BipartiteGraph
Source§impl PartialEq for BipartiteGraph
impl PartialEq for BipartiteGraph
Source§fn eq(&self, other: &BipartiteGraph) -> bool
fn eq(&self, other: &BipartiteGraph) -> bool
self and other values to be equal, and is used by ==.