@@ -172,7 +172,7 @@ export class DependencyGraph {
172172 }
173173
174174 public processCellDependencies ( cellDependencies : CellDependency [ ] , endVertex : Vertex ) {
175- const endVertexId = this . graph . getNodeId ( endVertex )
175+ const endVertexId = endVertex . idInGraph
176176
177177 if ( endVertexId === undefined ) {
178178 throw new Error ( 'End vertex not found' )
@@ -188,8 +188,8 @@ export class DependencyGraph {
188188 this . rangeMapping . addOrUpdateVertex ( rangeVertex )
189189 }
190190
191- this . graph . addNodeAndReturnId ( rangeVertex )
192- const rangeVertexId = this . graph . getNodeId ( rangeVertex )
191+ this . graph . addNodeIfNotExists ( rangeVertex )
192+ const rangeVertexId = rangeVertex . idInGraph
193193
194194 if ( rangeVertexId === undefined ) {
195195 throw new Error ( 'Range vertex not found' )
@@ -257,7 +257,7 @@ export class DependencyGraph {
257257 }
258258
259259 const newVertex = new EmptyCellVertex ( )
260- const newVertexId = this . graph . addNodeAndReturnId ( newVertex )
260+ const newVertexId = this . graph . addNodeIfNotExists ( newVertex )
261261 this . addressMapping . setCell ( address , newVertex )
262262
263263 return { vertex : newVertex , id : newVertexId }
@@ -567,12 +567,12 @@ export class DependencyGraph {
567567 }
568568
569569 public addVertex ( address : SimpleCellAddress , vertex : CellVertex ) : void {
570- this . graph . addNodeAndReturnId ( vertex )
570+ this . graph . addNodeIfNotExists ( vertex )
571571 this . addressMapping . setCell ( address , vertex )
572572 }
573573
574574 public addArrayVertex ( address : SimpleCellAddress , vertex : ArrayFormulaVertex ) : void {
575- this . graph . addNodeAndReturnId ( vertex )
575+ this . graph . addNodeIfNotExists ( vertex )
576576 this . setAddressMappingForArrayVertex ( vertex , address )
577577 }
578578
@@ -861,7 +861,7 @@ export class DependencyGraph {
861861 }
862862
863863 private exchangeGraphNode ( oldNode : Vertex , newNode : Vertex ) {
864- this . graph . addNodeAndReturnId ( newNode )
864+ this . graph . addNodeIfNotExists ( newNode )
865865 const adjNodesStored = this . graph . adjacentNodes ( oldNode )
866866 this . removeVertex ( oldNode )
867867 adjNodesStored . forEach ( ( adjacentNode ) => {
@@ -876,30 +876,30 @@ export class DependencyGraph {
876876 }
877877
878878 private correctInfiniteRangesDependency ( address : SimpleCellAddress ) {
879- const relevantInfiniteRanges = ( this . graph . getInfiniteRanges ( ) )
880- . filter ( ( { node } ) => ( node as RangeVertex ) . range . addressInRange ( address ) )
879+ const relevantInfiniteRanges = this . graph . getInfiniteRanges ( )
880+ . filter ( node => ( node as RangeVertex ) . range . addressInRange ( address ) )
881881
882882 if ( relevantInfiniteRanges . length <= 0 ) {
883883 return
884884 }
885885
886886 const { vertex, id : maybeVertexId } = this . fetchCellOrCreateEmpty ( address )
887- const vertexId = maybeVertexId ?? this . graph . getNodeId ( vertex )
887+ const vertexId = maybeVertexId ?? vertex . idInGraph
888888
889889 if ( vertexId === undefined ) {
890890 throw new Error ( 'Vertex not found' )
891891 }
892892
893- relevantInfiniteRanges . forEach ( ( { id } ) => {
894- this . graph . addEdge ( vertexId , id )
893+ relevantInfiniteRanges . forEach ( ( node ) => {
894+ this . graph . addEdge ( vertexId , node )
895895 } )
896896 }
897897
898898 private exchangeOrAddGraphNode ( oldNode : Maybe < Vertex > , newNode : Vertex ) {
899899 if ( oldNode ) {
900900 this . exchangeGraphNode ( oldNode , newNode )
901901 } else {
902- this . graph . addNodeAndReturnId ( newNode )
902+ this . graph . addNodeIfNotExists ( newNode )
903903 }
904904 }
905905
@@ -946,7 +946,7 @@ export class DependencyGraph {
946946
947947 private correctInfiniteRangesDependenciesByRangeVertex ( vertex : RangeVertex ) {
948948 this . graph . getInfiniteRanges ( )
949- . forEach ( ( { id : infiniteRangeVertexId , node : infiniteRangeVertex } ) => {
949+ . forEach ( ( infiniteRangeVertex ) => {
950950 const intersection = vertex . range . intersectionWith ( ( infiniteRangeVertex as RangeVertex ) . range )
951951
952952 if ( intersection === undefined ) {
@@ -955,7 +955,7 @@ export class DependencyGraph {
955955
956956 intersection . addresses ( this ) . forEach ( ( address : SimpleCellAddress ) => {
957957 const { vertex, id } = this . fetchCellOrCreateEmpty ( address )
958- this . graph . addEdge ( id ?? vertex , infiniteRangeVertexId )
958+ this . graph . addEdge ( id ?? vertex , infiniteRangeVertex )
959959 } )
960960 } )
961961 }
@@ -1069,7 +1069,7 @@ export class DependencyGraph {
10691069 while ( find . smallerRangeVertex === undefined ) {
10701070 const newRangeVertex = new RangeVertex ( AbsoluteCellRange . spanFrom ( currentRangeVertex . range . start , currentRangeVertex . range . width ( ) , currentRangeVertex . range . height ( ) - 1 ) )
10711071 this . rangeMapping . addOrUpdateVertex ( newRangeVertex )
1072- this . graph . addNodeAndReturnId ( newRangeVertex )
1072+ this . graph . addNodeIfNotExists ( newRangeVertex )
10731073 const restRange = new AbsoluteCellRange ( simpleCellAddress ( currentRangeVertex . range . start . sheet , currentRangeVertex . range . start . col , currentRangeVertex . range . end . row ) , currentRangeVertex . range . end )
10741074 this . addAllFromRange ( restRange , currentRangeVertex )
10751075 this . graph . addEdge ( newRangeVertex , currentRangeVertex )
0 commit comments