icentral_graph_interface/
traits.rs

1crate::ix!();
2
3pub trait IsValid {
4
5    fn is_valid(&self) -> bool;
6}
7
8pub trait McbFind {
9
10    fn mcb_find(&self);
11}
12
13pub trait PrintHeader {
14
15    fn print_header(&self);
16}
17
18pub trait InitDebugIteration {
19
20    fn init_dbg_iteration(&mut self, source: NodeId);
21}
22
23pub trait DebugIterationStep {
24
25    fn dbg_iteration_step(&mut self, v_s: &mut Vec<NodeId>) 
26    -> Result<(),BetweennessCentralityError>;
27}
28
29pub trait UpdateWithSrcDst {
30
31    fn update(&mut self, src: NodeId, dst: NodeId);
32}
33
34pub trait UpdatePairDependencies {
35
36    fn update_pair_dependencies(&mut self, v_p: NodeId, v_n: NodeId);
37
38    fn update_new_pair_dependencies(&mut self, v_p: NodeId, v_n: NodeId);
39}
40
41pub trait GetConnectedComponentSizes {
42
43    fn conn_comp_sizes(&self) 
44    -> Result<Vec<i32>,BetweennessCentralityError>;
45}
46
47pub trait FindSingleSourceShortestPaths {
48
49    fn find_single_source_shortest_paths(&self, s: NodeId) 
50    -> Result<DistanceMap,BetweennessCentralityError>;
51}
52
53pub trait CreateDistanceMaps {
54
55    fn create_distance_maps(&self, edge: &Edge)
56    -> Result<(DistanceMap, DistanceMap),BetweennessCentralityError>;
57}
58
59pub trait ComputeNewPathCountsAndPaths {
60
61    fn compute_new_path_counts_and_paths(
62        &mut self, 
63        src: NodeId, 
64        dst: NodeId);
65}
66
67pub trait BfsFromSource {
68
69    fn do_bfs_from_source_count_vertices_and_mark_visited(
70        &self, 
71        source:        NodeId, 
72        visit_markers: &mut VisitMarkers,
73        out_vec:       &mut Vec<i32>)
74    -> Result<(),BetweennessCentralityError>;
75}
76
77pub trait FindPruningCounts {
78
79    fn find_pruning_counts_exp(&mut self, 
80        src:    NodeId,
81        dst:    NodeId) 
82    -> Result<(i32,i32,i32),BetweennessCentralityError>;
83}
84
85pub trait FindConnVerts {
86
87    fn find_conn_verts(&mut self) 
88    -> Result<(),BetweennessCentralityError>;
89}
90
91pub trait BuildGraphHashMappingForConnVertex<GH> {
92
93    fn build_graphhash_mapping_for_conn_vertex_step(
94        &self, 
95        gh:         &mut GH,
96        bfs_source: NodeId,
97        conn_vert:  NodeId,
98        item:       (NodeId, &Vec<NodeId>),
99        muc_id:     MinimumUnionCycleId) 
100    -> Result<(),BetweennessCentralityError>;
101
102    fn build_graphhash_mapping_for_conn_vertex(
103        &self, 
104        item:   (NodeId, &Vec<NodeId>),
105        muc_id: MinimumUnionCycleId) 
106    -> Result<(NodeId, Arc<GH>),BetweennessCentralityError>;
107}
108
109pub trait FindMucSubgraphs {
110
111    fn find_muc_subgraphs(&mut self, muc_id: MinimumUnionCycleId) 
112    -> Result<(),BetweennessCentralityError>;
113}
114
115pub trait ConnectNodeIds {
116
117    fn connect_nodeids(&mut self, src: NodeId, dst: NodeId) 
118    -> Result<(),BetweennessCentralityError>;
119}
120
121pub trait ResetVisitMarkersAndVisitNode {
122
123    fn reset_visit_markers_and_visit_node(
124        &mut self, 
125        node: NodeId);
126}
127
128pub trait VisitMarkersHandle {
129
130    fn visit_markers_handle(&mut self) -> &mut VisitMarkers;
131}
132
133pub trait ReadGraph {
134    type Error;
135
136    fn read_graph(&mut self, path: &str) 
137    -> Result<(),Self::Error>;
138}
139
140pub trait GetShortestPath {
141
142    fn get_shortest_path(&mut self, 
143        src:      NodeId,
144        dst:      NodeId)  
145    -> Result<Vec<NodeId>,BetweennessCentralityError>;
146}
147
148pub trait BrandesIterInit {
149
150    fn brandes_iter_init(&mut self, s: NodeId);
151}
152
153pub trait BrandesIterUpdateDistancesAndPathForNeighbors {
154
155    fn brandes_iter_update_dist_and_path_for_neighbors(&mut self, s: NodeId);
156}
157
158pub trait GetPrintNodes {
159
160    fn get_print_nodes(&self) -> bool;
161}
162
163pub trait SetPrintNodes {
164
165    fn set_print_nodes(&self, val: bool);
166}
167
168pub trait InsertNode {
169
170    fn insert_node(&mut self, id: NodeId);
171}
172
173pub trait ReinitMaps {
174
175    fn reinit_maps(&mut self);
176}
177
178pub trait ReinitMapsForNode {
179
180    fn reinit_maps_for_node(&mut self, k: NodeId);
181}
182
183pub trait CreateAndPushNewMuc {
184
185    type Error;
186
187    fn create_and_push_new_muc(
188        &mut self, 
189        shortest_path: &Vec<NodeId>,
190        edge:          &Edge, 
191        src_muc_id:    MinimumUnionCycleId,
192        dst_muc_id:    MinimumUnionCycleId)
193    -> Result<MinimumUnionCycleId,Self::Error>;
194}
195
196pub trait ConnectedComponentSize {
197
198    fn connected_component_size_through_v_and_this_edge(
199        &self, 
200        visit_markers: &mut VisitMarkers, 
201        u:             NodeId) -> usize;
202}
203
204pub trait InitBetweennessCentrality {
205
206    fn init_bc(&mut self) 
207    -> Result<(),BetweennessCentralityError>;
208}
209
210pub trait ApproxBrandesIterationRuntimeOnBccSubgraph {
211
212    fn approx_bcc_iter_tm(&mut self, 
213        src:           NodeId,
214        dst:           NodeId,
215        avg_iter_time: &mut Duration,
216        num_iter:      Option<usize>) 
217    -> Result<(),BetweennessCentralityError>;
218}
219
220pub trait FromFilename {
221
222    fn from_filename(filename: &str) -> Self;
223}
224
225pub trait InsertEdgeUpdateMuc {
226
227    fn insert_edge_and_update_muc_when_full_edge_contained_in_muc(&mut self, 
228        edge:       &Edge, 
229        src_muc_id: MinimumUnionCycleId
230    );
231
232    fn insert_edge_and_update_muc_when_we_are_not_in_the_same_muc(
233        &mut self, 
234        edge:       &Edge, 
235        src_muc_id: MinimumUnionCycleId,
236        dst_muc_id: MinimumUnionCycleId) 
237    -> Result<(),BetweennessCentralityError>;
238
239    fn insert_edge_update_muc(&mut self, edge: &Edge);
240}
241
242pub trait InsertEdgeUpdateBc {
243
244    fn insert_edge_update_bc_experimental(&mut self, 
245        edge:        &Edge,
246        bcc_stat:    &mut BiconnectedComponentsStat,
247        max_iter_d1: Option<usize>,
248        max_iter_d2: Option<usize>) 
249    -> Result<(),BetweennessCentralityError>;
250}
251
252pub trait SubtractEdge {
253
254    fn simple_subtract_edge_and_update_mucs(&mut self, edge: &Edge);
255
256    fn maybe_simple_subtract_edge_and_update_mucs(
257        &mut self, 
258        edge:          &Edge,
259        all_muc_edges: &Edges
260    );
261
262    fn do_simple_subtraction_of_edges_and_update_mucs(
263        &mut self, 
264        all_muc_edges: &Edges
265    );
266}
267
268pub trait CreateRandomConnected {
269
270    fn random_connected(n_vertices: usize, n_edges: usize) -> Self;
271}
272
273pub trait SetGraphName {
274
275    fn set_graph_name(&mut self, name: &str);
276}
277
278pub trait NewFromCycleVec {
279
280    fn new_from_cycle_vec(cycle_vec: &Vec<Cycle>, name: &str) -> Self;
281}
282
283pub trait NewFromGraphRef<G> {
284
285    fn new_from_graph_ref(graph: &G, name: &str) -> Self;
286}
287
288pub trait RemoveBridges {
289
290     fn remove_bridges(&mut self, bridge_vec: Vec<Edge>);
291}
292
293pub trait FindConnectedComponents<GH> {
294
295    type Error;
296
297    fn find_conn_comp(&mut self) 
298    -> Result<Vec<GH>,Self::Error>;
299}