• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

gephi / graphstore / #634

24 Oct 2026 02:02PM UTC coverage: 91.715% (-0.02%) from 91.737%
#634

push

web-flow
Release the read lock when a view degree getter fails (#341)

* Release the read lock when a view degree getter fails

The degree getters of the view graphs read the edges of a node through
iterators that take the graph read lock in their constructor and release it
only when they are exhausted. An exception while iterating, such as a node
of another graph store whose edge ids are invalid in this store, left the
read hold behind, so every later write lock request blocked forever.

The in and out edge iterators release their read lock once, and the degree
getters release it in a finally block. The release also keeps a second
hasNext() after the end from dropping a hold of the caller.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

* Release the read lock in the view degree getters without changing the iterators

The getters release the read lock themselves when the iteration ends with an
exception, instead of the iterators learning to release it once.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>

21 of 24 new or added lines in 1 file covered. (87.5%)

12243 of 13349 relevant lines covered (91.71%)

0.92 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

81.61
/src/main/java/org/gephi/graph/impl/GraphViewDecorator.java
1
/*
2
 * Copyright 2012-2013 Gephi Consortium
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5
 * use this file except in compliance with the License. You may obtain a copy of
6
 * the License at
7
 *
8
 * http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
 * License for the specific language governing permissions and limitations under
14
 * the License.
15
 */
16
package org.gephi.graph.impl;
17

18
import java.util.Collection;
19
import java.util.Iterator;
20
import java.util.Set;
21
import java.util.Spliterator;
22
import java.util.ConcurrentModificationException;
23
import java.util.function.Consumer;
24
import java.util.function.Predicate;
25
import org.gephi.graph.api.DirectedSubgraph;
26
import org.gephi.graph.api.Edge;
27
import org.gephi.graph.api.EdgeIterable;
28
import org.gephi.graph.api.Graph;
29
import org.gephi.graph.api.GraphModel;
30
import org.gephi.graph.api.GraphView;
31
import org.gephi.graph.api.Interval;
32
import org.gephi.graph.api.Node;
33
import org.gephi.graph.api.NodeIterable;
34
import org.gephi.graph.api.Rect2D;
35
import org.gephi.graph.api.SpatialIndex;
36
import org.gephi.graph.api.Subgraph;
37
import org.gephi.graph.api.UndirectedSubgraph;
38

39
public class GraphViewDecorator implements DirectedSubgraph, UndirectedSubgraph, SpatialIndex {
40

41
    protected final boolean undirected;
42
    protected final GraphViewImpl view;
43
    protected final GraphStore graphStore;
44

45
    public GraphViewDecorator(GraphStore graphStore, GraphViewImpl view, boolean undirected) {
1 ✔
46
        this.graphStore = graphStore;
1 ✔
47
        this.view = view;
1 ✔
48
        this.undirected = undirected;
1 ✔
49
    }
1 ✔
50

51
    @Override
52
    public Edge getEdge(Node node1, Node node2) {
53
        graphStore.autoReadLock();
1 ✔
54
        try {
55
            EdgeImpl edge = graphStore.edgeStore.get(node1, node2, undirected);
1 ✔
56
            if (edge != null && view.containsEdge(edge)) {
1 ✔
57
                return edge;
1 ✔
58
            }
59
            return null;
1 ✔
60
        } finally {
61
            graphStore.autoReadUnlock();
1 ✔
62
        }
63
    }
64

65
    @Override
66
    public EdgeIterable getEdges(Node node1, Node node2) {
67
        return new EdgeIterableWrapper(
×
68
                () -> new EdgeViewIterator(graphStore.edgeStore.getAll(node1, node2, undirected)),
×
69
                graphStore.getAutoLock());
×
70
    }
71

72
    @Override
73
    public Edge getEdge(Node node1, Node node2, int type) {
74
        graphStore.autoReadLock();
1 ✔
75
        try {
76
            EdgeImpl edge = graphStore.edgeStore.get(node1, node2, type, undirected);
1 ✔
77
            if (edge != null && view.containsEdge(edge)) {
1 ✔
78
                return edge;
1 ✔
79
            }
80
            return null;
1 ✔
81
        } finally {
82
            graphStore.autoReadUnlock();
1 ✔
83
        }
84
    }
85

86
    @Override
87
    public EdgeIterable getEdges(Node node1, Node node2, int type) {
88
        return new EdgeIterableWrapper(
×
89
                () -> new EdgeViewIterator(graphStore.edgeStore.getAll(node1, node2, type, undirected)),
×
90
                graphStore.getAutoLock());
×
91
    }
92

93
    @Override
94
    public Edge getMutualEdge(Edge e) {
95
        graphStore.autoReadLock();
1 ✔
96
        try {
97
            EdgeImpl edge = graphStore.edgeStore.getMutualEdge(e);
1 ✔
98
            if (edge != null && view.containsEdge(edge)) {
1 ✔
99
                return edge;
1 ✔
100
            }
101
            return null;
1 ✔
102
        } finally {
103
            graphStore.autoReadUnlock();
1 ✔
104
        }
105
    }
106

107
    @Override
108
    public NodeIterable getPredecessors(Node node) {
109
        checkValidInViewNodeObject(node);
1 ✔
110
        return new NodeIterableWrapper(() -> new NeighborsIterator((NodeImpl) node,
1 ✔
111
                new EdgeViewIterator(graphStore.edgeStore.edgeInIterator(node))), graphStore.getAutoLock());
1 ✔
112
    }
113

114
    @Override
115
    public NodeIterable getPredecessors(Node node, int type) {
116
        checkValidInViewNodeObject(node);
1 ✔
117
        return new NodeIterableWrapper(
1 ✔
118
                () -> new NeighborsIterator((NodeImpl) node,
1 ✔
119
                        new EdgeViewIterator(graphStore.edgeStore.edgeInIterator(node, type))),
1 ✔
120
                graphStore.getAutoLock());
1 ✔
121
    }
122

123
    @Override
124
    public NodeIterable getSuccessors(Node node) {
125
        checkValidInViewNodeObject(node);
1 ✔
126
        return new NodeIterableWrapper(() -> new NeighborsIterator((NodeImpl) node,
1 ✔
127
                new EdgeViewIterator(graphStore.edgeStore.edgeOutIterator(node))), graphStore.getAutoLock());
1 ✔
128
    }
129

130
    @Override
131
    public NodeIterable getSuccessors(Node node, int type) {
132
        checkValidInViewNodeObject(node);
1 ✔
133
        return new NodeIterableWrapper(
1 ✔
134
                () -> new NeighborsIterator((NodeImpl) node,
1 ✔
135
                        new EdgeViewIterator(graphStore.edgeStore.edgeOutIterator(node, type))),
1 ✔
136
                graphStore.getAutoLock());
1 ✔
137
    }
138

139
    @Override
140
    public EdgeIterable getInEdges(Node node) {
141
        checkValidInViewNodeObject(node);
1 ✔
142
        return new EdgeIterableWrapper(() -> new EdgeViewIterator(graphStore.edgeStore.edgeInIterator(node)),
1 ✔
143
                graphStore.getAutoLock());
1 ✔
144
    }
145

146
    @Override
147
    public EdgeIterable getInEdges(Node node, int type) {
148
        checkValidInViewNodeObject(node);
1 ✔
149
        return new EdgeIterableWrapper(() -> new EdgeViewIterator(graphStore.edgeStore.edgeInIterator(node, type)),
1 ✔
150
                graphStore.getAutoLock());
1 ✔
151
    }
152

153
    @Override
154
    public EdgeIterable getOutEdges(Node node) {
155
        checkValidInViewNodeObject(node);
1 ✔
156
        return new EdgeIterableWrapper(() -> new EdgeViewIterator(graphStore.edgeStore.edgeOutIterator(node)),
1 ✔
157
                graphStore.getAutoLock());
1 ✔
158
    }
159

160
    @Override
161
    public EdgeIterable getOutEdges(Node node, int type) {
162
        checkValidInViewNodeObject(node);
1 ✔
163
        return new EdgeIterableWrapper(() -> new EdgeViewIterator(graphStore.edgeStore.edgeOutIterator(node, type)),
1 ✔
164
                graphStore.getAutoLock());
1 ✔
165
    }
166

167
    @Override
168
    public boolean isAdjacent(Node source, Node target) {
169
        checkValidInViewNodeObject(source);
1 ✔
170
        checkValidInViewNodeObject(target);
1 ✔
171
        graphStore.autoReadLock();
1 ✔
172
        try {
173
            EdgeImpl edge = graphStore.edgeStore.get(source, target, undirected);
1 ✔
174
            return edge != null && view.containsEdge(edge);
1 ✔
175
        } finally {
176
            graphStore.autoReadUnlock();
1 ✔
177
        }
178
    }
179

180
    @Override
181
    public boolean isAdjacent(Node source, Node target, int type) {
182
        checkValidInViewNodeObject(source);
1 ✔
183
        checkValidInViewNodeObject(target);
1 ✔
184
        graphStore.autoReadLock();
1 ✔
185
        try {
186
            EdgeImpl edge = graphStore.edgeStore.get(source, target, type, undirected);
1 ✔
187
            return edge != null && view.containsEdge(edge);
1 ✔
188
        } finally {
189
            graphStore.autoReadUnlock();
1 ✔
190
        }
191
    }
192

193
    @Override
194
    public boolean addEdge(Edge edge) {
195
        checkValidEdgeObject(edge);
1 ✔
196
        graphStore.autoWriteLock();
1 ✔
197
        try {
198
            return view.addEdge(edge);
1 ✔
199
        } finally {
200
            graphStore.autoWriteUnlock();
1 ✔
201
        }
202

203
    }
204

205
    @Override
206
    public boolean addNode(Node node) {
207
        checkValidNodeObject(node);
1 ✔
208
        graphStore.autoWriteLock();
1 ✔
209
        try {
210
            return view.addNode(node);
1 ✔
211
        } finally {
212
            graphStore.autoWriteUnlock();
1 ✔
213
        }
214
    }
215

216
    @Override
217
    public boolean addAllEdges(Collection<? extends Edge> edges) {
218
        graphStore.autoWriteLock();
1 ✔
219
        try {
220
            return view.addAllEdges(edges);
1 ✔
221
        } finally {
222
            graphStore.autoWriteUnlock();
1 ✔
223
        }
224
    }
225

226
    @Override
227
    public boolean addAllNodes(Collection<? extends Node> nodes) {
228
        graphStore.autoWriteLock();
1 ✔
229
        try {
230
            return view.addAllNodes(nodes);
1 ✔
231
        } finally {
232
            graphStore.autoWriteUnlock();
1 ✔
233
        }
234
    }
235

236
    @Override
237
    public boolean removeEdge(Edge edge) {
238
        checkValidEdgeObject(edge);
1 ✔
239
        graphStore.autoWriteLock();
1 ✔
240
        try {
241
            return view.removeEdge(edge);
1 ✔
242
        } finally {
243
            graphStore.autoWriteUnlock();
1 ✔
244
        }
245
    }
246

247
    @Override
248
    public boolean removeNode(Node node) {
249
        checkValidNodeObject(node);
1 ✔
250
        graphStore.autoWriteLock();
1 ✔
251
        try {
252
            return view.removeNode(node);
1 ✔
253
        } finally {
254
            graphStore.autoWriteUnlock();
1 ✔
255
        }
256
    }
257

258
    @Override
259
    public boolean removeAllEdges(Collection<? extends Edge> edges) {
260
        graphStore.autoWriteLock();
1 ✔
261
        try {
262
            return view.removeEdgeAll(edges);
1 ✔
263
        } finally {
264
            graphStore.autoWriteUnlock();
1 ✔
265
        }
266
    }
267

268
    @Override
269
    public boolean removeAllNodes(Collection<? extends Node> nodes) {
270
        graphStore.autoWriteLock();
1 ✔
271
        try {
272
            return view.removeNodeAll(nodes);
1 ✔
273
        } finally {
274
            graphStore.autoWriteUnlock();
1 ✔
275
        }
276
    }
277

278
    @Override
279
    public boolean retainNodes(Collection<? extends Node> nodes) {
280
        graphStore.autoWriteLock();
1 ✔
281
        try {
282
            return view.retainNodes(nodes);
1 ✔
283
        } finally {
284
            graphStore.autoWriteUnlock();
1 ✔
285
        }
286
    }
287

288
    @Override
289
    public boolean retainEdges(Collection<? extends Edge> edges) {
290
        graphStore.autoWriteLock();
1 ✔
291
        try {
292
            return view.retainEdges(edges);
1 ✔
293
        } finally {
294
            graphStore.autoWriteUnlock();
1 ✔
295
        }
296
    }
297

298
    @Override
299
    public boolean contains(Node node) {
300
        checkValidNodeObject(node);
1 ✔
301
        graphStore.autoReadLock();
1 ✔
302
        try {
303
            return view.containsNode(node);
1 ✔
304
        } finally {
305
            graphStore.autoReadUnlock();
1 ✔
306
        }
307
    }
308

309
    @Override
310
    public boolean contains(Edge edge) {
311
        checkValidEdgeObject(edge);
1 ✔
312
        graphStore.autoReadLock();
1 ✔
313
        try {
314
            return view.containsEdge((EdgeImpl) edge);
1 ✔
315
        } finally {
316
            graphStore.autoReadUnlock();
1 ✔
317
        }
318
    }
319

320
    @Override
321
    public Node getNode(Object id) {
322
        graphStore.autoReadLock();
1 ✔
323
        try {
324
            NodeImpl node = graphStore.getNode(id);
1 ✔
325
            if (node != null && view.containsNode(node)) {
1 ✔
326
                return node;
1 ✔
327
            }
328
            return null;
1 ✔
329
        } finally {
330
            graphStore.autoReadUnlock();
1 ✔
331
        }
332
    }
333

334
    @Override
335
    public Node getNodeByStoreId(int id) {
336
        graphStore.autoReadLock();
×
337
        try {
338
            NodeImpl node = graphStore.getNodeByStoreId(id);
×
339
            if (node != null && view.containsNode(node)) {
×
340
                return node;
×
341
            }
342
            return null;
×
343
        } finally {
344
            graphStore.autoReadUnlock();
×
345
        }
346
    }
347

348
    @Override
349
    public boolean hasNode(final Object id) {
350
        return getNode(id) != null;
1 ✔
351
    }
352

353
    @Override
354
    public Edge getEdge(Object id) {
355
        graphStore.autoReadLock();
1 ✔
356
        try {
357
            EdgeImpl edge = graphStore.getEdge(id);
1 ✔
358
            if (edge != null && view.containsEdge(edge)) {
1 ✔
359
                return edge;
1 ✔
360
            }
361
            return null;
1 ✔
362
        } finally {
363
            graphStore.autoReadUnlock();
1 ✔
364
        }
365
    }
366

367
    @Override
368
    public Edge getEdgeByStoreId(int id) {
369
        graphStore.autoReadLock();
×
370
        try {
371
            EdgeImpl edge = graphStore.getEdgeByStoreId(id);
×
372
            if (edge != null && view.containsEdge(edge)) {
×
373
                return edge;
×
374
            }
375
            return null;
×
376
        } finally {
377
            graphStore.autoReadUnlock();
×
378
        }
379
    }
380

381
    @Override
382
    public boolean hasEdge(final Object id) {
383
        return getEdge(id) != null;
1 ✔
384
    }
385

386
    @Override
387
    public NodeIterable getNodes() {
388
        if (!view.isNodeView()) {
1 ✔
389
            return graphStore.getNodes();
1 ✔
390
        }
391
        return new NodeIterableWrapper(() -> new NodeViewIterator(graphStore.nodeStore.iterator()),
1 ✔
392
                NodeViewSpliterator::new, graphStore.getAutoLock());
1 ✔
393
    }
394

395
    @Override
396
    public EdgeIterable getEdges() {
397
        if (undirected) {
1 ✔
398
            return new EdgeIterableWrapper(() -> new UndirectedEdgeViewIterator(graphStore.edgeStore.iterator()),
1 ✔
399
                    () -> graphStore.edgeStore
1 ✔
400
                            .newFilteredSizedSpliterator(e -> view.containsEdge(e) && !isUndirectedToIgnore(e), view
1 ✔
401
                                    .getUndirectedEdgeCount()),
1 ✔
402
                    graphStore.getAutoLock());
1 ✔
403
        } else {
404
            return new EdgeIterableWrapper(() -> new EdgeViewIterator(graphStore.edgeStore.iterator()),
1 ✔
405
                    () -> graphStore.edgeStore.newFilteredSizedSpliterator(view::containsEdge, view.getEdgeCount()),
1 ✔
406
                    graphStore.getAutoLock());
1 ✔
407
        }
408
    }
409

410
    @Override
411
    public EdgeIterable getEdges(int type) {
412
        if (undirected) {
1 ✔
413
            return new EdgeIterableWrapper(
1 ✔
414
                    () -> new UndirectedEdgeViewIterator(graphStore.edgeStore.iteratorType(type, false)),
1 ✔
415
                    () -> graphStore.edgeStore.newFilteredSizedSpliterator(e -> e.getType() == type && view
×
416
                            .containsEdge(e) && !isUndirectedToIgnore(e), view.getUndirectedEdgeCount(type)),
×
417
                    graphStore.getAutoLock());
1 ✔
418
        } else {
419
            return new EdgeIterableWrapper(
1 ✔
420
                    () -> new EdgeViewIterator(graphStore.edgeStore.iteratorType(type, undirected)),
1 ✔
421
                    () -> graphStore.edgeStore
×
422
                            .newFilteredSizedSpliterator(e -> e.getType() == type && view.containsEdge(e), view
×
423
                                    .getEdgeCount(type)),
×
424
                    graphStore.getAutoLock());
1 ✔
425
        }
426
    }
427

428
    @Override
429
    public EdgeIterable getSelfLoops() {
430
        return new EdgeIterableWrapper(() -> new EdgeViewIterator(graphStore.edgeStore.iteratorSelfLoop()),
1 ✔
431
                () -> graphStore.edgeStore.newFilteredSpliterator(e -> e.isSelfLoop() && view.containsEdge(e)),
1 ✔
432
                graphStore.getAutoLock());
1 ✔
433
    }
434

435
    @Override
436
    public NodeIterable getNeighbors(Node node) {
437
        checkValidInViewNodeObject(node);
1 ✔
438
        return new NodeIterableWrapper(
1 ✔
439
                () -> new NeighborsIterator((NodeImpl) node,
1 ✔
440
                        new UndirectedEdgeViewIterator(graphStore.edgeStore.edgeIterator(node, true))),
1 ✔
441
                graphStore.getAutoLock());
1 ✔
442
    }
443

444
    @Override
445
    public NodeIterable getNeighbors(Node node, int type) {
446
        checkValidInViewNodeObject(node);
1 ✔
447
        return new NodeIterableWrapper(
1 ✔
448
                () -> new NeighborsIterator((NodeImpl) node,
1 ✔
449
                        new UndirectedEdgeViewIterator(graphStore.edgeStore.edgeIterator(node, type))),
1 ✔
450
                graphStore.getAutoLock());
1 ✔
451
    }
452

453
    @Override
454
    public EdgeIterable getEdges(Node node) {
455
        checkValidInViewNodeObject(node);
1 ✔
456
        if (undirected) {
1 ✔
457
            return new EdgeIterableWrapper(
1 ✔
458
                    () -> new UndirectedEdgeViewIterator(graphStore.edgeStore.edgeIterator(node, true)),
1 ✔
459
                    graphStore.getAutoLock());
1 ✔
460
        } else {
461
            return new EdgeIterableWrapper(() -> new EdgeViewIterator(graphStore.edgeStore.edgeIterator(node, true)),
1 ✔
462
                    graphStore.getAutoLock());
1 ✔
463
        }
464
    }
465

466
    @Override
467
    public EdgeIterable getEdges(Node node, int type) {
468
        checkValidInViewNodeObject(node);
1 ✔
469
        if (undirected) {
1 ✔
470
            return new EdgeIterableWrapper(
1 ✔
471
                    () -> new UndirectedEdgeViewIterator(graphStore.edgeStore.edgeIterator(node, type)),
1 ✔
472
                    graphStore.getAutoLock());
1 ✔
473
        } else {
474
            return new EdgeIterableWrapper(() -> new EdgeViewIterator(graphStore.edgeStore.edgeIterator(node, type)),
1 ✔
475
                    graphStore.getAutoLock());
1 ✔
476
        }
477
    }
478

479
    @Override
480
    public int getNodeCount() {
481
        return view.getNodeCount();
1 ✔
482
    }
483

484
    @Override
485
    public int getEdgeCount() {
486
        if (undirected) {
1 ✔
487
            return view.getUndirectedEdgeCount();
1 ✔
488
        } else {
489
            return view.getEdgeCount();
1 ✔
490
        }
491
    }
492

493
    @Override
494
    public int getEdgeCount(int type) {
495
        if (undirected) {
1 ✔
496
            return view.getUndirectedEdgeCount(type);
1 ✔
497
        } else {
498
            return view.getEdgeCount(type);
1 ✔
499
        }
500
    }
501

502
    @Override
503
    public Node getOpposite(Node node, Edge edge) {
504
        checkValidInViewNodeObject(node);
1 ✔
505
        checkValidInViewEdgeObject(edge);
1 ✔
506

507
        return graphStore.getOpposite(node, edge);
1 ✔
508
    }
509

510
    @Override
511
    public int getDegree(Node node) {
512
        EdgeStore.EdgeInOutIterator itr = graphStore.edgeStore.edgeIterator(node, true);
1 ✔
513
        // The iterator releases the read lock when it is exhausted
514
        boolean exhausted = false;
1 ✔
515
        try {
516
            int count = 0;
1 ✔
517
            while (itr.hasNext()) {
1 ✔
518
                EdgeImpl edge = itr.next();
1 ✔
519
                if (view.containsEdge(edge) && !(undirected && isUndirectedToIgnore(edge))) {
1 ✔
520
                    count++;
1 ✔
521
                    if (edge.isSelfLoop()) {
1 ✔
522
                        count++;
1 ✔
523
                    }
524
                }
525
            }
1 ✔
526
            exhausted = true;
1 ✔
527
            return count;
1 ✔
528
        } finally {
529
            if (!exhausted) {
1 ✔
NEW
530
                graphStore.autoReadUnlock();
×
531
            }
532
        }
533
    }
534

535
    @Override
536
    public int getInDegree(Node node) {
537
        EdgeStore.EdgeInIterator itr = graphStore.edgeStore.edgeInIterator(node);
1 ✔
538
        // The iterator releases the read lock when it is exhausted
539
        boolean exhausted = false;
1 ✔
540
        try {
541
            int count = 0;
1 ✔
542
            while (itr.hasNext()) {
1 ✔
543
                if (view.containsEdge(itr.next())) {
1 ✔
544
                    count++;
1 ✔
545
                }
546
            }
547
            exhausted = true;
1 ✔
548
            return count;
1 ✔
549
        } finally {
550
            if (!exhausted) {
1 ✔
NEW
551
                graphStore.autoReadUnlock();
×
552
            }
553
        }
554
    }
555

556
    @Override
557
    public int getOutDegree(Node node) {
558
        EdgeStore.EdgeOutIterator itr = graphStore.edgeStore.edgeOutIterator(node);
1 ✔
559
        // The iterator releases the read lock when it is exhausted
560
        boolean exhausted = false;
1 ✔
561
        try {
562
            int count = 0;
1 ✔
563
            while (itr.hasNext()) {
1 ✔
564
                if (view.containsEdge(itr.next())) {
1 ✔
565
                    count++;
1 ✔
566
                }
567
            }
568
            exhausted = true;
1 ✔
569
            return count;
1 ✔
570
        } finally {
571
            if (!exhausted) {
1 ✔
NEW
572
                graphStore.autoReadUnlock();
×
573
            }
574
        }
575
    }
576

577
    @Override
578
    public boolean isSelfLoop(Edge edge) {
579
        return edge.isSelfLoop();
1 ✔
580
    }
581

582
    @Override
583
    public boolean isDirected(Edge edge) {
584
        return edge.isDirected();
1 ✔
585
    }
586

587
    @Override
588
    public boolean isIncident(Edge edge1, Edge edge2) {
589
        graphStore.autoReadLock();
1 ✔
590
        try {
591
            checkValidInViewEdgeObject(edge1);
1 ✔
592
            checkValidInViewEdgeObject(edge2);
1 ✔
593

594
            return graphStore.edgeStore.isIncident((EdgeImpl) edge1, (EdgeImpl) edge2);
1 ✔
595
        } finally {
596
            graphStore.autoReadUnlock();
1 ✔
597
        }
598
    }
599

600
    @Override
601
    public boolean isIncident(final Node node, final Edge edge) {
602
        graphStore.autoReadLock();
1 ✔
603
        try {
604
            checkValidInViewNodeObject(node);
1 ✔
605
            checkValidInViewEdgeObject(edge);
1 ✔
606

607
            return graphStore.edgeStore.isIncident((NodeImpl) node, (EdgeImpl) edge);
1 ✔
608
        } finally {
609
            graphStore.autoReadUnlock();
1 ✔
610
        }
611
    }
612

613
    @Override
614
    public void clearEdges(Node node) {
615
        graphStore.autoWriteLock();
1 ✔
616
        try {
617
            EdgeStore.EdgeInOutIterator itr = graphStore.edgeStore.edgeIterator(node, false);
1 ✔
618
            while (itr.hasNext()) {
1 ✔
619
                EdgeImpl edge = itr.next();
1 ✔
620
                view.removeEdge(edge);
1 ✔
621
            }
1 ✔
622
        } finally {
623
            graphStore.autoWriteUnlock();
1 ✔
624
        }
625
    }
1 ✔
626

627
    @Override
628
    public void clearEdges(Node node, int type) {
629
        graphStore.autoWriteLock();
1 ✔
630
        try {
631
            EdgeStore.EdgeTypeInOutIterator itr = graphStore.edgeStore.edgeIterator(node, type);
1 ✔
632
            while (itr.hasNext()) {
1 ✔
633
                EdgeImpl edge = itr.next();
1 ✔
634
                view.removeEdge(edge);
1 ✔
635
            }
1 ✔
636
        } finally {
637
            graphStore.autoWriteUnlock();
1 ✔
638
        }
639
    }
1 ✔
640

641
    @Override
642
    public void clear() {
643
        graphStore.autoWriteLock();
1 ✔
644
        try {
645
            view.clear();
1 ✔
646
        } finally {
647
            graphStore.autoWriteUnlock();
1 ✔
648
        }
649
    }
1 ✔
650

651
    @Override
652
    public void clearEdges() {
653
        graphStore.autoWriteLock();
1 ✔
654
        try {
655
            view.clearEdges();
1 ✔
656
        } finally {
657
            graphStore.autoWriteUnlock();
1 ✔
658
        }
659
    }
1 ✔
660

661
    @Override
662
    public Object getAttribute(String key) {
663
        return view.attributes.getValue(key);
1 ✔
664
    }
665

666
    @Override
667
    public Object getAttribute(String key, double timestamp) {
668
        return view.attributes.getValue(key, timestamp);
1 ✔
669
    }
670

671
    @Override
672
    public Object getAttribute(String key, Interval interval) {
673
        return view.attributes.getValue(key, interval);
1 ✔
674
    }
675

676
    @Override
677
    public Set<String> getAttributeKeys() {
678
        return view.attributes.getKeys();
1 ✔
679
    }
680

681
    @Override
682
    public void setAttribute(String key, Object value) {
683
        view.attributes.setValue(key, value);
1 ✔
684
    }
1 ✔
685

686
    @Override
687
    public void setAttribute(String key, Object value, double timestamp) {
688
        view.attributes.setValue(key, value, timestamp);
1 ✔
689
    }
1 ✔
690

691
    @Override
692
    public void setAttribute(String key, Object value, Interval interval) {
693
        view.attributes.setValue(key, value, interval);
1 ✔
694
    }
1 ✔
695

696
    @Override
697
    public void removeAttribute(String key) {
698
        view.attributes.removeValue(key);
1 ✔
699
    }
1 ✔
700

701
    @Override
702
    public void removeAttribute(String key, double timestamp) {
703
        view.attributes.removeValue(key, timestamp);
1 ✔
704
    }
1 ✔
705

706
    @Override
707
    public void removeAttribute(String key, Interval interval) {
708
        view.attributes.removeValue(key, interval);
1 ✔
709
    }
1 ✔
710

711
    @Override
712
    public GraphModel getModel() {
713
        return graphStore.graphModel;
×
714
    }
715

716
    @Override
717
    public int getVersion() {
718
        return view.getVersion();
×
719
    }
720

721
    @Override
722
    public boolean isDirected() {
723
        return graphStore.isDirected();
1 ✔
724
    }
725

726
    @Override
727
    public boolean isUndirected() {
728
        return graphStore.isUndirected();
1 ✔
729
    }
730

731
    @Override
732
    public boolean isMixed() {
733
        return graphStore.isMixed();
×
734
    }
735

736
    @Override
737
    public void readLock() {
738
        graphStore.lock.readLock();
1 ✔
739
    }
1 ✔
740

741
    @Override
742
    public void readUnlock() {
743
        graphStore.lock.readUnlock();
1 ✔
744
    }
1 ✔
745

746
    @Override
747
    public void readUnlockAll() {
748
        graphStore.lock.readUnlockAll();
×
749
    }
×
750

751
    @Override
752
    public void writeLock() {
753
        graphStore.lock.writeLock();
1 ✔
754
    }
1 ✔
755

756
    @Override
757
    public GraphLockImpl getLock() {
758
        return graphStore.lock;
1 ✔
759
    }
760

761
    @Override
762
    public void writeUnlock() {
763
        graphStore.lock.writeUnlock();
1 ✔
764
    }
1 ✔
765

766
    @Override
767
    public GraphView getView() {
768
        return view;
1 ✔
769
    }
770

771
    @Override
772
    public void fill() {
773
        graphStore.autoWriteLock();
1 ✔
774
        try {
775
            view.fill();
1 ✔
776
        } finally {
777
            graphStore.autoWriteUnlock();
1 ✔
778
        }
779
    }
1 ✔
780

781
    @Override
782
    public void union(Subgraph subGraph) {
783
        checkValidViewObject(subGraph.getView());
1 ✔
784

785
        graphStore.autoWriteLock();
1 ✔
786
        try {
787
            view.union((GraphViewImpl) subGraph.getView());
1 ✔
788
        } finally {
789
            graphStore.autoWriteUnlock();
1 ✔
790
        }
791
    }
1 ✔
792

793
    @Override
794
    public void intersection(Subgraph subGraph) {
795
        checkValidViewObject(subGraph.getView());
1 ✔
796

797
        graphStore.autoWriteLock();
1 ✔
798
        try {
799
            view.intersection((GraphViewImpl) subGraph.getView());
1 ✔
800
        } finally {
801
            graphStore.autoWriteUnlock();
1 ✔
802
        }
803
    }
1 ✔
804

805
    @Override
806
    public void not() {
807
        graphStore.autoWriteLock();
1 ✔
808
        try {
809
            view.not();
1 ✔
810
        } finally {
811
            graphStore.autoWriteUnlock();
1 ✔
812
        }
813
    }
1 ✔
814

815
    @Override
816
    public Graph getRootGraph() {
817
        return graphStore;
×
818
    }
819

820
    @Override
821
    public SpatialIndex getSpatialIndex() {
822
        if (graphStore.spatialIndex == null) {
1 ✔
823
            throw new UnsupportedOperationException("Spatial index is disabled (from Configuration)");
×
824
        }
825
        return this;
1 ✔
826
    }
827

828
    void checkWriteLock() {
829
        if (graphStore.lock != null) {
1 ✔
830
            graphStore.lock.checkHoldWriteLock();
1 ✔
831
        }
832
    }
1 ✔
833

834
    void checkValidNodeObject(final Node n) {
835
        if (n == null) {
1 ✔
836
            throw new NullPointerException();
×
837
        }
838
        if (!(n instanceof NodeImpl)) {
1 ✔
839
            throw new ClassCastException("Object must be a NodeImpl object");
×
840
        }
841
        if (n.getStoreId() == NodeStore.NULL_ID) {
1 ✔
842
            throw new IllegalArgumentException("Node should belong to a store");
×
843
        }
844
    }
1 ✔
845

846
    void checkValidInViewNodeObject(final Node n) {
847
        checkValidNodeObject(n);
1 ✔
848

849
        if (!view.containsNode(n)) {
1 ✔
850
            throw new RuntimeException("Node doesn't belong to this view");
1 ✔
851
        }
852
    }
1 ✔
853

854
    void checkValidEdgeObject(final Edge n) {
855
        if (n == null) {
1 ✔
856
            throw new NullPointerException();
×
857
        }
858
        if (!(n instanceof EdgeImpl)) {
1 ✔
859
            throw new ClassCastException("Object must be a EdgeImpl object");
×
860
        }
861
        if (n.getStoreId() == EdgeStore.NULL_ID) {
1 ✔
862
            throw new IllegalArgumentException("Edge should belong to a store");
×
863
        }
864
    }
1 ✔
865

866
    void checkValidInViewEdgeObject(final Edge e) {
867
        checkValidEdgeObject(e);
1 ✔
868

869
        if (!view.containsEdge(e)) {
1 ✔
870
            throw new RuntimeException("Edge doesn't belong to this view");
×
871
        }
872
    }
1 ✔
873

874
    void checkValidViewObject(final GraphView view) {
875
        if (view == null) {
1 ✔
876
            throw new NullPointerException();
×
877
        }
878
        if (!(view instanceof GraphViewImpl)) {
1 ✔
879
            throw new ClassCastException("Object must be a GraphViewImpl object");
×
880
        }
881
        if (((GraphViewImpl) view).graphStore != graphStore) {
1 ✔
882
            throw new RuntimeException("The view doesn't belong to this store");
×
883
        }
884
    }
1 ✔
885

886
    boolean isUndirectedToIgnore(final EdgeImpl edge) {
887
        if (edge.isMutual() && edge.source.storeId < edge.target.storeId) {
1 ✔
888
            if (view.containsEdge(graphStore.edgeStore.get(edge.target, edge.source, edge.type, false))) {
1 ✔
889
                return true;
1 ✔
890
            }
891
        }
892
        return false;
1 ✔
893
    }
894

895
    @Override
896
    public NodeIterable getNodesInArea(Rect2D rect) {
897
        if (graphStore.spatialIndex == null) {
×
898
            throw new UnsupportedOperationException("Spatial index is disabled (from Configuration)");
×
899
        }
900
        return graphStore.spatialIndex.getNodesInArea(rect, view::containsNode);
×
901
    }
902

903
    @Override
904
    public NodeIterable getNodesInArea(Rect2D rect, Predicate<? super Node> predicate) {
905
        if (graphStore.spatialIndex == null) {
×
906
            throw new UnsupportedOperationException("Spatial index is disabled (from Configuration)");
×
907
        }
908
        return graphStore.spatialIndex.getNodesInArea(rect, (node) -> view.containsNode(node) && predicate.test(node));
×
909
    }
910

911
    @Override
912
    public NodeIterable getApproximateNodesInArea(Rect2D rect) {
913
        if (graphStore.spatialIndex == null) {
×
914
            throw new UnsupportedOperationException("Spatial index is disabled (from Configuration)");
×
915
        }
916
        return graphStore.spatialIndex.getApproximateNodesInArea(rect, view::containsNode);
×
917
    }
918

919
    @Override
920
    public NodeIterable getApproximateNodesInArea(Rect2D rect, Predicate<? super Node> predicate) {
921
        if (graphStore.spatialIndex == null) {
×
922
            throw new UnsupportedOperationException("Spatial index is disabled (from Configuration)");
×
923
        }
924
        return graphStore.spatialIndex
×
925
                .getApproximateNodesInArea(rect, (node) -> view.containsNode(node) && predicate.test(node));
×
926
    }
927

928
    @Override
929
    public EdgeIterable getEdgesInArea(Rect2D rect) {
930
        if (graphStore.spatialIndex == null) {
×
931
            throw new UnsupportedOperationException("Spatial index is disabled (from Configuration)");
×
932
        }
933
        return graphStore.spatialIndex.getEdgesInArea(rect, view::containsEdge);
×
934
    }
935

936
    @Override
937
    public EdgeIterable getEdgesInArea(Rect2D rect, Predicate<? super Edge> predicate) {
938
        if (graphStore.spatialIndex == null) {
×
939
            throw new UnsupportedOperationException("Spatial index is disabled (from Configuration)");
×
940
        }
941
        return graphStore.spatialIndex.getEdgesInArea(rect, (edge) -> view.containsEdge(edge) && predicate.test(edge));
×
942
    }
943

944
    @Override
945
    public EdgeIterable getApproximateEdgesInArea(Rect2D rect) {
946
        if (graphStore.spatialIndex == null) {
×
947
            throw new UnsupportedOperationException("Spatial index is disabled (from Configuration)");
×
948
        }
949
        return graphStore.spatialIndex.getApproximateEdgesInArea(rect, view::containsEdge);
×
950
    }
951

952
    @Override
953
    public EdgeIterable getApproximateEdgesInArea(Rect2D rect, Predicate<? super Edge> predicate) {
954
        if (graphStore.spatialIndex == null) {
×
955
            throw new UnsupportedOperationException("Spatial index is disabled (from Configuration)");
×
956
        }
957
        return graphStore.spatialIndex
×
958
                .getApproximateEdgesInArea(rect, (edge) -> view.containsEdge(edge) && predicate.test(edge));
×
959
    }
960

961
    @Override
962
    public Rect2D getBoundaries() {
963
        if (graphStore.spatialIndex == null) {
1 ✔
964
            throw new UnsupportedOperationException("Spatial index is disabled (from Configuration)");
×
965
        }
966
        return graphStore.spatialIndex.getBoundaries(view::containsNode);
1 ✔
967
    }
968

969
    @Override
970
    public void spatialIndexReadLock() {
971
        if (graphStore.spatialIndex == null) {
×
972
            throw new UnsupportedOperationException("Spatial index is disabled (from Configuration)");
×
973
        }
974
        graphStore.spatialIndex.spatialIndexReadLock();
×
975
    }
×
976

977
    @Override
978
    public void spatialIndexReadUnlock() {
979
        if (graphStore.spatialIndex == null) {
×
980
            throw new UnsupportedOperationException("Spatial index is disabled (from Configuration)");
×
981
        }
982
        graphStore.spatialIndex.spatialIndexReadUnlock();
×
983
    }
×
984

985
    private final class NodeViewSpliterator implements Spliterator<Node> {
986

987
        private final int endBlockExclusive;
988
        private int blockIndex;
989
        private int indexInBlock;
990
        private NodeImpl[] currentArray;
991
        private int currentLength;
992
        private final int expectedVersion;
993
        private int totalSize;
994
        private int consumed;
995
        // True only for the root spliterator, where totalSize comes from view.getNodeCount().
996
        // Sub-ranges only have a proportional estimate and must drop SIZED.
997
        private boolean exactSize;
998

999
        NodeViewSpliterator() {
1000
            this(0, graphStore.nodeStore.blocksCount);
1 ✔
1001
        }
1 ✔
1002

1003
        NodeViewSpliterator(int startBlock, int endBlockExclusive) {
1 ✔
1004
            this.blockIndex = startBlock;
1 ✔
1005
            this.endBlockExclusive = endBlockExclusive;
1 ✔
1006
            this.expectedVersion = graphStore.version != null ? graphStore.version.getNodeVersion() : 0;
1 ✔
1007
            this.consumed = 0;
1 ✔
1008

1009
            // Root spliterator uses the exact view count; sub-ranges fall back to an estimate.
1010
            if (startBlock == 0 && endBlockExclusive == graphStore.nodeStore.blocksCount) {
1 ✔
1011
                this.totalSize = view.getNodeCount();
1 ✔
1012
                this.exactSize = true;
1 ✔
1013
            } else {
1014
                this.totalSize = computeSizeEstimate(startBlock, endBlockExclusive);
1 ✔
1015
                this.exactSize = false;
1 ✔
1016
            }
1017

1018
            if (startBlock < endBlockExclusive) {
1 ✔
1019
                NodeStore.NodeBlock b = graphStore.nodeStore.blocks[startBlock];
1 ✔
1020
                currentArray = b.backingArray;
1 ✔
1021
                currentLength = b.nodeLength;
1 ✔
1022
                indexInBlock = 0;
1 ✔
1023
            } else {
1 ✔
1024
                currentArray = null;
×
1025
                currentLength = 0;
×
1026
                indexInBlock = 0;
×
1027
            }
1028
        }
1 ✔
1029

1030
        private void advanceBlock() {
1031
            blockIndex++;
1 ✔
1032
            if (blockIndex < endBlockExclusive) {
1 ✔
1033
                NodeStore.NodeBlock b = graphStore.nodeStore.blocks[blockIndex];
×
1034
                currentArray = b.backingArray;
×
1035
                currentLength = b.nodeLength;
×
1036
                indexInBlock = 0;
×
1037
            } else {
×
1038
                currentArray = null;
1 ✔
1039
                currentLength = 0;
1 ✔
1040
                indexInBlock = 0;
1 ✔
1041
            }
1042
        }
1 ✔
1043

1044
        private void checkForComodification() {
1045
            if (graphStore.version != null && expectedVersion != graphStore.version.getNodeVersion()) {
1 ✔
1046
                throw new ConcurrentModificationException();
×
1047
            }
1048
        }
1 ✔
1049

1050
        private int computeSizeEstimate(int start, int end) {
1051
            int sum = 0;
1 ✔
1052
            for (int i = start; i < end; i++) {
1 ✔
1053
                NodeStore.NodeBlock b = graphStore.nodeStore.blocks[i];
1 ✔
1054
                if (b != null) {
1 ✔
1055
                    // Exact count: nodeLength minus garbageLength
1056
                    sum += (b.nodeLength - b.garbageLength);
1 ✔
1057
                }
1058
            }
1059
            if (sum > 0) {
1 ✔
1060
                // Scale by view ratio to estimate number of nodes in view
1061
                double viewRatio = (double) view.getNodeCount() / graphStore.nodeStore.size;
1 ✔
1062
                sum = (int) Math.round(sum * viewRatio);
1 ✔
1063
            }
1064
            return sum;
1 ✔
1065
        }
1066

1067
        @Override
1068
        public boolean tryAdvance(Consumer<? super Node> action) {
1069
            checkForComodification();
1 ✔
1070
            while (currentArray != null) {
1 ✔
1071
                while (indexInBlock < currentLength) {
1 ✔
1072
                    NodeImpl n = currentArray[indexInBlock++];
1 ✔
1073
                    if (n != null && view.containsNode(n)) {
1 ✔
1074
                        consumed++;
1 ✔
1075
                        action.accept(n);
1 ✔
1076
                        return true;
1 ✔
1077
                    }
1078
                }
1 ✔
1079
                advanceBlock();
1 ✔
1080
            }
1081
            return false;
1 ✔
1082
        }
1083

1084
        @Override
1085
        public Spliterator<Node> trySplit() {
1086
            // Only split at block boundaries to preserve encounter order
1087
            if (indexInBlock != 0) {
1 ✔
1088
                return null;
×
1089
            }
1090

1091
            int currentPos = blockIndex;
1 ✔
1092
            int remainingBlocks = endBlockExclusive - currentPos;
1 ✔
1093

1094
            if (remainingBlocks <= 1) {
1 ✔
1095
                return null;
1 ✔
1096
            }
1097

1098
            int mid = currentPos + remainingBlocks / 2;
1 ✔
1099

1100
            // Create left half
1101
            NodeViewSpliterator left = new NodeViewSpliterator(currentPos, mid);
1 ✔
1102

1103
            // Update this spliterator to become the right half
1104
            blockIndex = mid;
1 ✔
1105
            if (mid < endBlockExclusive) {
1 ✔
1106
                NodeStore.NodeBlock b = graphStore.nodeStore.blocks[mid];
1 ✔
1107
                currentArray = b.backingArray;
1 ✔
1108
                currentLength = b.nodeLength;
1 ✔
1109
                indexInBlock = 0;
1 ✔
1110
            } else {
1 ✔
1111
                currentArray = null;
×
1112
                currentLength = 0;
×
1113
                indexInBlock = 0;
×
1114
            }
1115

1116
            this.totalSize = Math.max(0, totalSize - left.totalSize);
1 ✔
1117
            // Once split, neither half can guarantee an exact view-aware size, so drop SIZED.
1118
            this.exactSize = false;
1 ✔
1119
            left.exactSize = false;
1 ✔
1120

1121
            return left;
1 ✔
1122
        }
1123

1124
        @Override
1125
        public long estimateSize() {
1126
            // Use the exact view size minus what we've consumed
1127
            long remaining = totalSize - consumed;
1 ✔
1128
            return remaining < 0 ? 0 : remaining;
1 ✔
1129
        }
1130

1131
        @Override
1132
        public int characteristics() {
1133
            int base = Spliterator.ORDERED | Spliterator.DISTINCT | Spliterator.NONNULL;
1 ✔
1134
            return exactSize ? base | Spliterator.SIZED : base;
1 ✔
1135
        }
1136
    }
1137

1138
    protected final class NodeViewIterator implements Iterator<Node> {
1139

1140
        private final Iterator<Node> nodeIterator;
1141
        private NodeImpl pointer;
1142

1143
        public NodeViewIterator(Iterator<Node> nodeIterator) {
1 ✔
1144
            this.nodeIterator = nodeIterator;
1 ✔
1145
        }
1 ✔
1146

1147
        @Override
1148
        public boolean hasNext() {
1149
            pointer = null;
1 ✔
1150
            while (pointer == null) {
1 ✔
1151
                if (!nodeIterator.hasNext()) {
1 ✔
1152
                    return false;
1 ✔
1153
                }
1154
                pointer = (NodeImpl) nodeIterator.next();
1 ✔
1155
                if (!view.containsNode(pointer)) {
1 ✔
1156
                    pointer = null;
1 ✔
1157
                }
1158
            }
1159
            return true;
1 ✔
1160
        }
1161

1162
        @Override
1163
        public Node next() {
1164
            return pointer;
1 ✔
1165
        }
1166

1167
        @Override
1168
        public void remove() {
1169
            checkWriteLock();
×
1170
            removeNode(pointer);
×
1171
        }
×
1172
    }
1173

1174
    protected final class EdgeViewIterator implements Iterator<Edge> {
1175

1176
        private final Iterator<Edge> edgeIterator;
1177
        private EdgeImpl pointer;
1178

1179
        public EdgeViewIterator(Iterator<Edge> edgeIterator) {
1 ✔
1180
            this.edgeIterator = edgeIterator;
1 ✔
1181
        }
1 ✔
1182

1183
        @Override
1184
        public boolean hasNext() {
1185
            pointer = null;
1 ✔
1186
            while (pointer == null) {
1 ✔
1187
                if (!edgeIterator.hasNext()) {
1 ✔
1188
                    return false;
1 ✔
1189
                }
1190
                pointer = (EdgeImpl) edgeIterator.next();
1 ✔
1191
                if (!view.containsEdge(pointer)) {
1 ✔
1192
                    pointer = null;
1 ✔
1193
                }
1194
            }
1195
            return true;
1 ✔
1196
        }
1197

1198
        @Override
1199
        public Edge next() {
1200
            return pointer;
1 ✔
1201
        }
1202

1203
        @Override
1204
        public void remove() {
1205
            checkWriteLock();
×
1206
            removeEdge(pointer);
×
1207
        }
×
1208
    }
1209

1210
    protected final class UndirectedEdgeViewIterator implements Iterator<Edge> {
1211

1212
        protected final Iterator<Edge> itr;
1213
        protected EdgeImpl pointer;
1214

1215
        public UndirectedEdgeViewIterator(Iterator<Edge> itr) {
1 ✔
1216
            this.itr = itr;
1 ✔
1217
        }
1 ✔
1218

1219
        @Override
1220
        public boolean hasNext() {
1221
            pointer = null;
1 ✔
1222
            while (pointer == null || !view.containsEdge(pointer) || isUndirectedToIgnore(pointer)) {
1 ✔
1223
                if (!itr.hasNext()) {
1 ✔
1224
                    return false;
1 ✔
1225
                }
1226
                pointer = (EdgeImpl) itr.next();
1 ✔
1227
            }
1228
            return true;
1 ✔
1229
        }
1230

1231
        @Override
1232
        public EdgeImpl next() {
1233
            return pointer;
1 ✔
1234
        }
1235

1236
        @Override
1237
        public void remove() {
1238
            checkWriteLock();
1 ✔
1239
            if (pointer.isMutual() && view
1 ✔
1240
                    .containsEdge(graphStore.edgeStore.get(pointer.target, pointer.source, pointer.type, false))) {
1 ✔
1241
                throw new UnsupportedOperationException(
1 ✔
1242
                        "Removing directed edges from undirected iterator is not supported");
1243
            }
1244
            removeEdge(pointer);
1 ✔
1245
        }
1 ✔
1246
    }
1247

1248
    protected static class NeighborsIterator implements Iterator<Node> {
1249

1250
        protected final NodeImpl node;
1251
        protected final Iterator<Edge> itr;
1252

1253
        public NeighborsIterator(NodeImpl node, Iterator<Edge> itr) {
1 ✔
1254
            this.node = node;
1 ✔
1255
            this.itr = itr;
1 ✔
1256
        }
1 ✔
1257

1258
        @Override
1259
        public boolean hasNext() {
1260
            return itr.hasNext();
1 ✔
1261
        }
1262

1263
        @Override
1264
        public Node next() {
1265
            Edge e = itr.next();
1 ✔
1266
            return e.getSource() == node ? e.getTarget() : e.getSource();
1 ✔
1267
        }
1268

1269
        @Override
1270
        public void remove() {
1271
            throw new UnsupportedOperationException("Remove not supported for this iterator");
×
1272
        }
1273
    }
1274
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc