File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -137,15 +137,7 @@ function Graph(serialized) {
137137 }
138138 // Returns true if there is an edge from node u to node v.
139139 function hasEdge ( u , v ) {
140- var has = false ;
141- if ( edges [ u ] ) {
142- adjacent ( u ) . forEach ( function ( _v ) {
143- if ( _v === v ) {
144- has = true ;
145- }
146- } ) ;
147- }
148- return has ;
140+ return adjacent ( u ) . includes ( v ) ;
149141 }
150142 // Computes the indegree for the given node.
151143 // Not very efficient, costs O(E) where E = number of edges.
Original file line number Diff line number Diff line change @@ -146,15 +146,7 @@ function Graph(serialized?: Serialized) {
146146
147147 // Returns true if there is an edge from node u to node v.
148148 function hasEdge ( u : NodeId , v : NodeId ) {
149- let has = false ;
150- if ( edges [ u ] ) {
151- adjacent ( u ) . forEach ( function ( _v ) {
152- if ( _v === v ) {
153- has = true ;
154- }
155- } ) ;
156- }
157- return has ;
149+ return adjacent ( u ) . includes ( v ) ;
158150 }
159151
160152 // Computes the indegree for the given node.
You can’t perform that action at this time.
0 commit comments