File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -122,6 +122,12 @@ function extractGraphEntitiesFromField(
122
122
}
123
123
}
124
124
125
+ const isValidLink = ( link , nodes ) => {
126
+ if ( nodes [ link . source ] == null || nodes [ link . target ] == null ) {
127
+ return false ;
128
+ }
129
+ return true ;
130
+ } ;
125
131
export function buildGraphVisualizationObjectFromRecords (
126
132
records : any [ ] , // Neo4jRecord[],
127
133
nodes : Record < string , any > [ ] ,
@@ -162,6 +168,7 @@ export function buildGraphVisualizationObjectFromRecords(
162
168
) ;
163
169
} ) ;
164
170
} ) ;
171
+
165
172
// Assign proper curvatures and colors to relationships.
166
173
// Assigning curvature is needed for pairs of nodes that have multiple relationships between them, or self-loops.
167
174
const linksList = Object . values ( links ) . map ( ( linkArray ) => {
@@ -176,6 +183,12 @@ export function buildGraphVisualizationObjectFromRecords(
176
183
} ) ;
177
184
} ) ;
178
185
186
+ linksList . forEach ( ( link , idx , object ) => {
187
+ if ( ! isValidLink ( link [ 0 ] , nodes ) ) {
188
+ object . splice ( idx , 1 ) ;
189
+ }
190
+ } ) ;
191
+
179
192
// Assign proper colors to nodes.
180
193
const totalColors = colorScheme ? colorScheme . length : 0 ;
181
194
const nodeLabelsList = fields . map ( ( e ) => e [ 0 ] ) ;
You can’t perform that action at this time.
0 commit comments