@@ -77,7 +77,8 @@ const NeuroJsonGraph: React.FC<{
7777 // if (size > 3) return { color: Colors.primary.main, size: 7 };
7878 // return { color: Colors.primary.light, size: 5 };
7979 // };
80- // Custom random number generator (same as `mulberry32`)
80+
81+ // Custom random number generator
8182 const mulberry32 = ( a : number ) => {
8283 return function ( ) {
8384 let t = ( a += 0x6d2b79f5 ) ;
@@ -87,17 +88,7 @@ const NeuroJsonGraph: React.FC<{
8788 } ;
8889 } ;
8990
90- const rngfun = mulberry32 ( 0x123456789 ) ; // Seeded random function
91-
92- // // Shuffle nodes
93- // const nodenum = registry.length;
94- // const randnode = [...Array(nodenum).keys()];
95-
96- // Fisher-Yates Shuffle
97- // for (let i = 0; i < nodenum; i++) {
98- // const j = Math.floor(rngfun() * (i + 1));
99- // [randnode[i], randnode[j]] = [randnode[j], randnode[i]];
100- // }
91+ const rngfun = mulberry32 ( 0x123456789 ) ;
10192
10293 useEffect ( ( ) => {
10394 // Ensure registry and graphRef are properly initialized
@@ -115,7 +106,7 @@ const NeuroJsonGraph: React.FC<{
115106 ( db , index ) => {
116107 const colorStr = blendColors ( db . datatype ) ; // Get color in "rgb(R,G,B)" format
117108
118- // ** Extract RGB values from the string**
109+ // Extract RGB values from the string
119110 const match = colorStr . match ( / \d + / g) ; // Get numbers from "rgb(R,G,B)"
120111 if ( ! match ) return { brightness : 255 , index } ; // Default to white if extraction fails
121112
@@ -126,24 +117,18 @@ const NeuroJsonGraph: React.FC<{
126117 }
127118 ) ;
128119
129- // **2️⃣ Sort nodes by brightness (dark → bright)**
120+ // Sort nodes by brightness
130121 colorlist . sort ( ( a , b ) => a . brightness - b . brightness ) ;
131122
132- // // **3️⃣ Create shuffled node list using Fisher-Yates algorithm**
133- // const nodenum = registry.length;
134- // const randnode = colorlist.map((item) => item.index); // Get sorted indices
135-
136- // for (let i = 0; i < nodenum; i++) {
137- // const j = Math.floor(rngfun() * (i + 1));
138- // [randnode[i], randnode[j]] = [randnode[j], randnode[i]];
139- // }
140-
141123 // Prepare graph data
142124 const graphData = {
143125 nodes : registry . map ( ( db ) => {
144126 // const { color, size } = size2colorAndSize(db.datasets);
145127 const color = blendColors ( db . datatype ) ;
146- const size = db . datasets > 32 ? 10 : db . datasets > 3 ? 7 : 5 ;
128+ // const size = db.datasets > 32 ? 10 : db.datasets > 3 ? 7 : 5;
129+
130+ let size = db . datasets > 100 ? Math . log ( db . datasets ) : db . datasets / 5 ;
131+ size = Math . max ( size , 2 ) ;
147132
148133 return {
149134 id : db . id ,
@@ -160,61 +145,20 @@ const NeuroJsonGraph: React.FC<{
160145 } ) ,
161146
162147 links : registry . flatMap ( ( db , index ) => {
163- // const color = blendColors(db.datatype);
164- // return registry
165- // .filter(
166- // (otherDb) =>
167- // db.id !== otherDb.id &&
168- // db.datatype.some((type) => otherDb.datatype.includes(type))
169- // )
170- // .map((otherDB) => ({
171- // source: db.id,
172- // target: otherDB.id,
173- // color: Colors.lightGray,
174- // visible: true,
175- // }));
176-
177- // const connections = [];
178- // const nextIndex = (index + 1) % registry.length;
179- // // const { color } = size2colorAndSize(db.datasets);
180- // const color = blendColors(db.datatype);
181- // connections.push({
182- // source: db.id,
183- // target: registry[nextIndex].id,
184- // color: color,
185- // visible: true,
186- // });
187- // return connections;
188-
189- // use original website logic
190148 const coloridx = index ;
191149 const i = colorlist [ coloridx ] . index ; // Get shuffled node index
192150 const node = registry [ i ] ; // Get actual node
193151
194152 // Determine number of connections (proportional to dataset size)
195153 const conn = 1 + Math . round ( rngfun ( ) * Math . max ( 1 , node . datasets / 20 ) ) ;
196- // const numConnections = 4;
154+
197155 const connections : {
198156 source : string ;
199157 target : string ;
200158 color : string ;
201159 visible : boolean ;
202160 } [ ] = [ ] ;
203161
204- // for (let j = -conn; j <= conn; j++) {
205- // if (j === 0) continue; // Skip linking to itself
206- // if (coloridx + j >= nodenum) break; // Prevent out-of-bounds errors
207-
208- // const targetNode = registry[randnode[Math.max(0, coloridx + j)]]; // Pick a nearby node from shuffled list
209-
210- // connections.push({
211- // source: node.id,
212- // target: targetNode.id,
213- // color: blendColors(node.datatype), // Match node's color
214- // visible: true, // Make links visible
215- // });
216- // }
217-
218162 for ( let j = 1 ; j <= conn ; j ++ ) {
219163 if ( index + j >= registry . length ) break ; // Prevent out-of-bounds errors
220164
@@ -238,7 +182,7 @@ const NeuroJsonGraph: React.FC<{
238182 . graphData ( graphData )
239183 . nodeRelSize ( 2 )
240184 . nodeColor ( ( node ) => ( node as NodeObject ) . color )
241- . linkWidth ( 0.5 )
185+ . linkWidth ( 1 )
242186 . backgroundColor ( "rgba(0,0,0,0)" )
243187 . nodeLabel ( "name" )
244188 . onNodeHover ( ( node ) => {
0 commit comments