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(
122122 }
123123}
124124
125+ const isValidLink = ( link , nodes ) => {
126+ if ( nodes [ link . source ] == null || nodes [ link . target ] == null ) {
127+ return false ;
128+ }
129+ return true ;
130+ } ;
125131export function buildGraphVisualizationObjectFromRecords (
126132 records : any [ ] , // Neo4jRecord[],
127133 nodes : Record < string , any > [ ] ,
@@ -162,6 +168,7 @@ export function buildGraphVisualizationObjectFromRecords(
162168 ) ;
163169 } ) ;
164170 } ) ;
171+
165172 // Assign proper curvatures and colors to relationships.
166173 // Assigning curvature is needed for pairs of nodes that have multiple relationships between them, or self-loops.
167174 const linksList = Object . values ( links ) . map ( ( linkArray ) => {
@@ -176,6 +183,12 @@ export function buildGraphVisualizationObjectFromRecords(
176183 } ) ;
177184 } ) ;
178185
186+ linksList . forEach ( ( link , idx , object ) => {
187+ if ( ! isValidLink ( link [ 0 ] , nodes ) ) {
188+ object . splice ( idx , 1 ) ;
189+ }
190+ } ) ;
191+
179192 // Assign proper colors to nodes.
180193 const totalColors = colorScheme ? colorScheme . length : 0 ;
181194 const nodeLabelsList = fields . map ( ( e ) => e [ 0 ] ) ;
You can’t perform that action at this time.
0 commit comments