diff --git a/components/Visualization/svgs/SSSPTableSvgReact.js b/components/Visualization/svgs/SSSPTableSvgReact.js new file mode 100644 index 0000000..d287319 --- /dev/null +++ b/components/Visualization/svgs/SSSPTableSvgReact.js @@ -0,0 +1,97 @@ +import React from "react" + +function reconstructFullPath(vertexName, vertices) { + const prevMap = Object.fromEntries(vertices.map(v => [v.name, v.path])); + const path = []; + let current = vertexName; + while (current != null) { + path.unshift(current); + current = prevMap[current]; + } + return path.join(" \u2192 "); +} + +export default function SSSPTableVisualization({problemData}) { + if(!problemData || !problemData.vertices) { + return null; + } + + return ( +
+ + + + + + + + + + + + {problemData.vertices.map(v => ( + + + + + + + + ))} + +
VertexKnownCostPathFull Path
+ {v.name} + {v.known ? "\u2705" : "\u274C"}{v.cost}{v.path ?? "-"}{reconstructFullPath(v.name, problemData.vertices)}
+
+ ); +} + +const thStyle = { + border: "1px solid #ccc", + padding: "8px 16px", + textAlign: "center", + fontWeight: "bold" +}; + +const tdStyle = { + border: "1px solid #ccc", + padding: "8px 16px", + textAlign: "center", + fontSize: "14px", + border: "1px solid #ccc" +} \ No newline at end of file diff --git a/components/Visualization/svgs/Visualizations.js b/components/Visualization/svgs/Visualizations.js index 53d3ed2..0c0244e 100644 --- a/components/Visualization/svgs/Visualizations.js +++ b/components/Visualization/svgs/Visualizations.js @@ -5,6 +5,7 @@ import QuantumCircuitVis from "../QuantumCircuitVis"; import LaTeXGraphSvgReact from "./LaTeXGraphSvgReact"; import StandardSetSvgReact from "./StandardSetSvgReact"; import PumpSchedulingSvgReact from "./PumpSchedulingSvgReact"; +import SSSPTableVisualization from "./SSSPTableSvgReact"; const Visualizations = new Map([ ["Boolean Satisfiability" , (solve, url, problemData, gadgetMap, gadgetsOn) => { @@ -82,6 +83,15 @@ const Visualizations = new Map([ /> ); }], + ["SSSP Table", (solve, url, problemData) => { + return ( + + ); + }] ]) export default Visualizations;