File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import ReactFlow, {
1010} from "reactflow" ;
1111import "reactflow/dist/style.css" ;
1212import { useGraphStore } from "../store/graphStore" ;
13+ import { TraversalPath } from "./TraversalPath" ;
1314
1415const nodeTypes = { } ;
1516
@@ -139,12 +140,24 @@ export const GraphVisualizer = () => {
139140 >
140141 < Background color = "#aaa" gap = { 16 } />
141142 < Controls />
142- < MiniMap
143- nodeColor = { ( node ) => getNodeColor ( node . id , traversalState ) }
144- nodeStrokeWidth = { 3 }
145- zoomable
146- pannable
147- />
143+ { traversalState . isComplete ? (
144+ < div style = { {
145+ position : 'absolute' ,
146+ bottom : 20 ,
147+ right : 20 ,
148+ zIndex : 1000 ,
149+ maxWidth : 300
150+ } } >
151+ < TraversalPath />
152+ </ div >
153+ ) : (
154+ < MiniMap
155+ nodeColor = { ( node ) => getNodeColor ( node . id , traversalState ) }
156+ nodeStrokeWidth = { 3 }
157+ zoomable
158+ pannable
159+ />
160+ ) }
148161 </ ReactFlow >
149162 </ div >
150163 </ Card >
Original file line number Diff line number Diff line change 1+ import React from 'react' ;
2+ import { Card , Typography } from 'antd' ;
3+ import { useGraphStore } from '../store/graphStore' ;
4+
5+ const { Text } = Typography ;
6+
7+ export const TraversalPath = ( ) => {
8+ const { traversalState, algorithm } = useGraphStore ( ) ;
9+ const { visitOrder, isComplete } = traversalState ;
10+
11+ if ( ! visitOrder || visitOrder . length === 0 ) {
12+ return null ;
13+ }
14+
15+ const pathString = visitOrder . join ( ' → ' ) ;
16+
17+ return (
18+ < Card
19+ title = { `${ algorithm } Traversal Path` }
20+ size = "small"
21+ style = { { marginTop : 16 } }
22+ >
23+ < div style = { { display : 'flex' , alignItems : 'center' , gap : 8 } } >
24+ < Text strong > Path: </ Text >
25+ < Text code style = { { fontSize : '14px' } } >
26+ { pathString }
27+ </ Text >
28+ { isComplete && (
29+ < Text type = "success" style = { { marginLeft : 8 } } >
30+ ✓ Complete
31+ </ Text >
32+ ) }
33+ </ div >
34+ < div style = { { marginTop : 8 } } >
35+ < Text type = "secondary" >
36+ Nodes visited: { visitOrder . length }
37+ </ Text >
38+ </ div >
39+ </ Card >
40+ ) ;
41+ } ;
You can’t perform that action at this time.
0 commit comments