@@ -9,31 +9,40 @@ export const GraphVisualizer = () => {
99
1010 const styledNodes = useMemo ( ( ) => {
1111 return nodes . map ( node => {
12- let backgroundColor = '#f0f0f0' ;
13- let color = 'black ' ;
12+ let background , borderColor , boxShadow ;
13+ let color = 'white ' ;
1414
1515 if ( traversalState . visited . has ( node . id ) ) {
16- backgroundColor = '#52c41a' ; // Green for visited
17- color = 'white' ;
16+ background = 'linear-gradient(135deg, #52c41a, #389e0d)' ;
17+ borderColor = '#389e0d' ;
18+ boxShadow = '0 4px 12px rgba(82, 196, 26, 0.4)' ;
1819 } else if ( traversalState . current === node . id ) {
19- backgroundColor = '#1890ff' ; // Blue for current
20- color = 'white' ;
20+ background = 'linear-gradient(135deg, #1890ff, #096dd9)' ;
21+ borderColor = '#096dd9' ;
22+ boxShadow = '0 4px 12px rgba(24, 144, 255, 0.4)' ;
23+ } else {
24+ background = 'linear-gradient(135deg, #ffffff, #f0f0f0)' ;
25+ borderColor = '#d9d9d9' ;
26+ boxShadow = '0 2px 8px rgba(0, 0, 0, 0.1)' ;
27+ color = '#333' ;
2128 }
2229
2330 return {
2431 ...node ,
2532 style : {
26- backgroundColor ,
33+ background ,
2734 color,
28- border : '2px solid #d9d9d9' ,
35+ border : `3px solid ${ borderColor } ` ,
2936 borderRadius : '50%' ,
30- width : 40 ,
31- height : 40 ,
37+ width : 35 ,
38+ height : 35 ,
3239 display : 'flex' ,
3340 alignItems : 'center' ,
3441 justifyContent : 'center' ,
3542 fontSize : '12px' ,
36- fontWeight : 'bold'
43+ fontWeight : '600' ,
44+ boxShadow,
45+ transition : 'all 0.3s ease'
3746 }
3847 } ;
3948 } ) ;
@@ -42,26 +51,63 @@ export const GraphVisualizer = () => {
4251 const styledEdges = useMemo ( ( ) => {
4352 return edges . map ( edge => ( {
4453 ...edge ,
54+ type : 'straight' ,
4555 style : {
46- stroke : traversalState . currentEdge === edge . id ? '#ff4d4f' : '#d9d9d9' ,
47- strokeWidth : traversalState . currentEdge === edge . id ? 3 : 2
56+ stroke : traversalState . currentEdge === edge . id ? '#ff4d4f' : '#8c8c8c' ,
57+ strokeWidth : traversalState . currentEdge === edge . id ? 4 : 2 ,
58+ strokeDasharray : traversalState . currentEdge === edge . id ? '0' : '0' ,
59+ filter : traversalState . currentEdge === edge . id ? 'drop-shadow(0 2px 4px rgba(255, 77, 79, 0.3))' : 'none'
60+ } ,
61+ labelStyle : {
62+ fontSize : '11px' ,
63+ fontWeight : '600' ,
64+ fill : '#666' ,
65+ backgroundColor : 'rgba(255, 255, 255, 0.9)' ,
66+ padding : '2px 6px' ,
67+ borderRadius : '4px'
4868 }
4969 } ) ) ;
5070 } , [ edges , traversalState . currentEdge ] ) ;
5171
5272 if ( nodes . length === 0 ) {
5373 return (
54- < Card title = "Graph Visualization" >
55- < div style = { { height : 400 , display : 'flex' , alignItems : 'center' , justifyContent : 'center' } } >
74+ < Card
75+ title = "Graph Visualization"
76+ style = { {
77+ borderRadius : '12px' ,
78+ boxShadow : '0 4px 16px rgba(0, 0, 0, 0.1)'
79+ } }
80+ >
81+ < div style = { {
82+ height : 400 ,
83+ display : 'flex' ,
84+ alignItems : 'center' ,
85+ justifyContent : 'center' ,
86+ background : 'linear-gradient(135deg, #f5f7fa, #c3cfe2)' ,
87+ borderRadius : '8px' ,
88+ color : '#666' ,
89+ fontSize : '16px'
90+ } } >
5691 Please input a graph to visualize
5792 </ div >
5893 </ Card >
5994 ) ;
6095 }
6196
6297 return (
63- < Card title = "Graph Visualization" >
64- < div style = { { height : 400 } } >
98+ < Card
99+ title = "Graph Visualization"
100+ style = { {
101+ borderRadius : '12px' ,
102+ boxShadow : '0 4px 16px rgba(0, 0, 0, 0.1)'
103+ } }
104+ >
105+ < div style = { {
106+ height : 400 ,
107+ borderRadius : '8px' ,
108+ overflow : 'hidden' ,
109+ background : 'linear-gradient(135deg, #667eea 0%, #764ba2 100%)'
110+ } } >
65111 < ReactFlow
66112 nodes = { styledNodes }
67113 edges = { styledEdges }
@@ -70,8 +116,19 @@ export const GraphVisualizer = () => {
70116 nodesConnectable = { false }
71117 elementsSelectable = { false }
72118 >
73- < Background />
74- < Controls />
119+ < Background
120+ color = "rgba(255, 255, 255, 0.2)"
121+ gap = { 20 }
122+ size = { 1 }
123+ />
124+ < Controls
125+ style = { {
126+ background : 'rgba(255, 255, 255, 0.9)' ,
127+ borderRadius : '8px' ,
128+ border : 'none' ,
129+ boxShadow : '0 2px 8px rgba(0, 0, 0, 0.1)'
130+ } }
131+ />
75132 </ ReactFlow >
76133 </ div >
77134 </ Card >
0 commit comments