Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented a stop button for BFS/ DFS/ Dijksra visualization #507

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/app/components/header/header.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,9 @@ <h2 data-i18n="interactive-graph-visualizer">Interactive Graph Visualizer</h2>
</p>
<div class="button-container">
<!-- BFS Button -->
<button (click)="startBFS()">
{{ isBFSRunning ? 'Stop BFS' : 'Start BFS' }}
</button>
<button class="algo-button" (click)="startBFS()">Start BFS</button>
<div *ngIf="showBFSGif" class="gif-container">
<img
Expand All @@ -420,6 +423,9 @@ <h2 data-i18n="interactive-graph-visualizer">Interactive Graph Visualizer</h2>
</div>

<!-- DFS Button -->
<button (click)="startDFS()">
{{ isDFSRunning ? 'Stop DFS' : 'Start DFS' }}
</button>
<button class="algo-button" (click)="startDFS()">Start DFS</button>
<div *ngIf="showDFSGif" class="gif-container">
<img
Expand All @@ -429,6 +435,9 @@ <h2 data-i18n="interactive-graph-visualizer">Interactive Graph Visualizer</h2>
</div>

<!-- Dijkstra Button -->
<button (click)="startDijkstra()">
{{ isDijkstraRunning ? 'Stop Dijkstra' : 'Start Dijkstra' }}
</button>
<button class="algo-button" (click)="startDijkstra()">Start Dijkstra</button>
<div *ngIf="showDijkstraGif" class="gif-container">
<img
Expand Down
12 changes: 9 additions & 3 deletions src/app/components/header/header.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@ export class HeaderComponent implements AfterViewInit, OnDestroy {
private resizeListener: (() => void) | null = null; // Initialize as null
activeTab: string = 'dfs'; // Default tab is 'dfs'
showBFSGif: boolean = false; // Default for BFS visualization
isBFSRunning: boolean = false;
showDFSGif: boolean = false; // Default for DFS visualization
isDFSRunning: boolean =false;
showDijkstraGif: boolean = false; // Default for Dijkstra visualization
isDijkstraRunning: boolean = false;

setActiveTab(tab: string) {
this.activeTab = tab;
Expand Down Expand Up @@ -52,17 +55,20 @@ export class HeaderComponent implements AfterViewInit, OnDestroy {
}

startBFS() {
this.showBFSGif = !this.showBFSGif; // Toggle the visibility
this.isBFSRunning = !this.isBFSRunning; // Toggle the BFS state on/off
this.showBFSGif = this.isBFSRunning; // Toggle the visibility
console.log('BFS Started: ', this.showBFSGif); // Debugging
}

startDFS() {
this.showDFSGif = !this.showDFSGif; // Toggle the visibility
this.isDFSRunning = !this.isDFSRunning; // Toggle the DFS state on/off
this.showDFSGif = this.isDFSRunning; // Toggle the visibility
console.log('DFS Started: ', this.showDFSGif); // Debugging
}

startDijkstra() {
this.showDijkstraGif = !this.showDijkstraGif; // Toggle the visibility
this.isDijkstraRunning = !this.isDijkstraRunning; // Toggle the Dijkstra state on/off
this.showDijkstraGif = this.isDijkstraRunning; // Toggle the visibility
console.log('Dijkstra Started: ', this.showDijkstraGif); // Debugging
}
}