@@ -13,14 +13,14 @@ The map taking `w` to the set of all `(u, v)` such that `(u, v, w)` is a positiv
13
13
Adjacent2Vertex(adj2v::Dict{IntegerType, EdgesType})
14
14
"""
15
15
struct Adjacent2Vertex{I,Es}
16
- adjacent2vertex:: Dict{I,Es}
17
- Adjacent2Vertex (adj2v:: Dict{I,Es} ) where {I,Es} = new {I,Es} (adj2v)
16
+ adjacent2vertex:: Dict{I,Es}
17
+ Adjacent2Vertex (adj2v:: Dict{I,Es} ) where {I,Es} = new {I,Es} (adj2v)
18
18
end
19
19
Adjacent2Vertex {I,Es} () where {I,Es} = Adjacent2Vertex (Dict {I,Es} ())
20
20
Base.:(== )(adj2v:: Adjacent2Vertex , adj2v2:: Adjacent2Vertex ) = get_adjacent2vertex (adj2v) == get_adjacent2vertex (adj2v2)
21
21
function Base. show (io:: IO , m:: MIME"text/plain" , adj2v:: Adjacent2Vertex{I,Es} ) where {I,Es}
22
- println (io, " Adjacent2Vertex{" , I, " , " , Es, " } with map:" )
23
- show (io, m, get_adjacent2vertex (adj2v))
22
+ println (io, " Adjacent2Vertex{" , I, " , " , Es, " } with map:" )
23
+ show (io, m, get_adjacent2vertex (adj2v))
24
24
end
25
25
Base. sizehint! (adj2v:: Adjacent2Vertex , n) = Base. sizehint! (get_adjacent2vertex (adj2v), n)
26
26
@@ -86,8 +86,8 @@ Set{Tuple{Int64, Int64}} with 3 elements:
86
86
```
87
87
"""
88
88
function get_adjacent2vertex (adj2v:: Adjacent2Vertex , w)
89
- dict = get_adjacent2vertex (adj2v)
90
- return dict[w]
89
+ dict = get_adjacent2vertex (adj2v)
90
+ return dict[w]
91
91
end
92
92
93
93
"""
@@ -123,15 +123,15 @@ Dict{Int64, Set{Tuple{Int64, Int64}}} with 2 entries:
123
123
```
124
124
"""
125
125
function add_adjacent2vertex! (adj2v:: Adjacent2Vertex{I,Es} , w, uv) where {I,Es}
126
- dict = get_adjacent2vertex (adj2v)
127
- existing_edges = get! (Es, dict, w)
128
- add_edge! (existing_edges, uv)
129
- return adj2v
126
+ dict = get_adjacent2vertex (adj2v)
127
+ existing_edges = get! (Es, dict, w)
128
+ add_edge! (existing_edges, uv)
129
+ return adj2v
130
130
end
131
131
function add_adjacent2vertex! (adj2v:: Adjacent2Vertex{I,Es} , w, u, v) where {I,Es}
132
- E = edge_type (Es)
133
- uv = construct_edge (E, u, v)
134
- return add_adjacent2vertex! (adj2v, w, uv)
132
+ E = edge_type (Es)
133
+ uv = construct_edge (E, u, v)
134
+ return add_adjacent2vertex! (adj2v, w, uv)
135
135
end
136
136
137
137
"""
@@ -165,14 +165,14 @@ Dict{Int64, Set{Tuple{Int64, Int64}}} with 2 entries:
165
165
```
166
166
"""
167
167
function delete_adjacent2vertex! (adj2v:: Adjacent2Vertex , w, uv)
168
- existing_edges = get_adjacent2vertex (adj2v, w)
169
- delete_edge! (existing_edges, uv)
170
- return adj2v
168
+ existing_edges = get_adjacent2vertex (adj2v, w)
169
+ delete_edge! (existing_edges, uv)
170
+ return adj2v
171
171
end
172
172
function delete_adjacent2vertex! (adj2v:: Adjacent2Vertex{I,Es} , w, u, v) where {I,Es}
173
- E = edge_type (Es)
174
- uv = construct_edge (E, u, v)
175
- return delete_adjacent2vertex! (adj2v, w, uv)
173
+ E = edge_type (Es)
174
+ uv = construct_edge (E, u, v)
175
+ return delete_adjacent2vertex! (adj2v, w, uv)
176
176
end
177
177
178
178
"""
@@ -201,9 +201,9 @@ Dict{Int64, Set{Tuple{Int64, Int64}}}()
201
201
```
202
202
"""
203
203
function delete_adjacent2vertex! (adj2v:: Adjacent2Vertex , w)
204
- dict = get_adjacent2vertex (adj2v)
205
- delete! (dict, w)
206
- return adj2v
204
+ dict = get_adjacent2vertex (adj2v)
205
+ delete! (dict, w)
206
+ return adj2v
207
207
end
208
208
209
209
"""
@@ -238,10 +238,10 @@ Dict{Int32, Set{Tuple{Int32, Int32}}} with 5 entries:
238
238
```
239
239
"""
240
240
function add_triangle! (adj2v:: Adjacent2Vertex , u:: Integer , v:: Integer , w:: Integer )
241
- add_adjacent2vertex! (adj2v, u, v, w)
242
- add_adjacent2vertex! (adj2v, v, w, u)
243
- add_adjacent2vertex! (adj2v, w, u, v)
244
- return adj2v
241
+ add_adjacent2vertex! (adj2v, u, v, w)
242
+ add_adjacent2vertex! (adj2v, v, w, u)
243
+ add_adjacent2vertex! (adj2v, w, u, v)
244
+ return adj2v
245
245
end
246
246
add_triangle! (adj2v:: Adjacent2Vertex , T) = add_triangle! (adj2v, geti (T), getj (T), getk (T))
247
247
@@ -295,10 +295,10 @@ Dict{Int32, Set{Tuple{Int32, Int32}}} with 5 entries:
295
295
```
296
296
"""
297
297
function delete_triangle! (adj2v:: Adjacent2Vertex , u:: Integer , v:: Integer , w:: Integer )
298
- delete_adjacent2vertex! (adj2v, u, v, w)
299
- delete_adjacent2vertex! (adj2v, v, w, u)
300
- delete_adjacent2vertex! (adj2v, w, u, v)
301
- return adj2v
298
+ delete_adjacent2vertex! (adj2v, u, v, w)
299
+ delete_adjacent2vertex! (adj2v, v, w, u)
300
+ delete_adjacent2vertex! (adj2v, w, u, v)
301
+ return adj2v
302
302
end
303
303
delete_triangle! (adj2v:: Adjacent2Vertex , T) = delete_triangle! (adj2v, geti (T), getj (T), getk (T))
304
304
@@ -335,15 +335,15 @@ Dict{Int64, Set{Tuple{Int64, Int64}}}()
335
335
```
336
336
"""
337
337
function clear_empty_keys! (adj2v:: Adjacent2Vertex )
338
- dict = get_adjacent2vertex (adj2v)
339
- for ( w, S) in dict
340
- isempty (S) && delete_adjacent2vertex! (adj2v, w)
341
- end
342
- return adj2v
338
+ dict = get_adjacent2vertex (adj2v)
339
+ foreach (dict) do ( w, S)
340
+ isempty (S) && delete_adjacent2vertex! (adj2v, w)
341
+ end
342
+ return adj2v
343
343
end
344
344
345
345
function Base. empty! (adj2v:: Adjacent2Vertex )
346
- dict = get_adjacent2vertex (adj2v)
347
- empty! (dict)
348
- return adj2v
346
+ dict = get_adjacent2vertex (adj2v)
347
+ empty! (dict)
348
+ return adj2v
349
349
end
0 commit comments