Skip to content

Commit

Permalink
Merge branch 'master' into twitter
Browse files Browse the repository at this point in the history
  • Loading branch information
SrijaVuppala295 authored Oct 29, 2024
2 parents dfab8d8 + 2f28319 commit cfae210
Show file tree
Hide file tree
Showing 19 changed files with 367 additions and 28 deletions.
219 changes: 219 additions & 0 deletions src/app/components/Graphs/acyclicgraph.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,219 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Acyclic Graph Visualization</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/7.0.0/d3.min.js"></script>
<style>
/* Professional and Neat Greyish Black and White Theme */
body {
font-family: 'Roboto', sans-serif;
background-color: #2b2b2b;
color: #e0e0e0;
margin: 0;
padding: 20px;
display: flex;
flex-direction: column;
align-items: center;
}

h1 {
color: #ffffff;
font-size: 26px;
margin-bottom: 10px;
}

.section {
max-width: 800px;
text-align: center;
margin-bottom: 25px;
font-size: 18px;
line-height: 1.7;
}

.section h2 {
color: #ffffff;
font-size: 22px;
margin-bottom: 8px;
}

#graphContainer {
width: 100%;
max-width: 800px;
height: 500px;
border-radius: 10px;
border: 2px solid #ccc;
background-color: #444;
box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.5);
position: relative;
margin-bottom: 30px;
}

.node {
fill: #ccc;
stroke: #fff;
stroke-width: 1.5px;
cursor: grab;
}

.link {
stroke: #999;
stroke-opacity: 0.8;
}

.node:hover {
fill: #ff7f50;
}

button {
padding: 10px 20px;
margin: 10px;
background-color: #5a5a5a;
color: #e0e0e0;
border: none;
cursor: pointer;
border-radius: 5px;
transition: background-color 0.3s ease;
}

button:hover {
background-color: #7a7a7a;
}

.highlight {
color: #00ffae;
font-weight: bold;
}
</style>
</head>

<body>
<h1>Acyclic Graph Visualization</h1>

<div class="section">
<p>
An <span class="highlight">Acyclic Graph</span> is a directed graph with no cycles. It represents a structure where each node points to other nodes, but no path leads back to the starting node.
</p>
</div>

<div class="section">
<h2>Key Properties of Acyclic Graphs</h2>
<ul>
<li><strong>Direction:</strong> Each edge has a direction, indicated by arrows from one node to another.</li>
<li><strong>Nodes:</strong> The circles represent entities in the graph.</li>
<li><strong>Edges:</strong> The arrows represent directed connections between nodes.</li>
<li><strong>No Cycles:</strong> Paths in an acyclic graph do not form cycles, meaning no node can loop back to itself.</li>
<li><strong>Path:</strong> A sequence of directed edges connecting nodes in a particular direction.</li>
</ul>
</div>

<div class="section">
<h2>Interactive Acyclic Graph</h2>
<p>Hover over nodes to see a highlighted effect. Click and drag nodes to reposition them!</p>
</div>

<!-- Container for the graph -->
<div id="graphContainer"></div>

<div class="section">
<button onclick="generateGraph()">Regenerate Graph</button>
</div>

<script>
const graphContainer = d3.select('#graphContainer');
const width = graphContainer.node().clientWidth;
const height = graphContainer.node().clientHeight;

function generateGraph() {
const nodes = [
{ id: "A" }, { id: "B" }, { id: "C" },
{ id: "D" }, { id: "E" }, { id: "F" }
];
const links = [
{ source: "A", target: "B" },
{ source: "A", target: "C" },
{ source: "B", target: "D" },
{ source: "C", target: "E" },
{ source: "D", target: "F" },
{ source: "E", target: "F" }
];

graphContainer.select("svg").remove();

const simulation = d3.forceSimulation(nodes)
.force("link", d3.forceLink(links).id(d => d.id).distance(120))
.force("charge", d3.forceManyBody().strength(-300))
.force("center", d3.forceCenter(width / 2, height / 2));

const svg = graphContainer.append("svg")
.attr("width", width)
.attr("height", height);

svg.append("defs").append("marker")
.attr("id", "arrow")
.attr("viewBox", [0, 0, 10, 10])
.attr("refX", 12)
.attr("refY", 5)
.attr("markerWidth", 6)
.attr("markerHeight", 6)
.attr("orient", "auto-start-reverse")
.append("path")
.attr("d", "M0,0 L10,5 L0,10 Z")
.attr("fill", "#999");

const link = svg.selectAll(".link")
.data(links)
.enter().append("line")
.attr("class", "link")
.attr("stroke-width", 2)
.attr("marker-end", "url(#arrow)");

const node = svg.selectAll(".node")
.data(nodes)
.enter().append("circle")
.attr("class", "node")
.attr("r", 8)
.call(d3.drag()
.on("start", dragstarted)
.on("drag", dragged)
.on("end", dragended));

simulation.nodes(nodes).on("tick", () => {
link
.attr("x1", d => d.source.x)
.attr("y1", d => d.source.y)
.attr("x2", d => d.target.x)
.attr("y2", d => d.target.y);

node
.attr("cx", d => d.x)
.attr("cy", d => d.y);
});

simulation.force("link").links(links);
}

function dragstarted(event, d) {
if (!event.active) simulation.alphaTarget(0.3).restart();
d.fx = d.x;
d.fy = d.y;
}

function dragged(event, d) {
d.fx = event.x;
d.fy = event.y;
}

function dragended(event, d) {
if (!event.active) simulation.alphaTarget(0);
d.fx = null;
d.fy = null;
}

generateGraph();
</script>
</body>

</html>
10 changes: 9 additions & 1 deletion src/app/components/bfs-page/bfs-page.component.css
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;700&display=swap');
.montserrat-unique {
font-family: "Montserrat", sans-serif;
font-weight: 500; /* Medium weight for specific elements */
font-style: normal; /* Normal font style */
}

body {
font-family: "Montserrat", sans-serif; /* Apply Montserrat to the body for all text */
font-weight: 400; /* Regular weight for body text */
display: flex;
flex-direction: column;
min-height: 100vh;
margin: 0;
background-color: #f5f5f5;
font-family: Arial, sans-serif;
color: #333;
}

Expand Down
7 changes: 5 additions & 2 deletions src/app/components/bfs-page/bfs-page.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Component, AfterViewInit, OnInit } from '@angular/core';
import { RouterModule } from '@angular/router';
import { FormsModule } from '@angular/forms';
import { AuthService } from '../../services/auth.service';
import { Title } from '@angular/platform-browser';
import { NavbarComponent } from '../navbar/navbar.component';

@Component({
Expand All @@ -24,9 +25,11 @@ export class BfsPageComponent implements AfterViewInit, OnInit {
isDropdownOpen: boolean = false;
private finalPath: number[] = []; // To store the final path taken

constructor(private authService: AuthService) {}
constructor(private authService: AuthService,private titleService: Title) {}

ngOnInit(): void {}
ngOnInit(): void {
this.titleService.setTitle('GraphExplorer Pro | BFS');
}

ngAfterViewInit(): void {
this.bfsCanvas = document.getElementById('bfs-canvas') as HTMLCanvasElement;
Expand Down
10 changes: 9 additions & 1 deletion src/app/components/dfs-page/dfs-page.component.css
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;700&display=swap');
.montserrat-unique {
font-family: "Montserrat", sans-serif;
font-weight: 500; /* Medium weight for specific elements */
font-style: normal; /* Normal font style */
}

body {
font-family: "Montserrat", sans-serif; /* Apply Montserrat to the body for all text */
font-weight: 400; /* Regular weight for body text */
display: flex;
flex-direction: column;
min-height: 100vh;
margin: 0;
background-color: #f5f5f5;
font-family: Arial, sans-serif;
color: #333;
}

Expand Down
14 changes: 12 additions & 2 deletions src/app/components/dfs-page/dfs-page.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { RouterModule } from '@angular/router';
import { FormsModule } from '@angular/forms';
import { AuthService } from '../../services/auth.service';
import { NavbarComponent } from '../navbar/navbar.component';
import { Title } from '@angular/platform-browser';

@Component({
selector: 'app-dfs-page',
Expand All @@ -12,6 +13,15 @@ import { NavbarComponent } from '../navbar/navbar.component';
styleUrls: ['./dfs-page.component.css'],
})
export class DfsPageComponent implements AfterViewInit, OnInit {

// constructor(private titleService: Title) { }

// ngOnInit(): void {

// this.titleService.setTitle('GraphExplorer | DFS');
// }


private nodes: { label: string; x: number; y: number }[] = [];
private edges: [number, number][] = [];

Expand All @@ -24,10 +34,10 @@ export class DfsPageComponent implements AfterViewInit, OnInit {
customEdgeInput: string = '';
isDropdownOpen: boolean = false;

constructor(private authService: AuthService) {}
constructor(private authService: AuthService,private titleService: Title) {}

ngOnInit(): void {
// No need to access the canvas here
this.titleService.setTitle('GraphExplorer Pro | DFS');
}

ngAfterViewInit(): void {
Expand Down
12 changes: 8 additions & 4 deletions src/app/components/faq/faq.component.css
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@



@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;700&display=swap');
.montserrat-unique {
font-family: "Montserrat", sans-serif;
font-weight: 500; /* Medium weight for specific elements */
font-style: normal; /* Normal font style */
}
body {
font-family: Arial, sans-serif;
/* max-width: 800px; */
font-family: "Montserrat", sans-serif; /* Apply Montserrat to the body for all text */
font-weight: 400; /* Regular weight for body text */
width: 100vw;
margin:auto 0;
display:flex;
Expand Down
16 changes: 15 additions & 1 deletion src/app/components/faq/faq.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { Component, AfterViewInit } from '@angular/core';
import { Component, AfterViewInit, OnInit } from '@angular/core';
import { NavbarComponent } from '../navbar/navbar.component';
import { Title } from '@angular/platform-browser';
import { AuthService } from '../../services/auth.service';

@Component({
selector: 'app-faq',
Expand All @@ -9,6 +11,14 @@ import { NavbarComponent } from '../navbar/navbar.component';
styleUrls: ['./faq.component.css']
})
export class FaqComponent implements AfterViewInit {

constructor(private authService: AuthService,private titleService: Title) {}

ngOnInit(): void {
this.titleService.setTitle('GraphExplorer Pro | FAQ');
}


ngAfterViewInit() {
// const faqItems = document.querySelectorAll<HTMLElement>('.faq-item');
// faqItems.forEach((item) => {
Expand All @@ -27,6 +37,10 @@ export class FaqComponent implements AfterViewInit {
// });
// }
// });




document.addEventListener('DOMContentLoaded', () => {
const togglers = document.querySelectorAll('[data-toggle]');

Expand Down
Loading

0 comments on commit cfae210

Please sign in to comment.