icentral_graph/
muc_debugger.rs

1crate::ix!();
2
3pub trait SetMucDebug {
4
5    fn set_muc_debug(&self, val: bool);
6}
7
8pub trait GetMucDebuggerWithoutNodes: Sized {
9
10    fn muc_debugger_without_nodes<'g>(&'g self) -> MinimumUnionCycleDebugger<'g,Self>;
11}
12
13pub trait GetMucDebuggerWithNodes: Sized {
14
15    fn muc_debugger_with_nodes<'g>(&'g self) -> MinimumUnionCycleDebugger<'g,Self>;
16}
17
18//----------------------------
19pub struct MinimumUnionCycleDebugger<'g,G> {
20    host:       &'g G,
21    with_nodes: bool,
22}
23
24impl<'g,GH> fmt::Debug for MinimumUnionCycleDebugger<'g,Graph<GH>> 
25where 
26    Graph<GH>
27    : SetMucDebug 
28    + GetMucs<GH> 
29    + SetPrintNodes 
30    + Debug,
31    GH
32    : ExtendWith<GH,Error=BetweennessCentralityError> 
33    + Debug
34    + GetConnectedComponentSizes
35    + GetEdges 
36    + GetNeighborsForNode
37    + GetNodeIdRange
38    + HasMapForNode
39    + InsertEdge
40    + InsertNode
41    + MappedNodes
42    + NumEdges
43    + NumNodes
44    + SetPrintNodes
45{
46    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
47
48        self.host.set_muc_debug(self.with_nodes);
49
50        f.debug_list()
51            .entries(self.host.get_mucs().iter())
52            .finish()
53    }
54}
55
56impl<GH> SetMucDebug for Graph<GH> 
57where GH: GraphHashMucInterface
58{
59    fn set_muc_debug(&self, val: bool) {
60
61        for muc in self.mucs.iter() {
62            muc.set_print_nodes(val);
63        }
64    }
65}
66
67impl<GH> GetMucDebuggerWithoutNodes for Graph<GH> {
68
69    fn muc_debugger_without_nodes<'g>(&'g self) -> MinimumUnionCycleDebugger<'g,Self> 
70    {
71        MinimumUnionCycleDebugger {
72            host:       self,
73            with_nodes: false,
74        }
75    }
76}
77
78impl<GH> GetMucDebuggerWithNodes for Graph<GH> {
79
80    fn muc_debugger_with_nodes<'g>(&'g self) -> MinimumUnionCycleDebugger<'g,Self> 
81    {
82        MinimumUnionCycleDebugger {
83            host:       self,
84            with_nodes: true,
85        }
86    }
87}