Initial commit

This commit is contained in:
Thomas Nordquist
2018-12-28 15:25:25 +01:00
commit 0af3a2ede3
21 changed files with 2892 additions and 0 deletions

37
src/Model/Edge.ts Normal file
View File

@@ -0,0 +1,37 @@
import { Hashable, TreeNode, TopicProperties } from './'
const sha1 = require('sha1')
export class Edge {
public name: string
public node!: TreeNode
public source: TreeNode | undefined
public target: TreeNode | undefined
constructor(name: string) {
this.name = name
}
public edges() {
return this.node ? Object.values(this.node.edges) : []
}
public hash(): string {
let previousHash = this.source ? this.source.sourceEdge.hash() : ''
return 'H' + sha1(previousHash + this.name)
}
public firstEdge(): Edge {
if (this.source) {
return this.source.sourceEdge.firstEdge()
} else {
return this
}
}
// public merge(edge: Edge) {
// if (this.node && edge.node) {
// this.node.updateWithNode(edge.node)
// }
// }
}