icentral_subgraph/debug.rs
1crate::ix!();
2
3/*
4 | When Jesus came into the coasts of Cæsarea
5 | Philippi, he asked his disciples, saying, Whom do
6 | men say that I, the Son of man, am?
7 |
8 | And they said, Some say that thou art John the
9 | Baptist: some, Elias; and others, Jeremias, or one
10 | of the prophets.
11 |
12 | He saith unto them, But whom say ye that I am?
13 |
14 | And Simon Peter answered and said, Thou art the
15 | Christ, the Son of the living God.
16 |
17 | And Jesus answered and said unto him, Blessed art
18 | thou, Simon Bar-jona: for flesh and blood hath not
19 | revealed it unto thee, but my Father which is in
20 | heaven.
21 |
22 | And I say also unto thee, That thou art Peter, and
23 | upon this rock I will build my church; and the
24 | gates of hell shall not prevail against it.
25 |
26 | And I will give unto thee the keys of the kingdom
27 | of heaven: and whatsoever thou shalt bind on earth
28 | shall be bound in heaven: and whatsoever thou
29 | shalt loose on earth shall be loosed in heaven.
30 |
31 | Then charged he his disciples that they should
32 | tell no man that he was Jesus the Christ.
33 |
34 | From that time forth began Jesus to shew unto his
35 | disciples, how that he must go unto Jerusalem, and
36 | suffer many things of the elders and chief priests
37 | and scribes, and be killed, and be raised again
38 | the third day.
39 |
40 | Then Peter took him, and began to rebuke him,
41 | saying, Be it far from thee, Lord: this shall not
42 | be unto thee.
43 |
44 | But he turned, and said unto Peter, Get thee
45 | behind me, Satan: thou art an offence unto me: for
46 | thou savourest not the things that be of God, but
47 | those that be of men.
48 |
49 | Then said Jesus unto his disciples, If any man
50 | will come after me, let him deny himself, and take
51 | up his cross, and follow me.
52 |
53 | For whosoever will save his life shall lose it:
54 | and whosoever will lose his life for my sake shall
55 | find it.
56 |
57 | For what is a man profited, if he shall gain the
58 | whole world, and lose his own soul? or what shall
59 | a man give in exchange for his soul?
60 |
61 | For the Son of man shall come in the glory of his
62 | Father with his angels; and then he shall reward
63 | every man according to his works.
64 |
65 | Verily I say unto you, There be some standing
66 | here, which shall not taste of death, till they
67 | see the Son of man coming in his kingdom.
68 |
69 | - The Book of Matthew, Ch. 16
70 */
71impl fmt::Debug for SubGraph {
72
73    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
74
75        let binding = f.debug_struct("SubGraph");
76
77        let mut builder = binding;
78
79        builder.field("nodes_map",             &self.nodes_map);
80        builder.field("edges",                 &self.edges);
81        builder.field("label_map",             &self.label_map);
82        builder.field("parents",               &self.parents);
83
84        builder.field("path_counts",           &self.path_counts);
85        builder.field("new_path_counts",       &self.new_path_counts);
86        builder.field("inc_path_counts",       &self.inc_path_counts);
87
88        builder.field("distances",             &self.distances);
89
90        builder.field("pair_dependencies",     &self.pair_dependencies);
91        builder.field("new_pair_dependencies", &self.new_pair_dependencies);
92
93        builder.field("sigmas",                &self.sigmas);
94        builder.field("new_sigmas",            &self.new_sigmas);
95
96        builder.field("visit_markers",         &self.visit_markers);
97        builder.field("stack",                 &self.stack);
98        builder.field("queue",                 &self.queue);
99
100        builder.finish()
101    }
102}
103
104pub struct SubGraphDebugger<'g> {
105    host:       &'g SubGraph,
106    with_nodes: bool,
107}
108
109impl SubGraph {
110
111    pub fn debug_without_nodes<'g>(&'g self) -> SubGraphDebugger<'g> {
112
113        SubGraphDebugger {
114            host:       self,
115            with_nodes: false,
116        }
117    }
118
119    pub fn debug_with_nodes<'g>(&'g self) -> SubGraphDebugger<'g> {
120
121        SubGraphDebugger {
122            host:       self,
123            with_nodes: true,
124        }
125    }
126}
127
128impl<'g> fmt::Debug for SubGraphDebugger<'g> {
129
130    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
131
132        let binding = f.debug_struct("SubGraph");
133
134        let mut builder = binding;
135
136        builder.field(
137            "edges", 
138            self.host.edges()
139        );
140
141        if self.with_nodes {
142
143            builder.field("nodes", self.host.nodes());
144        }
145
146        builder.finish()
147    }
148}