@@ -101,6 +101,13 @@ function Base.:(==)(a::ConnectionVertex, b::ConnectionVertex)
101
101
return true
102
102
end
103
103
104
+ function Base. show (io:: IO , vert:: ConnectionVertex )
105
+ for name in @view (vert. name[1 : (end - 1 )])
106
+ print (io, name, " ." )
107
+ end
108
+ print (io, vert. name[end ], " ::" , vert. isouter ? " outer" : " inner" )
109
+ end
110
+
104
111
"""
105
112
$(TYPEDEF)
106
113
@@ -138,6 +145,33 @@ function ConnectionGraph()
138
145
return ConnectionGraph (Dict {ConnectionVertex, Int} (), ConnectionVertex[], graph)
139
146
end
140
147
148
+ function Base. show (io:: IO , graph:: ConnectionGraph )
149
+ printstyled (io, get (io, :cgraph_name , " ConnectionGraph" ); color = :blue , bold = true )
150
+ println (io, " with " , length (graph. labels),
151
+ " vertices and " , nsrcs (graph. graph), " hyperedges" )
152
+ compact = get (io, :compact , false )
153
+ for edge_i in 𝑠vertices (graph. graph)
154
+ if compact && edge_i > 5
155
+ println (io, " ⋮" )
156
+ break
157
+ end
158
+ edge_idxs = 𝑠neighbors (graph. graph, edge_i)
159
+ type = graph. invmap[edge_idxs[1 ]]. type
160
+ if type <: Union{InputVar, OutputVar}
161
+ type = " Causal"
162
+ elseif type == Equality
163
+ # otherwise it prints `ModelingToolkit.Equality`
164
+ type = " Equality"
165
+ end
166
+ printstyled (io, " " , type; bold = true , color = :yellow )
167
+ print (io, " <" )
168
+ for vi in @view (edge_idxs[1 : (end - 1 )])
169
+ print (io, graph. invmap[vi], " , " )
170
+ end
171
+ println (io, graph. invmap[edge_idxs[end ]], " >" )
172
+ end
173
+ end
174
+
141
175
"""
142
176
$(TYPEDSIGNATURES)
143
177
@@ -208,6 +242,18 @@ Create an empty `ConnectionState` with empty graphs.
208
242
"""
209
243
ConnectionState () = ConnectionState (ConnectionGraph (), ConnectionGraph ())
210
244
245
+ function Base. show (io:: IO , state:: AbstractConnectionState )
246
+ printstyled (io, typeof (state); bold = true , color = :green )
247
+ println (io, " comprising of" )
248
+ ctx1 = IOContext (io, :cgraph_name => " Connection Network" , :compact => true )
249
+ show (ctx1, state. connection_graph)
250
+ println (io)
251
+ println (io, " And" )
252
+ println (io)
253
+ ctx2 = IOContext (io, :cgraph_name => " Domain Network" , :compact => true )
254
+ show (ctx2, state. domain_connection_graph)
255
+ end
256
+
211
257
"""
212
258
$(TYPEDSIGNATURES)
213
259
0 commit comments