<prompt> Tengeneza darasa la TypeScript ambalo linawakilisha muundo msingi wa data ya grafu yenye nodi na kingo. Tekeleza mbinu za kuongeza nodi, kuunganisha nodi na kingo, na kutekeleza vipenyo vya kina-kwanza na upana-kwanza.PLINFORMAT  <response>: darasa la GraphNode thamani: yoyote; kingo: GraphNode; mjenzi thamani: yoyote hii.thamani thamani; this.edges ; Grafu ya darasa nodi: GraphNode; mjenzi nodi hizi ; addNodethamani: yoyote: utupu const newNode GraphNode mpyathamani; this.nodes.pushnewNode; connectNodesnode1Value: any, node2Value: any: batili const node1 this.nodes.findnode node.value node1Value; const node2 this.nodes.findnode node.value node2Value; ikiwa !nodi1 !nodi2 kutupa Hitilafu mpya Moja au nodi zote mbili hazipo kwenye grafu.; node1.edges.pushnode2; node2.edges.pushnode1; deepFirstTraversalstartingValue: yoyote, callback: thamani: yoyote batili: batili const startingNode this.nodes.findnode node.value startingValue; ikiwa !Nodi ya kuanzia kutupa Hitilafu mpyaNjia ya kuanzia haipo kwenye grafu.; const visitedNodes new Set; const traverse Njia ya sasa: GraphNode ikiwa alitembeleaNodes.hascurrentNode kurudi; callbackcurrentNode.value; VisitNodes.addcurrentNode; currentNode.edges.forEachjirani pitiajirani; ; traversestartNode; widethFirstTraversalstartingValue: any, callback: thamani: yoyote batili: batili const startingNode this.nodes.findnode node.value startingValue; ikiwa !Nodi ya kuanzia kutupa Hitilafu mpyaNjia ya kuanzia haipo kwenye grafu.; const visitedNodes new Set; const queue: GraphNode startingNode; wakati foleni.urefu 0 const currentNode queue.shift!; ikiwa !visitedNodes.hascurrentNode callbackcurrentNode.value; VisitNodes.addcurrentNode; currentNode.edges.forEachjirani foleni.sukumajirani; const graph Grafu mpya;graph.addNodeA;graph.addNodeB;graph.addNodeC;graph.addNodeD;graph.connectNodesA, B;graph.connectNodesA, C;graph.connectNodesB, D;console.logUpitishaji wa kina-kwanza:;graph.depthFirstTraversalA, thamani console.logthamani;console.logUpana-kwanza upitishaji:;graph.breadthFirstTraversalA, thamani console.logthamani; 