@@ -56,7 +56,7 @@ const MatrixVisualization = () => {
5656 } ;
5757
5858 const generateMatrix = ( ) => {
59- const n = 40
59+ const n = 30
6060 const newMatrix = Array . from ( { length : n } , ( ) => Array ( n ) . fill ( " " ) ) ; // generate array
6161 const objectivesArray = [ ] ; // array to hold bojectives
6262 const obstaclesArray = [ ] ; // array to hold obstacles
@@ -106,15 +106,17 @@ const MatrixVisualization = () => {
106106 const [ row , col ] = node ;
107107 const nodeElement = document . querySelector ( `.matrix-row-${ row } .col-index-${ col } ` ) ;
108108 if ( nodeElement ) {
109- nodeElement . classList . add ( 'path' ) ;
109+ if ( ! ( nodeElement . classList . contains ( 'objective' ) ) && ! ( nodeElement . classList . contains ( 'start' ) ) ) {
110+ nodeElement . classList . add ( 'path' ) ;
111+ }
110112 } } ) ;
111113
112114 if ( expanded ) {
113115 expanded . forEach ( node => {
114116 const [ row , col ] = node ;
115117 const nodeElement = document . querySelector ( `.matrix-row-${ row } .col-index-${ col } ` ) ;
116118 if ( nodeElement ) {
117- if ( ! ( nodeElement . classList . contains ( 'path' ) ) ) {
119+ if ( ! ( nodeElement . classList . contains ( 'path' ) ) && ! ( nodeElement . classList . contains ( 'objective' ) ) && ! ( nodeElement . classList . contains ( 'start' ) ) ) {
118120 nodeElement . classList . add ( 'expanded' ) ;
119121 }
120122 } } ) ;
@@ -171,14 +173,23 @@ const MatrixVisualization = () => {
171173 key = { colIndex }
172174 className = { `matrix-cell ${ start . row === rowIndex && start . col === colIndex ? 'start' : '' }
173175 ${ objectives . some ( obj => obj . row === rowIndex && obj . col === colIndex ) ? 'objective' : '' }
174- ${ obstacles . some ( obs => obs . row === rowIndex && obs . col === colIndex ) ? 'obstacle' : '' } col-index-${ colIndex } ` }
175- >
176+ ${ obstacles . some ( obs => obs . row === rowIndex && obs . col === colIndex ) ? 'obstacle' : '' } col-index-${ colIndex } ` } >
176177 { cell }
177178 </ div >
178179 ) ) }
179180 </ div >
180181 ) ) }
181182 </ div >
183+ < div className = 'legend' >
184+ < ul >
185+ < li className = 'start' > Start</ li >
186+ < li className = 'objective' > Objective</ li >
187+ < li className = 'path' > Path</ li >
188+ < li className = 'obstacle white-text' > Obstacle</ li >
189+ < li className = 'expanded' > Expanded Nodes</ li >
190+ < li className = 'weight' > Weighted (ignored for bfs and dfs)</ li >
191+ </ ul >
192+ </ div >
182193 < form onSubmit = { handleSubmit } >
183194 < label htmlFor = 'algorithm' className = 'label' >
184195 Algorithms:
@@ -192,7 +203,7 @@ const MatrixVisualization = () => {
192203 < option value = 'DFS' > DFS</ option >
193204 < option value = 'UCS' > UCS</ option >
194205 < option value = 'Astar' > Astar</ option >
195- < option value = 'IDS' > IDS</ option >
206+ { /* <option value='IDS'>IDS</option> */ }
196207 </ select >
197208 </ label >
198209 < input
@@ -203,6 +214,7 @@ const MatrixVisualization = () => {
203214 disabled = { button }
204215 />
205216 </ form >
217+
206218 </ div >
207219 ) ;
208220} ;
0 commit comments