@@ -257,7 +257,7 @@ export class D3DagLayout extends GraphLayout<D3DagLayoutOptions> {
257257
258258 const points = this . _edgePoints . get ( edge . getId ( ) ) || [ sourcePosition , targetPosition ] ;
259259 const controlPoints = this . _edgeControlPoints . get ( edge . getId ( ) ) || [ ] ;
260- const edgeType = controlPoints . length ? EDGE_TYPE . SPLINE_CURVE : EDGE_TYPE . LINE ;
260+ const edgeType = controlPoints . length ? 'spline' : 'line' ;
261261
262262 return {
263263 type : edgeType ,
@@ -305,7 +305,7 @@ export class D3DagLayout extends GraphLayout<D3DagLayoutOptions> {
305305 const builder = this . _options . dagBuilder ?? D3DagLayout . defaultOptions . dagBuilder ;
306306
307307 if ( typeof builder === 'function' ) {
308- const dag = builder ( this . _graph ! ) ;
308+ const dag = builder ( this . _graph ) ;
309309 this . _ensureEdgeData ( dag ) ;
310310 return dag ;
311311 }
@@ -325,12 +325,12 @@ export class D3DagLayout extends GraphLayout<D3DagLayoutOptions> {
325325 const dag = createDagGraph < Node , Edge > ( ) ;
326326 const dagNodeLookup = new Map < string | number , MutGraphNode < Node , Edge > > ( ) ;
327327
328- for ( const node of this . _graph ! . getNodes ( ) ) {
328+ for ( const node of this . _graph . getNodes ( ) ) {
329329 const dagNode = dag . node ( node ) ;
330330 dagNodeLookup . set ( node . getId ( ) , dagNode ) ;
331331 }
332332
333- for ( const edge of this . _graph ! . getEdges ( ) ) {
333+ for ( const edge of this . _graph . getEdges ( ) ) {
334334 if ( ! edge . isDirected ( ) ) {
335335 continue ;
336336 }
@@ -346,20 +346,13 @@ export class D3DagLayout extends GraphLayout<D3DagLayoutOptions> {
346346 }
347347
348348 private _buildDagWithConnect ( ) : MutGraph < Node , Edge > {
349- const connect = graphConnect <
350- Node ,
351- {
352- source : string ;
353- target : string ;
354- edge : Edge ;
355- }
356- > ( )
349+ const connect = graphConnect ( )
357350 . sourceId ( ( link ) => link . source )
358351 . targetId ( ( link ) => link . target )
359352 . nodeDatum ( ( id ) => this . _nodeLookup . get ( this . _fromDagId ( id ) ) ?? new Node ( { id} ) )
360353 . single ( true ) ;
361354
362- const data = this . _graph !
355+ const data = this . _graph
363356 . getEdges ( )
364357 . filter ( ( edge ) => edge . isDirected ( ) )
365358 . map ( ( edge ) => ( {
@@ -374,11 +367,11 @@ export class D3DagLayout extends GraphLayout<D3DagLayoutOptions> {
374367 for ( const dagNode of dag . nodes ( ) ) {
375368 const datum = dagNode . data ;
376369 if ( datum ) {
377- seenIds . add ( ( datum as Node ) . getId ( ) ) ;
370+ seenIds . add ( ( datum ) . getId ( ) ) ;
378371 }
379372 }
380373
381- for ( const node of this . _graph ! . getNodes ( ) ) {
374+ for ( const node of this . _graph . getNodes ( ) ) {
382375 if ( ! seenIds . has ( node . getId ( ) ) ) {
383376 dag . node ( node ) ;
384377 }
@@ -398,7 +391,7 @@ export class D3DagLayout extends GraphLayout<D3DagLayoutOptions> {
398391 private _buildDagWithStratify ( ) : MutGraph < Node , Edge > {
399392 const stratify = graphStratify ( ) ;
400393
401- const nodeData = this . _graph ! . getNodes ( ) . map ( ( node ) => {
394+ const nodeData = this . _graph . getNodes ( ) . map ( ( node ) => {
402395 const id = this . _toDagId ( node . getId ( ) ) ;
403396 const parentIds = ( this . _incomingParentMap . get ( node . getId ( ) ) ?? [ ] )
404397 . filter ( ( parentId ) => this . _nodeLookup . has ( parentId ) )
@@ -427,8 +420,8 @@ export class D3DagLayout extends GraphLayout<D3DagLayoutOptions> {
427420 if ( link . data instanceof Edge ) {
428421 continue ;
429422 }
430- const sourceNode = link . source . data as Node ;
431- const targetNode = link . target . data as Node ;
423+ const sourceNode = link . source . data ;
424+ const targetNode = link . target . data ;
432425 const key = this . _edgeKey ( sourceNode . getId ( ) , targetNode . getId ( ) ) ;
433426 const edge = this . _edgeLookup . get ( key ) ;
434427 if ( edge ) {
@@ -512,7 +505,7 @@ export class D3DagLayout extends GraphLayout<D3DagLayoutOptions> {
512505 let maxY = Number . NEGATIVE_INFINITY ;
513506
514507 for ( const dagNode of this . _dag . nodes ( ) ) {
515- const node = dagNode . data as Node ;
508+ const node = dagNode . data ;
516509 const id = node . getId ( ) ;
517510 const x = dagNode . x ?? 0 ;
518511 const y = dagNode . y ?? 0 ;
@@ -543,13 +536,13 @@ export class D3DagLayout extends GraphLayout<D3DagLayoutOptions> {
543536 } ;
544537
545538 for ( const link of this . _dag . links ( ) ) {
546- const source = link . source . data as Node ;
547- const target = link . target . data as Node ;
539+ const source = link . source . data ;
540+ const target = link . target . data ;
548541 const edge = link . data instanceof Edge ? link . data : this . _edgeLookup . get ( this . _edgeKey ( source . getId ( ) , target . getId ( ) ) ) ;
549542 if ( ! edge ) {
550543 continue ;
551544 }
552- const points = ( link . points && link . points . length ? link . points : [ [ link . source . x ?? 0 , link . source . y ?? 0 ] , [ link . target . x ?? 0 , link . target . y ?? 0 ] ] ) as [ number , number ] [ ] ;
545+ const points = ( link . points && link . points . length ? link . points : [ [ link . source . x ?? 0 , link . source . y ?? 0 ] , [ link . target . x ?? 0 , link . target . y ?? 0 ] ] ) ;
553546 this . _rawEdgePoints . set ( edge . getId ( ) , points . map ( ( point ) => [ ...point ] as [ number , number ] ) ) ;
554547 }
555548
0 commit comments