Struct Graph

Source
pub struct Graph<GH> { /* private fields */ }
Expand description

| Simple undirected unweighted graph | data structure no checks whatsoever | should call init_size(..) first then | insert_edge(..) to populate | | IMP: nodes have indexes from 0 to n-1 | | IMP: graph is assumed to be connected |

Implementations§

Source§

impl<GH> Graph<GH>

Source

pub fn nodeid_range(&self) -> Vec<NodeId>

Source

pub fn limited_nodeid_range(&self, cap: Option<usize>) -> Vec<NodeId>

Source

pub fn mapped_nodes(&self) -> Vec<NodeId>

Source

pub fn set_neighbors(&mut self, node: NodeId, nbrs: Vec<NodeId>)

Source

pub fn add_neighbor(&mut self, node: NodeId, nbr: NodeId)

Source

pub fn has_map_for_node(&self, node: NodeId) -> bool

Source

pub fn remove_node_and_neighbors(&mut self, node: NodeId)

Source

pub fn neighbors(&self, node: NodeId) -> Neighbors

Source

pub fn extend_mapped_nodes(&mut self, other: &NeighborsMap)

Source

pub fn nodes_map_add_edge(&mut self, e: &Edge)

Source

pub fn nodes_map_reinit(&mut self, len: usize)

Source

pub fn nodes_map_clear(&mut self)

Source

pub fn nodes_map_add_isolated_node(&mut self, node: NodeId)

Source

pub fn num_edges(&self) -> usize

Source

pub fn clear_edges(&mut self)

Source

pub fn has_edge(&self, edge: &Edge) -> bool

Source

pub fn connects(&self, src: NodeId, dst: NodeId) -> bool

Source

pub fn edges_to_node(&self, src: NodeId) -> Vec<Edge>

Source

pub fn edges_from_node(&self, src: NodeId) -> Vec<Edge>

Source

pub fn debug_all(&self) -> bool

Source

pub fn adjacency_list_for_dachshund(&self) -> Vec<(usize, usize)>

Source§

impl<GH> Graph<GH>

Source

pub fn node_to_muc_debugger<'g>( &'g self, ) -> NodeToMinimumUnionCycleDebugger<'g, Self>

Trait Implementations§

Source§

impl<GH> ApproxBrandesIterationRuntimeOnBccSubgraph for Graph<GH>

Source§

fn approx_bcc_iter_tm( &mut self, src: NodeId, dst: NodeId, avg_iter_time: &mut Duration, num_iter: Option<usize>, ) -> Result<(), BetweennessCentralityError>

| approximates the runtime of Brandes | iteration on a bcc subgraph by doing | @num_iter iteration and taking the average | if @num_iter is -1 the number of iteration | is just going to be the number of nodes in | the graph |

Source§

impl<GH> BuildGraphHashMappingForConnVertex<GH> for Graph<GH>

Source§

impl<GH> ClearMucs for Graph<GH>

Source§

impl<GH> CollectAllMucEdges for Graph<GH>

Source§

impl<GH> ConnectNodeIds for Graph<GH>

Source§

impl<GH> ConnectedComponentSize for Graph<GH>

Source§

fn connected_component_size_through_v_and_this_edge( &self, visit_markers: &mut VisitMarkers, u: NodeId, ) -> usize

do a dfs from this guy to figure out the size of the connected component connected to the bcc through v and this edge

Source§

impl<GH> ConstructMucs<GH> for Graph<GH>

Source§

fn construct_mucs(&mut self, conn_comp_vec: Vec<GH>)

Source§

impl<GH> ConstructMucsForConnectedComponent<GH> for Graph<GH>

Source§

impl<GH> ConstructSingleNodeMucs for Graph<GH>

Source§

impl<GH> CreateAndPushNewMuc for Graph<GH>

Source§

impl<GH> CreateNamedEmpty for Graph<GH>

Source§

fn empty(name: &str) -> Self

Source§

impl<GH> CreateRandomConnected for Graph<GH>

Source§

fn random_connected(n_vertices: usize, n_edges: usize) -> Self

TODO: This is probably inefficient, but maybe not that bad

Source§

impl<GH> CreateScoresVector for Graph<GH>

Source§

impl<GH> CreateSingleVertexMucs for Graph<GH>

Source§

impl<GH> Debug for Graph<GH>

Source§

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

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

impl<GH> FindAllMucSubgraphs for Graph<GH>

Source§

fn find_all_muc_subgraphs(&mut self)

find the disconnected subgraphs that will result from the deletion of connection vertices

Source§

impl<GH> FindConnVerts for Graph<GH>

Source§

fn find_conn_verts(&mut self) -> Result<(), BetweennessCentralityError>

find the connection vertices for each muc

edges that belong to the graph and don’t belong to any muc connect two connection vertices

  1. collect all edges in mucs in one set

  2. do simple subtraction of edges and update muc’s

Source§

impl<GH> FindEdgeBccWithComponent<GH> for Graph<GH>

Source§

fn find_edge_bcc_with_component_step( &mut self, gh: &GH, v: NodeId, component: &mut Component, e: &Edge, ) -> Result<(), BetweennessCentralityError>

the node is an articulation point and it belongs to the bcc of interest, so it must be added to the art point of this bcc along with the sizes of the subgraphs it connects the bcc to

Source§

fn find_edge_bcc_with_component( &mut self, component: &mut Component, e: &Edge, ) -> Result<(), BetweennessCentralityError>

a. find the bcc subgraph

b. find the articulation points in bcc

c. find the sizes of the subgraphs connected to each art point

IMP: assumes @e is not in the graph already

Source§

impl<GH> FindEdgeBccWithDelta<GH> for Graph<GH>

Source§

fn find_edge_bcc_with_delta( &mut self, bcc: &mut BiconnectedComponentsDelta<GH>, edge: &Edge, ) -> Result<(), BetweennessCentralityError>

a. find the bcc subgraph

b. find the articulation points in bcc

c. find the sizes of the subgraphs connected to each art point

Source§

fn find_edge_bcc_with_delta_step( &mut self, v: NodeId, bcc: &mut BiconnectedComponentsDelta<GH>, edge: &Edge, ) -> Result<(), BetweennessCentralityError>

the node is an articulation point and it belongs to the bcc of interest, so it must be added to the art point of this bcc along with the sizes of the subgraphs it connects the bcc to

Source§

impl<GH> FindEdgeBccWithScratch<GH> for Graph<GH>

Source§

fn find_edge_bcc_with_scratch( &mut self, bcc: &mut BiconnectedComponentsScratch<GH>, edge: &Edge, ) -> Result<(), BetweennessCentralityError>

a. find the bcc subgraph

b. find the articulation points in bcc

c. find the sizes of the subgraphs connected to each art point

Source§

fn find_edge_bcc_with_scratch_step( &mut self, v: NodeId, bcc: &mut BiconnectedComponentsScratch<GH>, edge: &Edge, ) -> Result<(), BetweennessCentralityError>

the node is an articulation point and it belongs to the bcc of interest, so it must be added to the art point of this bcc along with the sizes of the subgraphs it connects the bcc to

Source§

impl<GH> FindMucMcb<GH> for Graph<GH>

Source§

impl<GH> FindMucSubgraphs for Graph<GH>

Source§

fn find_muc_subgraphs( &mut self, muc_id: MinimumUnionCycleId, ) -> Result<(), BetweennessCentralityError>

| TODO not sure what to do with single node | muc’s, will not do anything for them | now |

Source§

impl<GH> FindMucs for Graph<GH>

Source§

fn find_mucs_fast(&mut self) -> Result<(), BetweennessCentralityError>

  1. find bridges

  2. delete bridges

  3. find connected components of size >=3 (these are MinimumUnionCycles)

Source§

fn find_mucs(&mut self)

Source§

impl<GH> FindSingleSourceShortestPaths for Graph<GH>

Source§

impl<GH> From<GraphMock> for Graph<GH>

Source§

fn from(mock: GraphMock) -> Self

Converts to this type from the input type.
Source§

impl<GH> FromFilename for Graph<GH>

Source§

fn from_filename(filename: &str) -> Self

Source§

impl<GH> GetEdgeListDebugger for Graph<GH>

Source§

fn edgelist_debugger<'g>(&'g self) -> EdgeListDebugger<'g, Self>

Source§

impl<GH> GetEdges for Graph<GH>

Source§

fn edges(&self) -> &Edges

Source§

impl<GH> GetMuc<GH> for Graph<GH>

Source§

impl<GH> GetMucDebuggerWithNodes for Graph<GH>

Source§

impl<GH> GetMucDebuggerWithoutNodes for Graph<GH>

Source§

impl<GH> GetMucs<GH> for Graph<GH>

Source§

fn get_mucs<'a>(&'a self) -> &Vec<MinimumUnionCycle<GH>>

Source§

impl<GH> GetNeighborsForNode for Graph<GH>

Source§

fn neighbors(&self, node: NodeId) -> Neighbors

Source§

impl<GH> GetNodesToMucs for Graph<GH>

Source§

fn get_nodes_to_mucs<'a>(&'a self) -> &'a MucIdMap

Source§

impl<GH> GetNumMucs for Graph<GH>

Source§

fn get_num_mucs(&mut self) -> usize

Source§

impl<GH> GetShortestPath for Graph<GH>

Source§

impl<GH> HasEdge for Graph<GH>

Source§

fn has_edge(&self, e: &Edge) -> bool

Source§

impl<GH> InitBetweennessCentrality for Graph<GH>

Source§

impl<GH> InitInternals for Graph<GH>

Source§

impl<GH> InitWithSize for Graph<GH>

Source§

fn init_size(&mut self, num_nodes: usize)

Source§

impl<GH> InsertEdge for Graph<GH>

Source§

impl<GH> InsertEdgeUpdateBc for Graph<GH>

Source§

fn insert_edge_update_bc_experimental( &mut self, edge: &Edge, bcc_stat: &mut BiconnectedComponentsStat, max_iter_d1: Option<usize>, max_iter_d2: Option<usize>, ) -> Result<(), BetweennessCentralityError>

Source§

impl<GH> InsertEdgeUpdateMuc for Graph<GH>

Source§

fn insert_edge_and_update_muc_when_full_edge_contained_in_muc( &mut self, edge: &Edge, src_muc_id: MinimumUnionCycleId, )

case 1: both @src and @dst are in the same muc

    then just update the graph and the
    muc graph

just update the muc and the graph

Source§

fn insert_edge_and_update_muc_when_we_are_not_in_the_same_muc( &mut self, edge: &Edge, src_muc_id: MinimumUnionCycleId, dst_muc_id: MinimumUnionCycleId, ) -> Result<(), BetweennessCentralityError>

case 2: @src and @dst are not in the same muc

Source§

fn insert_edge_update_muc(&mut self, edge: &Edge)

Source§

impl<GH> McbFind for Graph<GH>

Source§

fn mcb_find(&self)

will store into self.mcb

Source§

impl<GH> MergeMucCycle<GH> for Graph<GH>

Source§

fn merge_muc_cycle(&mut self, muc: &mut MinimumUnionCycle<GH>, cycle: &Cycle)

| add all the edges in cycle to muc |

Source§

impl<GH> Named for Graph<GH>

Source§

fn name(&self) -> Cow<'_, str>

Returns the name associated with self. We use Cow to allow both owned and borrowed strings.
Source§

impl<GH> NodeIdToMucId for Graph<GH>

Source§

impl<GH> NumEdges for Graph<GH>

Source§

impl<GH> NumNodes for Graph<GH>

Source§

impl<GH> PrintHeader for Graph<GH>

Source§

impl<GH> ReadGraph for Graph<GH>

Source§

impl<GH> RemoveEdge for Graph<GH>

Source§

impl<GH> ResetVisitMarkersAndVisitNode for Graph<GH>

Source§

impl<GH> SetGraphName for Graph<GH>

Source§

fn set_graph_name(&mut self, name: &str)

Source§

impl<GH> SetMucDebug for Graph<GH>

Source§

fn set_muc_debug(&self, val: bool)

Source§

impl<GH> SubtractEdge for Graph<GH>

Source§

impl<GH> VisitMarkersHandle for Graph<GH>

Auto Trait Implementations§

§

impl<GH> Freeze for Graph<GH>

§

impl<GH> RefUnwindSafe for Graph<GH>
where GH: RefUnwindSafe,

§

impl<GH> Send for Graph<GH>
where GH: Send + Sync,

§

impl<GH> Sync for Graph<GH>
where GH: Sync + Send,

§

impl<GH> Unpin for Graph<GH>
where GH: Unpin,

§

impl<GH> UnwindSafe for Graph<GH>

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<G> FindArticulationPoints for G

Source§

fn find_articulation_points(&self, out_vec: &mut Vec<NodeId>)

| This function will return a vector of | the articulation points. | | If an articulation point appears in | more than two biconnected components | it will appear more than once (number | of bcc’s it appears in -1) |

Source§

fn articulation_point_dfs_visitor<'a>( &self, u: NodeId, ctx: &mut ArticulationPointFinderContext<'a>, articulation_point_vec: &mut Vec<NodeId>, ) -> Result<(), BetweennessCentralityError>

Source§

fn articulation_point_dfs_visitor_step_tree_edge<'a>( &self, v: NodeId, u: NodeId, ctx: &mut ArticulationPointFinderContext<'a>, articulation_point_vec: &mut Vec<NodeId>, tree_edge_cnt: &mut i32, ) -> Result<(), BetweennessCentralityError>

Source§

impl<T> FindBiconnectedComponent for T

Source§

fn find_bicon_component<GH>(&mut self, out_vec: &mut Vec<GH>)

Source§

impl<G> FindBridgeEdges for G

Source§

fn find_bridge_edges<GH>(&mut self) -> Vec<Edge>

the single edge in a size 2 bcc is a bridge

Source§

impl<T> FindEdgeBccSubgraph for T

Source§

fn find_edge_bcc_subgraph<GH>( &mut self, bcc: &mut GH, edge: &Edge, ) -> Result<(), BetweennessCentralityError>

| the edge (@src, @dst) must be in the graph | the biconnected component subgraph that | contains the passed edge will be returned | in @bcc | | IMP assumption: | | the input graph is connected, and the edge | (src, dst) is inserted, so the edge (src, | dst) is part of a cycle, so both ends | belong to the same bcc | |IMP: (src,dst) must exist!

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> PoisonMessage for T
where T: Debug,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> BccGraphHashInterface for T