-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathGraphTracer.ts
175 lines (158 loc) · 3.71 KB
/
GraphTracer.ts
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
import { LogTracer, Tracer } from './';
export default class GraphTracer extends Tracer {
/**
* Set an adjacency matrix to visualize.
*
* @param array2d
*/
set(array2d?: any[][]) {
this.command('set', arguments);
}
/**
* Make the graph directed.
*
* @param isDirected
*/
directed(isDirected?: boolean) {
this.command('directed', arguments);
return this;
}
/**
* Make the graph weighted.
*
* @param isWeighted
*/
weighted(isWeighted?: boolean) {
this.command('weighted', arguments);
return this;
}
/**
* Arrange nodes on a circular layout.
*/
layoutCircle() {
this.command('layoutCircle', arguments);
return this;
}
/**
* Arrange nodes on a tree layout.
*
* @param root The id of a root node.
* @param sorted Whether to sort sibling nodes.
*/
layoutTree(root?: any, sorted?: boolean) {
this.command('layoutTree', arguments);
return this;
}
/**
* Arrange nodes randomly.
*/
layoutRandom() {
this.command('layoutRandom', arguments);
return this;
}
/**
* Add a node.
*
* @param id
* @param weight
* @param x The x position between `-160` and `+160`.
* @param y The y position between `-160` and `+160`.
*/
addNode(id: any, weight?: any, x?: number, y?: number) {
this.command('addNode', arguments);
}
/**
* Update a node.
*
* @param id
* @param weight
* @param x The x position between `-160` and `+160`.
* @param y The y position between `-160` and `+160`.
*/
updateNode(id: any, weight?: any, x?: number, y?: number) {
this.command('updateNode', arguments);
}
/**
* Remove a node.
*
* @param id
*/
removeNode(id: any) {
this.command('removeNode', arguments);
}
/**
* Add an edge.
*
* @param source The id of the node where the edge starts.
* @param target The id of the node where the edge ends.
* @param weight
*/
addEdge(source: any, target: any, weight?: any) {
this.command('addEdge', arguments);
}
/**
* Update an edge.
*
* @param source The id of the node where the edge starts.
* @param target The id of the node where the edge ends.
* @param weight
*/
updateEdge(source: any, target: any, weight?: any) {
this.command('updateEdge', arguments);
}
/**
* Remove an edge.
*
* @param source The id of the node where the edge starts.
* @param target The id of the node where the edge ends.
*/
removeEdge(source: any, target: any) {
this.command('removeEdge', arguments);
}
/**
* Visit a node.
*
* @param target The id of the node to visit.
* @param source The id of the node to visit from.
* @param weight The weight of `target` to set to.
*/
visit(target: any, source?: any, weight?: any) {
this.command('visit', arguments);
}
/**
* Leave after visiting a node.
*
* @param target The id of the node to leave.
* @param source The id of the node to leave to.
* @param weight The weight of `target` to set to.
*/
leave(target: any, source?: any, weight?: any) {
this.command('leave', arguments);
}
/**
* Select a node.
*
* @param target The id of the node to select.
* @param source The id of the node to select from.
*/
select(target: any, source?: any) {
this.command('select', arguments);
}
/**
* Stop selecting a node.
*
* @param target The id of the node to stop selecting.
* @param source The id of the node to stop selecting from.
*/
deselect(target: any, source?: any) {
this.command('deselect', arguments);
}
/**
* Synchronize with a log tracer.
*
* @param logTracer
*/
log(logTracer: LogTracer) {
this.command('log', arguments);
}
}