Skip to content
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
26 changes: 11 additions & 15 deletions Tools/Constants.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
const Constants = {

ProblemTypes: {
Sat3: "SAT3",
Clique: "CLIQUE",
GraphColoring: "GRAPHCOLORING",
VertexCover: "VERTEXCOVER",
Arcset: "ARCSET",
Knapsack: "KNAPSACK"
}



}

export default Constants
ProblemTypes: {
Sat3: "SAT3",
Clique: "CLIQUE",
GraphColoring: "GRAPHCOLORING",
VertexCover: "VERTEXCOVER",
Arcset: "ARCSET",
Knapsack: "KNAPSACK",
},
};

export default Constants;
126 changes: 70 additions & 56 deletions Tools/ProblemInstanceParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,69 +3,83 @@
import Constants from "./Constants";

class ProblemInstanceParser {
constructor() {

}

//Breaks parsing logic up by problem type, calls function based on type.
parse(problemType, problemInstance) {
let parsedOutput = {}
constructor() {}

if (problemType === Constants.ProblemTypes.Clique || problemType === Constants.ProblemTypes.VertexCover || problemType === Constants.ProblemTypes.GraphColoring) {
parsedOutput = this.parseUndirectedGraph(problemInstance);
}
else if (problemType === Constants.ProblemTypes.Sat3) {
parsedOutput = this.parseSat3(problemInstance);
}

else if (problemType === Constants.ProblemTypes.Arcset) {
parsedOutput = this.parseDirectedGraph(problemInstance);
}
else {
parsedOutput = {
test: true,
input: problemInstance,
regex: "There is no regex string for this problem, parsing is likely not enabled",
type: problemType,
exampleStr: "There is no example string for this problem, click on the problem info box for more problem information"

}
}
//Breaks parsing logic up by problem type, calls function based on type.
parse(problemType, problemInstance) {
let parsedOutput = {};

return parsedOutput
if (
problemType === Constants.ProblemTypes.Clique ||
problemType === Constants.ProblemTypes.VertexCover ||
problemType === Constants.ProblemTypes.GraphColoring
) {
parsedOutput = this.parseUndirectedGraph(problemInstance);
} else if (problemType === Constants.ProblemTypes.Sat3) {
parsedOutput = this.parseSat3(problemInstance);
} else if (problemType === Constants.ProblemTypes.Arcset) {
parsedOutput = this.parseDirectedGraph(problemInstance);
} else {
parsedOutput = {
test: true,
input: problemInstance,
regex: "There is no regex string for this problem, parsing is likely not enabled",
type: problemType,
exampleStr:
"There is no example string for this problem, click on the problem info box for more problem information",
};
}


parseSat3(instance) {
return parsedOutput;
}

parseSat3(instance) {
const type = "Sat3BooleanExp";
// const sat3Format = /^(\((!)*\w+\|(!)*\w+\|(!)*\w+\))((&)(\((!)*\w+\|(!)*\w+\|(!)*\w+\)))*$/g
const sat3Format =
/^(\((!)*[^\W_]+\|(!)*[^\W_]+\|(!)*[^\W_]+\))((&)(\((!)*[^\W_]+\|(!)*[^\W_]+\|(!)*[^\W_]+\)))*$/g;

const type = "Sat3BooleanExp"
// const sat3Format = /^(\((!)*\w+\|(!)*\w+\|(!)*\w+\))((&)(\((!)*\w+\|(!)*\w+\|(!)*\w+\)))*$/g
const sat3Format = /^(\((!)*[^\W_]+\|(!)*[^\W_]+\|(!)*[^\W_]+\))((&)(\((!)*[^\W_]+\|(!)*[^\W_]+\|(!)*[^\W_]+\)))*$/g
//[^\W_]
const satRegex = new RegExp(sat3Format);
const bool = satRegex.test(instance);
return {
test: bool,
input: instance,
regex: sat3Format,
type: type,
exampleStr: "(x1|!x2|x3)&(!x1|x3|x1)&(x2|!x3|x1)",
};
}

//[^\W_]
const satRegex = new RegExp(sat3Format)
const bool = satRegex.test(instance);
return {test:bool,input:instance,regex:sat3Format,type:type,exampleStr:"(x1|!x2|x3)&(!x1|x3|x1)&(x2|!x3|x1)"}
}
parseUndirectedGraph(instance) {
const type = "UndirectedGraph"
const undirectedGraphFormat = /\(\({([\w!]+)(,([\w!]+))*},{\{([\w!]+),([\w!]+)\}(,\{([\w!]+),([\w!]+)\})*}\),\d+\)$/g; //checks for undirected graph format, implicitly regex
const graphReg = new RegExp(undirectedGraphFormat);
const bool = graphReg.test(instance)
return {test:bool,input:instance,regex:undirectedGraphFormat,type:type,exampleStr:"(({a,b,c},{{a,b},{b,c}}),2)"}
}
parseUndirectedGraph(instance) {
const type = "UndirectedGraph";
const undirectedGraphFormat =
/\(\({([\w!]+)(,([\w!]+))*},{\{([\w!]+),([\w!]+)\}(,\{([\w!]+),([\w!]+)\})*}\),\d+\)$/g; //checks for undirected graph format, implicitly regex
const graphReg = new RegExp(undirectedGraphFormat);
const bool = graphReg.test(instance);
return {
test: bool,
input: instance,
regex: undirectedGraphFormat,
type: type,
exampleStr: "(({a,b,c},{{a,b},{b,c}}),2)",
};
}

parseDirectedGraph(instance) {
const type = "DirectedGraph"
const directedGraphFormat = /\(\({(([\w!]+)+(,([\w!]+))*)},{(\(([\w!]+),([\w!]+)\)(,\(([\w!]+),([\w!]+)\))*)*}\),\d+\)$/g
const graphReg = new RegExp(directedGraphFormat);
const bool = graphReg.test(instance);
return {test:bool,input:instance,regex:directedGraphFormat,type:type,exampleStr:"(({a,b,c},{(a,b),(b,c),(c,a)}),3)"}
}

parseDirectedGraph(instance) {
const type = "DirectedGraph";
const directedGraphFormat =
/\(\({(([\w!]+)(,([\w!]+))*)},{(\(([\w!]+),([\w!]+)\)(,\(([\w!]+),([\w!]+)\))*)*}\),\d+\)$/g;
const graphReg = new RegExp(directedGraphFormat);
const bool = graphReg.test(instance);
return {
test: bool,
input: instance,
regex: directedGraphFormat,
type: type,
exampleStr: "(({a,b,c},{(a,b),(b,c),(c,a)}),3)",
};
}
}

export default ProblemInstanceParser
export default ProblemInstanceParser;
11 changes: 2 additions & 9 deletions biome.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
{
"$schema": "https://biomejs.dev/schemas/2.5.3/schema.json",
"$schema": "https://biomejs.dev/schemas/2.5.8/schema.json",
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true
},
"files": {
"ignoreUnknown": false,
"includes": [
"**",
"!public/**",
"!package-lock.json",
"!.next/**",
"!out/**",
"!build/**"
]
"includes": ["**", "!public/**", "!package-lock.json", "!.next/**", "!out/**", "!build/**"]
},
"formatter": {
"enabled": true,
Expand Down
20 changes: 11 additions & 9 deletions components/ContributorCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@ import React from "react";

export default function ContributorCard({ name, role, contributions, github, image }) {
return (
<div style={{
background: "#111827",
border: "1px solid #7c3aed",
borderRadius: "12px",
padding: "16px",
color: "#e5e7eb",
maxWidth: "320px"
}}>
<div
style={{
background: "#111827",
border: "1px solid #7c3aed",
borderRadius: "12px",
padding: "16px",
color: "#e5e7eb",
maxWidth: "320px",
}}
>
<div style={{ display: "flex", alignItems: "center", gap: "12px" }}>
<img
src={image}
Expand All @@ -18,7 +20,7 @@ export default function ContributorCard({ name, role, contributions, github, ima
width: "48px",
height: "48px",
borderRadius: "50%",
border: "2px solid #7c3aed"
border: "2px solid #7c3aed",
}}
/>
<div>
Expand Down
23 changes: 11 additions & 12 deletions components/Quantum/QuantumCircuitVisualizer.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// components/Quantum/QuantumCircuitVisualizer.jsx
import React, { useEffect, useRef, useState } from "react";

import * as d3 from "d3";
import React, { useEffect, useRef, useState } from "react";
import { getMaxTime } from "./circuitUtils";

export default function QuantumCircuitVisualizer({ circuit }) {
Expand Down Expand Up @@ -68,7 +69,7 @@ export default function QuantumCircuitVisualizer({ circuit }) {
(g) =>
g.qubit !== prev.qubits - 1 &&
g.control !== prev.qubits - 1 &&
g.target !== prev.qubits - 1
g.target !== prev.qubits - 1,
),
};
});
Expand Down Expand Up @@ -128,7 +129,11 @@ export default function QuantumCircuitVisualizer({ circuit }) {
[...Array(c.qubits).keys()].forEach((q) => {
const y = 60 + q * spacingY;

svg.append("text").attr("x", 20).attr("y", y + 5).text(`q${q}`);
svg
.append("text")
.attr("x", 20)
.attr("y", y + 5)
.text(`q${q}`);

svg
.append("line")
Expand Down Expand Up @@ -210,9 +215,7 @@ export default function QuantumCircuitVisualizer({ circuit }) {
<div style={{ width: "100%", padding: "20px" }}>
<h2>Quantum Circuit Visualizer</h2>

<button onClick={() => document.getElementById("qc-import").click()}>
Import JSON
</button>
<button onClick={() => document.getElementById("qc-import").click()}>Import JSON</button>
<input
id="qc-import"
type="file"
Expand Down Expand Up @@ -245,11 +248,7 @@ export default function QuantumCircuitVisualizer({ circuit }) {

<label>
Time:{" "}
<input
type="number"
value={gateTime}
onChange={(e) => setGateTime(e.target.value)}
/>
<input type="number" value={gateTime} onChange={(e) => setGateTime(e.target.value)} />
</label>

{gateType !== "cnot" ? (
Expand Down Expand Up @@ -288,4 +287,4 @@ export default function QuantumCircuitVisualizer({ circuit }) {
</div>
</div>
);
}
}
2 changes: 1 addition & 1 deletion components/Quantum/circuitUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
export function getMaxTime(circuit) {
if (!circuit?.gates || circuit.gates.length === 0) return 0;
return Math.max(...circuit.gates.map((g) => g.t));
}
}
11 changes: 3 additions & 8 deletions components/Visualization/Graphvisualization.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
/**
* GraphVisualization.js
*
*
* This component generates an example Graph component using the Graphviz library.
*
*
* @author Daniel Igbokwe
*/



import dynamic from "next/dynamic";

const Graphviz = dynamic(() => import("./GraphvizWrapper"), { ssr: false });

function Page(props) {
return (
<Graphviz dot={props.dot} options={props.options} />

);
return <Graphviz dot={props.dot} options={props.options} />;
}

export default Page;
2 changes: 1 addition & 1 deletion components/Visualization/GraphvizWrapper.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useEffect, useRef } from "react";
import { graphviz } from "d3-graphviz";
import { useEffect, useRef } from "react";

export default function GraphvizWrapper({ dot, options = {} }) {
const ref = useRef(null);
Expand Down
Loading
Loading