-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathGraph+Debug.swift
More file actions
41 lines (36 loc) · 1.08 KB
/
Graph+Debug.swift
File metadata and controls
41 lines (36 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
//
// Graph+Debug.swift
// OpenAttributeGraphShims
#if canImport(Darwin) && !OPENATTRIBUTEGRAPH_COMPUTE // Compute's descriptionFormatDictionary API is not aligned with OAG yet.
import Foundation
@_spi(Debug)
extension Graph {
public var dict: [String: Any]? {
let options = [
DescriptionOption.format: Graph.descriptionFormatDictionary
] as NSDictionary
guard let description = Graph.description(nil, options: options) else {
return nil
}
guard let dictionary = description as? NSDictionary else {
return nil
}
return dictionary as? [String: Any]
}
// style:
// - bold: empty input/output edge
// - dashed: indirect or has no value
// color:
// - red: is_changed
public var dot: String? {
let options = [
DescriptionOption.format: Graph.descriptionFormatDot
] as NSDictionary
guard let description = Graph.description(self, options: options)
else {
return nil
}
return description as? String
}
}
#endif