-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathGraphEdge.ps1
41 lines (31 loc) · 915 Bytes
/
GraphEdge.ps1
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
class GraphEdge {
$startVertex
$endVertex
$weight
GraphEdge($startVertex, $endVertex) {
$this.DoInit($startVertex, $endVertex, 0)
}
GraphEdge($startVertex, $endVertex, $weight) {
$this.DoInit($startVertex, $endVertex, $weight)
}
hidden DoInit($startVertex, $endVertex, $weight) {
$this.startVertex = $startVertex
$this.endVertex = $endVertex
$this.weight = $weight
}
[object] getKey() {
$startVertexKey = $this.startVertex.getKey()
$endVertexKey = $this.endVertex.getKey()
return "$($startVertexKey)_$($endVertexKey)"
# return `${startVertexKey}_${endVertexKey}`;
}
[object] reverse() {
$tmp = $this.startVertex
$this.startVertex = $this.endVertex
$this.endVertex = $tmp
return $this
}
[string] toString() {
return $this.getKey()
}
}