AbstractNode.java

1
/*
2
 * Copyright 2006 - 2013
3
 *     Stefan Balev     <stefan.balev@graphstream-project.org>
4
 *     Julien Baudry    <julien.baudry@graphstream-project.org>
5
 *     Antoine Dutot    <antoine.dutot@graphstream-project.org>
6
 *     Yoann Pign��      <yoann.pigne@graphstream-project.org>
7
 *     Guilhelm Savin   <guilhelm.savin@graphstream-project.org>
8
 * 
9
 * This file is part of GraphStream <http://graphstream-project.org>.
10
 * 
11
 * GraphStream is a library whose purpose is to handle static or dynamic
12
 * graph, create them from scratch, file or any source and display them.
13
 * 
14
 * This program is free software distributed under the terms of two licenses, the
15
 * CeCILL-C license that fits European law, and the GNU Lesser General Public
16
 * License. You can  use, modify and/ or redistribute the software under the terms
17
 * of the CeCILL-C license as circulated by CEA, CNRS and INRIA at the following
18
 * URL <http://www.cecill.info> or under the terms of the GNU LGPL as published by
19
 * the Free Software Foundation, either version 3 of the License, or (at your
20
 * option) any later version.
21
 * 
22
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY
23
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
24
 * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
25
 * 
26
 * You should have received a copy of the GNU Lesser General Public License
27
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
28
 * 
29
 * The fact that you are presently reading this means that you have had
30
 * knowledge of the CeCILL-C and LGPL licenses and that you accept their terms.
31
 */
32
package org.graphstream.graph.implementations;
33
34
import java.util.AbstractCollection;
35
import java.util.Collection;
36
import java.util.HashSet;
37
import java.util.Iterator;
38
import java.util.NoSuchElementException;
39
40
import org.graphstream.graph.BreadthFirstIterator;
41
import org.graphstream.graph.DepthFirstIterator;
42
import org.graphstream.graph.Edge;
43
import org.graphstream.graph.Graph;
44
import org.graphstream.graph.Node;
45
import org.graphstream.stream.SourceBase;
46
47
/**
48
 * <p>
49
 * This class provides a basic implementation of {@code Node} interface, to
50
 * minimize the effort required to implement this interface.
51
 * </p>
52
 * 
53
 * <p>
54
 * This class implements all the methods of
55
 * {@link org.graphstream.graph.implementations#AbstractElement} and most of the
56
 * methods of {@link org.graphstream.graph#Node} (there are "only" ten abstract
57
 * methods). In addition to these, subclasses must provide implementations for
58
 * {@link #addEdgeCallback(AbstractEdge)} and
59
 * {@link #removeEdgeCallback(AbstractEdge)} which are called by the parent
60
 * graph when an edge incident to this node is added to or removed from the
61
 * graph. This class has a low memory overhead (one reference as field).
62
 * </p>
63
 */
64
public abstract class AbstractNode extends AbstractElement implements Node {
65
66
	// *** Fields ***
67
68
	/**
69
	 * The graph to which this node belongs
70
	 */
71
	protected AbstractGraph graph;
72
73
	// *** Constructors
74
75
	/**
76
	 * Constructs a new node. This constructor copies the parameters into the
77
	 * corresponding fields
78
	 * 
79
	 * @param graph
80
	 *            The graph to which this node belongs.
81
	 * @param id
82
	 *            Unique identifier of this node.
83
	 */
84
	protected AbstractNode(AbstractGraph graph, String id) {
85
		super(id);
86
		this.graph = graph;
87
	}
88
89
	// *** Inherited from abstract element ***
90
91
	@Override
92
	protected void attributeChanged(String sourceId, long timeId,
93
			String attribute, AttributeChangeEvent event, Object oldValue,
94
			Object newValue) {
95 1 1. attributeChanged : removed call to org/graphstream/graph/implementations/AbstractGraph$GraphListeners::sendAttributeChangedEvent → SURVIVED
		graph.listeners.sendAttributeChangedEvent(sourceId, timeId, id,
96
				SourceBase.ElementType.NODE, attribute, event, oldValue,
97
				newValue);
98
99
	}
100
101
	@Override
102
	/**
103
	 * @return The id of the parent graph
104
	 * @see org.graphstream.graph.implementations.AbstractElement#myGraphId()
105
	 */
106
	protected String myGraphId() {
107 1 1. myGraphId : mutated return of Object value for org/graphstream/graph/implementations/AbstractNode::myGraphId to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
		return graph.getId();
108
	}
109
110
	@Override
111
	/**
112
	 * This implementation calls the corresponding method of the parent graph
113
	 * 
114
	 * @see org.graphstream.graph.implementations.AbstractElement#newEvent()
115
	 */
116
	protected long newEvent() {
117 1 1. newEvent : replaced return of long value with value + 1 for org/graphstream/graph/implementations/AbstractNode::newEvent → NO_COVERAGE
		return graph.newEvent();
118
	}
119
120
	@Override
121
	/**
122
	 * This implementation calls the corresponding method of the parent graph
123
	 * 
124
	 * @see org.graphstream.graph.implementations.AbstractElement#nullAttributesAreErrors()
125
	 */
126
	protected boolean nullAttributesAreErrors() {
127 1 1. nullAttributesAreErrors : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED
		return graph.nullAttributesAreErrors();
128
	}
129
130
	// *** Inherited from Node ***
131
132
	/**
133
	 * This implementation returns {@link #graph}.
134
	 * 
135
	 * @see org.graphstream.graph.Node#getGraph()
136
	 */
137
	public Graph getGraph() {
138 1 1. getGraph : mutated return of Object value for org/graphstream/graph/implementations/AbstractNode::getGraph to ( if (x != null) null else throw new RuntimeException ) → KILLED
		return graph;
139
	}
140
141
	public abstract int getDegree();
142
143
	public abstract int getInDegree();
144
145
	public abstract int getOutDegree();
146
147
	// [has|get]Edge[Toward|From|Between](Node|int|String) -> 2 * 3 * 3 = 18
148
	// methods
149
150
	/**
151
	 * This implementation returns {@code true} if {@link #getEdgeToward(Node)}
152
	 * is not {@code null}.
153
	 * 
154
	 * @see org.graphstream.graph.Node#getEdgeToward(org.graphstream.graph.Node)
155
	 */
156
	public boolean hasEdgeToward(Node node) {
157 3 1. hasEdgeToward : negated conditional → NO_COVERAGE
2. hasEdgeToward : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE
3. hasEdgeToward : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE
		return getEdgeToward(node) != null;
158
	}
159
160
	/**
161
	 * This implementation returns {@code true} if {@link #getEdgeToward(int)}
162
	 * is not {@code null}.
163
	 * 
164
	 * @see org.graphstream.graph.Node#hasEdgeToward(int)
165
	 */
166
	public boolean hasEdgeToward(int index) {
167 3 1. hasEdgeToward : negated conditional → NO_COVERAGE
2. hasEdgeToward : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE
3. hasEdgeToward : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE
		return getEdgeToward(index) != null;
168
	}
169
170
	/**
171
	 * This implementation returns {@code true} if {@link #getEdgeToward(Node)}
172
	 * is not {@code null}.
173
	 * 
174
	 * @see org.graphstream.graph.Node#hasEdgeToward(java.lang.String)
175
	 */
176
	public boolean hasEdgeToward(String id) {
177 3 1. hasEdgeToward : negated conditional → NO_COVERAGE
2. hasEdgeToward : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE
3. hasEdgeToward : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE
		return getEdgeToward(id) != null;
178
	}
179
180
	/**
181
	 * This implementation returns {@code true} if {@link #getEdgeFrom(Node)} is
182
	 * not {@code null}.
183
	 * 
184
	 * @see org.graphstream.graph.Node#hasEdgeFrom(org.graphstream.graph.Node)
185
	 */
186
	public boolean hasEdgeFrom(Node node) {
187 3 1. hasEdgeFrom : negated conditional → NO_COVERAGE
2. hasEdgeFrom : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE
3. hasEdgeFrom : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE
		return getEdgeFrom(node) != null;
188
	}
189
190
	/**
191
	 * This implementation returns {@code true} if {@link #getEdgeFrom(int)} is
192
	 * not {@code null}.
193
	 * 
194
	 * @see org.graphstream.graph.Node#hasEdgeFrom(int)
195
	 */
196
	public boolean hasEdgeFrom(int index) {
197 3 1. hasEdgeFrom : negated conditional → NO_COVERAGE
2. hasEdgeFrom : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE
3. hasEdgeFrom : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE
		return getEdgeFrom(index) != null;
198
	}
199
200
	/**
201
	 * This implementation returns {@code true} if {@link #getEdgeFrom(Node)} is
202
	 * not {@code null}.
203
	 * 
204
	 * @see org.graphstream.graph.Node#hasEdgeFrom(java.lang.String)
205
	 */
206
	public boolean hasEdgeFrom(String id) {
207 3 1. hasEdgeFrom : negated conditional → NO_COVERAGE
2. hasEdgeFrom : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE
3. hasEdgeFrom : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE
		return getEdgeFrom(id) != null;
208
	}
209
210
	/**
211
	 * This implementation returns {@code true} if {@link #getEdgeBetween(Node)}
212
	 * is not {@code null}.
213
	 * 
214
	 * @see org.graphstream.graph.Node#hasEdgeBetween(org.graphstream.graph.Node)
215
	 */
216
	public boolean hasEdgeBetween(Node node) {
217 3 1. hasEdgeBetween : negated conditional → NO_COVERAGE
2. hasEdgeBetween : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE
3. hasEdgeBetween : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE
		return getEdgeBetween(node) != null;
218
	}
219
220
	/**
221
	 * This implementation returns {@code true} if {@link #getEdgeBetween(int)}
222
	 * is not {@code null}.
223
	 * 
224
	 * @see org.graphstream.graph.Node#hasEdgeBetween(int)
225
	 */
226
	public boolean hasEdgeBetween(int index) {
227 3 1. hasEdgeBetween : negated conditional → NO_COVERAGE
2. hasEdgeBetween : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE
3. hasEdgeBetween : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE
		return getEdgeBetween(index) != null;
228
	}
229
230
	/**
231
	 * This implementation returns {@code true} if {@link #getEdgeBetween(Node)}
232
	 * is not {@code null}.
233
	 * 
234
	 * @see org.graphstream.graph.Node#hasEdgeBetween(java.lang.String)
235
	 */
236
	public boolean hasEdgeBetween(String id) {
237 3 1. hasEdgeBetween : negated conditional → NO_COVERAGE
2. hasEdgeBetween : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE
3. hasEdgeBetween : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE
		return getEdgeBetween(id) != null;
238
	}
239
240
	public abstract <T extends Edge> T getEdgeToward(Node node);
241
242
	/**
243
	 * This implementation uses {@link #getEdgeToward(Node)}
244
	 * 
245
	 * @see org.graphstream.graph.Node#getEdgeToward(int)
246
	 */
247
	public <T extends Edge> T getEdgeToward(int index) {
248 1 1. getEdgeToward : mutated return of Object value for org/graphstream/graph/implementations/AbstractNode::getEdgeToward to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
		return getEdgeToward(graph.getNode(index));
249
	}
250
251
	/**
252
	 * This implementation uses {@link #getEdgeToward(Node)}
253
	 * 
254
	 * @see org.graphstream.graph.Node#getEdgeToward(java.lang.String)
255
	 */
256
	public <T extends Edge> T getEdgeToward(String id) {
257 1 1. getEdgeToward : mutated return of Object value for org/graphstream/graph/implementations/AbstractNode::getEdgeToward to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
		return getEdgeToward(graph.getNode(id));
258
	}
259
260
	public abstract <T extends Edge> T getEdgeFrom(Node node);
261
262
	/**
263
	 * This implementation uses {@link #getEdgeFrom(Node)}
264
	 * 
265
	 * @see org.graphstream.graph.Node#getEdgeFrom(int)
266
	 */
267
	public <T extends Edge> T getEdgeFrom(int index) {
268 1 1. getEdgeFrom : mutated return of Object value for org/graphstream/graph/implementations/AbstractNode::getEdgeFrom to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
		return getEdgeFrom(graph.getNode(index));
269
	}
270
271
	/**
272
	 * This implementation uses {@link #getEdgeFrom(Node)}
273
	 * 
274
	 * @see org.graphstream.graph.Node#getEdgeFrom(java.lang.String)
275
	 */
276
	public <T extends Edge> T getEdgeFrom(String id) {
277 1 1. getEdgeFrom : mutated return of Object value for org/graphstream/graph/implementations/AbstractNode::getEdgeFrom to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
		return getEdgeFrom(graph.getNode(id));
278
	}
279
280
	public abstract <T extends Edge> T getEdgeBetween(Node node);
281
282
	/**
283
	 * This implementation uses {@link #getEdgeBetween(Node)}
284
	 * 
285
	 * @see org.graphstream.graph.Node#getEdgeBetween(int)
286
	 */
287
	public <T extends Edge> T getEdgeBetween(int index) {
288 1 1. getEdgeBetween : mutated return of Object value for org/graphstream/graph/implementations/AbstractNode::getEdgeBetween to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
		return getEdgeBetween(graph.getNode(index));
289
	}
290
291
	/**
292
	 * This implementation uses {@link #getEdgeBetween(Node)}
293
	 * 
294
	 * @see org.graphstream.graph.Node#getEdgeBetween(java.lang.String)
295
	 */
296
	public <T extends Edge> T getEdgeBetween(String id) {
297 1 1. getEdgeBetween : mutated return of Object value for org/graphstream/graph/implementations/AbstractNode::getEdgeBetween to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
		return getEdgeBetween(graph.getNode(id));
298
	}
299
300
	// get[_|Entering|Leaving]EdgeIterator
301
302
	public abstract <T extends Edge> Iterator<T> getEdgeIterator();
303
304
	public abstract <T extends Edge> Iterator<T> getEnteringEdgeIterator();
305
306
	public abstract <T extends Edge> Iterator<T> getLeavingEdgeIterator();
307
308
	// getEach[_Entering|Leaving]Edge
309
310
	/**
311
	 * This implementation uses {@link #getEdgeIterator()}
312
	 * 
313
	 * @see org.graphstream.graph.Node#getEachEdge()
314
	 */
315
	public <T extends Edge> Iterable<T> getEachEdge() {
316 1 1. getEachEdge : mutated return of Object value for org/graphstream/graph/implementations/AbstractNode::getEachEdge to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
		return new Iterable<T>() {
317
			public Iterator<T> iterator() {
318 1 1. iterator : mutated return of Object value for org/graphstream/graph/implementations/AbstractNode$1::iterator to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
				return getEdgeIterator();
319
			}
320
		};
321
	}
322
323
	/**
324
	 * This implementation uses {@link #getEnteringEdgeIterator()}
325
	 * 
326
	 * @see org.graphstream.graph.Node#getEachEnteringEdge()
327
	 */
328
	public <T extends Edge> Iterable<T> getEachEnteringEdge() {
329 1 1. getEachEnteringEdge : mutated return of Object value for org/graphstream/graph/implementations/AbstractNode::getEachEnteringEdge to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
		return new Iterable<T>() {
330
			public Iterator<T> iterator() {
331 1 1. iterator : mutated return of Object value for org/graphstream/graph/implementations/AbstractNode$2::iterator to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
				return getEnteringEdgeIterator();
332
			}
333
		};
334
	}
335
336
	/**
337
	 * This implementation uses {@link #getLeavingEdgeIterator()}
338
	 * 
339
	 * @see org.graphstream.graph.Node#getEachLeavingEdge()
340
	 */
341
	public <T extends Edge> Iterable<T> getEachLeavingEdge() {
342 1 1. getEachLeavingEdge : mutated return of Object value for org/graphstream/graph/implementations/AbstractNode::getEachLeavingEdge to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
		return new Iterable<T>() {
343
			public Iterator<T> iterator() {
344 1 1. iterator : mutated return of Object value for org/graphstream/graph/implementations/AbstractNode$3::iterator to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
				return getLeavingEdgeIterator();
345
			}
346
		};
347
	}
348
349
	// get[_|Entering|Leaving]EdgeSet
350
351
	/**
352
	 * This implementation uses {@link #getEdgeIterator()} and
353
	 * {@link #getDegree()}
354
	 * 
355
	 * @see org.graphstream.graph.Node#getEdgeSet()
356
	 */
357
	public <T extends Edge> Collection<T> getEdgeSet() {
358 1 1. getEdgeSet : mutated return of Object value for org/graphstream/graph/implementations/AbstractNode::getEdgeSet to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
		return new AbstractCollection<T>() {
359
			@Override
360
			public Iterator<T> iterator() {
361 1 1. iterator : mutated return of Object value for org/graphstream/graph/implementations/AbstractNode$4::iterator to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
				return getEdgeIterator();
362
			}
363
364
			@Override
365
			public int size() {
366 1 1. size : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE
				return getDegree();
367
			}
368
		};
369
	}
370
371
	/**
372
	 * This implementation uses {@link #getEnteringEdgeIterator()} and
373
	 * {@link #geIntDegree()}
374
	 * 
375
	 * @see org.graphstream.graph.Node#getEnteringEdgeSet()
376
	 */
377
	public <T extends Edge> Collection<T> getEnteringEdgeSet() {
378 1 1. getEnteringEdgeSet : mutated return of Object value for org/graphstream/graph/implementations/AbstractNode::getEnteringEdgeSet to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
		return new AbstractCollection<T>() {
379
			@Override
380
			public Iterator<T> iterator() {
381 1 1. iterator : mutated return of Object value for org/graphstream/graph/implementations/AbstractNode$5::iterator to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
				return getEnteringEdgeIterator();
382
			}
383
384
			@Override
385
			public int size() {
386 1 1. size : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE
				return getInDegree();
387
			}
388
		};
389
	}
390
391
	/**
392
	 * This implementation uses {@link #getLeavingIterator()} and
393
	 * {@link #geOuttDegree()}
394
	 * 
395
	 * @see org.graphstream.graph.Node#getLeavingEdgeSet()
396
	 */
397
	public <T extends Edge> Collection<T> getLeavingEdgeSet() {
398 1 1. getLeavingEdgeSet : mutated return of Object value for org/graphstream/graph/implementations/AbstractNode::getLeavingEdgeSet to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
		return new AbstractCollection<T>() {
399
			@Override
400
			public Iterator<T> iterator() {
401 1 1. iterator : mutated return of Object value for org/graphstream/graph/implementations/AbstractNode$6::iterator to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
				return getLeavingEdgeIterator();
402
			}
403
404
			@Override
405
			public int size() {
406 1 1. size : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE
				return getOutDegree();
407
			}
408
		};
409
	}
410
411
	/**
412
	 * This implementation uses {@link #getEdgeIterator()}
413
	 * 
414
	 * @see java.lang.Iterable#iterator()
415
	 */
416
	public Iterator<Edge> iterator() {
417 1 1. iterator : mutated return of Object value for org/graphstream/graph/implementations/AbstractNode::iterator to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
		return getEdgeIterator();
418
	}
419
420
	public abstract <T extends Edge> T getEdge(int i);
421
422
	public abstract <T extends Edge> T getEnteringEdge(int i);
423
424
	public abstract <T extends Edge> T getLeavingEdge(int i);
425
426
	/**
427
	 * This implementation uses {@link #getEdgeIterator()} and stores the
428
	 * visited nodes in a set. In this way it ensures that each neighbor will be
429
	 * visited exactly once, even in multi-graph.
430
	 * 
431
	 * @see org.graphstream.graph.Node#getNeighborNodeIterator()
432
	 */
433
	public <T extends Node> Iterator<T> getNeighborNodeIterator() {
434 1 1. getNeighborNodeIterator : mutated return of Object value for org/graphstream/graph/implementations/AbstractNode::getNeighborNodeIterator to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
		return new Iterator<T>() {
435
			Iterator<Edge> edgeIt = getEdgeIterator();
436
			HashSet<T> visited = new HashSet<T>(getDegree());
437
			T next;
438
			{
439 1 1. : removed call to org/graphstream/graph/implementations/AbstractNode$7::gotoNext → NO_COVERAGE
				gotoNext();
440
			}
441
442
			private void gotoNext() {
443 1 1. gotoNext : negated conditional → NO_COVERAGE
				while (edgeIt.hasNext()) {
444
					next = edgeIt.next().getOpposite(AbstractNode.this);
445 1 1. gotoNext : negated conditional → NO_COVERAGE
					if (!visited.contains(next)) {
446
						visited.add(next);
447
						return;
448
					}
449
				}
450
				next = null;
451
			}
452
453
			public boolean hasNext() {
454 3 1. hasNext : negated conditional → NO_COVERAGE
2. hasNext : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE
3. hasNext : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE
				return next != null;
455
			}
456
457
			public T next() {
458 1 1. next : negated conditional → NO_COVERAGE
				if (next == null)
459
					throw new NoSuchElementException();
460
				T current = next;
461 1 1. next : removed call to org/graphstream/graph/implementations/AbstractNode$7::gotoNext → NO_COVERAGE
				gotoNext();
462 1 1. next : mutated return of Object value for org/graphstream/graph/implementations/AbstractNode$7::next to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
				return current;
463
			}
464
465
			public void remove() {
466
				throw new UnsupportedOperationException(
467
						"This iterator does not support remove");
468
469
			}
470
471
			// Iterator<Edge> edgeIterator = getEdgeIterator();
472
			//
473
			// public boolean hasNext() {
474
			// return edgeIterator.hasNext();
475
			// }
476
			//
477
			// public T next() {
478
			// return edgeIterator.next().getOpposite(AbstractNode.this);
479
			// }
480
			//
481
			// public void remove() {
482
			// throw new UnsupportedOperationException(
483
			// "This iterator does not support remove");
484
			// }
485
		};
486
	}
487
488
	// breadth- and depth-first iterator
489
490
	/**
491
	 * This implementation creates an instance of
492
	 * {@link org.graphstream.graph#BreadthFirstIterator} and returns it.
493
	 * 
494
	 * @see org.graphstream.graph.Node#getBreadthFirstIterator()
495
	 */
496
	public <T extends Node> Iterator<T> getBreadthFirstIterator() {
497
		// XXX change it when the old iterator disappears
498
		// XXX change the return type to have access to the other methods
499 1 1. getBreadthFirstIterator : mutated return of Object value for org/graphstream/graph/implementations/AbstractNode::getBreadthFirstIterator to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
		return new BreadthFirstIterator<T>(this);
500
	}
501
502
	/**
503
	 * This implementation creates an instance of
504
	 * {@link org.graphstream.graph#BreadthFirstIterator} and returns it.
505
	 * 
506
	 * @see org.graphstream.graph.Node#getBreadthFirstIterator(boolean)
507
	 */
508
	public <T extends Node> Iterator<T> getBreadthFirstIterator(boolean directed) {
509
		// XXX change it when the old iterator disappears
510
		// XXX change the return type to have access to the other methods
511 1 1. getBreadthFirstIterator : mutated return of Object value for org/graphstream/graph/implementations/AbstractNode::getBreadthFirstIterator to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
		return new BreadthFirstIterator<T>(this, directed);
512
	}
513
514
	/**
515
	 * This implementation creates an instance of
516
	 * {@link org.graphstream.graph#DepthFirstIterator} and returns it.
517
	 * 
518
	 * @see org.graphstream.graph.Node#getDepthFirstIterator()
519
	 */
520
	public <T extends Node> Iterator<T> getDepthFirstIterator() {
521
		// XXX change it when the old iterator disappears
522
		// XXX change the return type to have access to the other methods
523 1 1. getDepthFirstIterator : mutated return of Object value for org/graphstream/graph/implementations/AbstractNode::getDepthFirstIterator to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
		return new DepthFirstIterator<T>(this);
524
	}
525
526
	/**
527
	 * This implementation creates an instance of
528
	 * {@link org.graphstream.graph#DepthFirstIterator} and returns it.
529
	 * 
530
	 * @see org.graphstream.graph.Node#getDepthFirstIterator(boolean)
531
	 */
532
	public <T extends Node> Iterator<T> getDepthFirstIterator(boolean directed) {
533
		// XXX change it when the old iterator disappears
534
		// XXX change the return type to have access to the other methods
535 1 1. getDepthFirstIterator : mutated return of Object value for org/graphstream/graph/implementations/AbstractNode::getDepthFirstIterator to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
		return new DepthFirstIterator<T>(this, directed);
536
	}
537
538
	// *** Other methods ***
539
540
	/**
541
	 * This method is called automatically when an edge incident to this node is
542
	 * created. Subclasses use it to add the edge to their data structure.
543
	 * 
544
	 * @param edge
545
	 *            a new edge incident to this node
546
	 */
547
	protected abstract boolean addEdgeCallback(AbstractEdge edge);
548
549
	/**
550
	 * This method is called automatically before removing an edge incident to
551
	 * this node. Subclasses use it to remove the edge from their data
552
	 * structure.
553
	 * 
554
	 * @param edge
555
	 *            an edge incident to this node that will be removed
556
	 */
557
	protected abstract void removeEdgeCallback(AbstractEdge edge);
558
559
	/**
560
	 * This method is called for each node when the graph is cleared. Subclasses
561
	 * may use it to clear their data structures in order to facilitate the
562
	 * garbage collection.
563
	 */
564
	protected abstract void clearCallback();
565
566
	/**
567
	 * Checks if an edge enters this node. Utility method that can be useful in
568
	 * subclasses.
569
	 * 
570
	 * @param e
571
	 *            an edge
572
	 * @return {@code true} if {@code e} is entering edge for this node.
573
	 */
574
	public boolean isEnteringEdge(Edge e) {
575 3 1. isEnteringEdge : negated conditional → NO_COVERAGE
2. isEnteringEdge : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE
3. isEnteringEdge : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE
		return e.getTargetNode() == this
576 2 1. isEnteringEdge : negated conditional → NO_COVERAGE
2. isEnteringEdge : negated conditional → NO_COVERAGE
				|| (!e.isDirected() && e.getSourceNode() == this);
577
	}
578
579
	/**
580
	 * Checks if an edge leaves this node. Utility method that can be useful in
581
	 * subclasses.
582
	 * 
583
	 * @param e
584
	 *            an edge
585
	 * @return {@code true} if {@code e} is leaving edge for this node.
586
	 */
587
	public boolean isLeavingEdge(Edge e) {
588 3 1. isLeavingEdge : negated conditional → NO_COVERAGE
2. isLeavingEdge : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE
3. isLeavingEdge : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE
		return e.getSourceNode() == this
589 2 1. isLeavingEdge : negated conditional → NO_COVERAGE
2. isLeavingEdge : negated conditional → NO_COVERAGE
				|| (!e.isDirected() && e.getTargetNode() == this);
590
	}
591
592
	/**
593
	 * Checks if an edge is incident to this node. Utility method that can be
594
	 * useful in subclasses.
595
	 * 
596
	 * @param e
597
	 *            an edge
598
	 * @return {@code true} if {@code e} is incident edge for this node.
599
	 */
600
	public boolean isIncidentEdge(Edge e) {
601 4 1. isIncidentEdge : negated conditional → NO_COVERAGE
2. isIncidentEdge : negated conditional → NO_COVERAGE
3. isIncidentEdge : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE
4. isIncidentEdge : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE
		return e.getSourceNode() == this || e.getTargetNode() == this;
602
	}
603
}

Mutations

95

1.1
Location : attributeChanged
Killed by : none
removed call to org/graphstream/graph/implementations/AbstractGraph$GraphListeners::sendAttributeChangedEvent → SURVIVED

107

1.1
Location : myGraphId
Killed by : none
mutated return of Object value for org/graphstream/graph/implementations/AbstractNode::myGraphId to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE

117

1.1
Location : newEvent
Killed by : none
replaced return of long value with value + 1 for org/graphstream/graph/implementations/AbstractNode::newEvent → NO_COVERAGE

127

1.1
Location : nullAttributesAreErrors
Killed by : org.graphstream.graph.implementations.AbstractGraphTest.nodeAttributeRemovedTest(org.graphstream.graph.implementations.AbstractGraphTest)
replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED

138

1.1
Location : getGraph
Killed by : org.graphstream.graph.implementations.AbstractGraphTest.edgeAttributeAddedTest(org.graphstream.graph.implementations.AbstractGraphTest)
mutated return of Object value for org/graphstream/graph/implementations/AbstractNode::getGraph to ( if (x != null) null else throw new RuntimeException ) → KILLED

157

1.1
Location : hasEdgeToward
Killed by : none
negated conditional → NO_COVERAGE

2.2
Location : hasEdgeToward
Killed by : none
replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE

3.3
Location : hasEdgeToward
Killed by : none
replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE

167

1.1
Location : hasEdgeToward
Killed by : none
negated conditional → NO_COVERAGE

2.2
Location : hasEdgeToward
Killed by : none
replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE

3.3
Location : hasEdgeToward
Killed by : none
replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE

177

1.1
Location : hasEdgeToward
Killed by : none
negated conditional → NO_COVERAGE

2.2
Location : hasEdgeToward
Killed by : none
replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE

3.3
Location : hasEdgeToward
Killed by : none
replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE

187

1.1
Location : hasEdgeFrom
Killed by : none
negated conditional → NO_COVERAGE

2.2
Location : hasEdgeFrom
Killed by : none
replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE

3.3
Location : hasEdgeFrom
Killed by : none
replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE

197

1.1
Location : hasEdgeFrom
Killed by : none
negated conditional → NO_COVERAGE

2.2
Location : hasEdgeFrom
Killed by : none
replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE

3.3
Location : hasEdgeFrom
Killed by : none
replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE

207

1.1
Location : hasEdgeFrom
Killed by : none
negated conditional → NO_COVERAGE

2.2
Location : hasEdgeFrom
Killed by : none
replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE

3.3
Location : hasEdgeFrom
Killed by : none
replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE

217

1.1
Location : hasEdgeBetween
Killed by : none
negated conditional → NO_COVERAGE

2.2
Location : hasEdgeBetween
Killed by : none
replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE

3.3
Location : hasEdgeBetween
Killed by : none
replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE

227

1.1
Location : hasEdgeBetween
Killed by : none
negated conditional → NO_COVERAGE

2.2
Location : hasEdgeBetween
Killed by : none
replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE

3.3
Location : hasEdgeBetween
Killed by : none
replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE

237

1.1
Location : hasEdgeBetween
Killed by : none
negated conditional → NO_COVERAGE

2.2
Location : hasEdgeBetween
Killed by : none
replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE

3.3
Location : hasEdgeBetween
Killed by : none
replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE

248

1.1
Location : getEdgeToward
Killed by : none
mutated return of Object value for org/graphstream/graph/implementations/AbstractNode::getEdgeToward to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE

257

1.1
Location : getEdgeToward
Killed by : none
mutated return of Object value for org/graphstream/graph/implementations/AbstractNode::getEdgeToward to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE

268

1.1
Location : getEdgeFrom
Killed by : none
mutated return of Object value for org/graphstream/graph/implementations/AbstractNode::getEdgeFrom to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE

277

1.1
Location : getEdgeFrom
Killed by : none
mutated return of Object value for org/graphstream/graph/implementations/AbstractNode::getEdgeFrom to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE

288

1.1
Location : getEdgeBetween
Killed by : none
mutated return of Object value for org/graphstream/graph/implementations/AbstractNode::getEdgeBetween to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE

297

1.1
Location : getEdgeBetween
Killed by : none
mutated return of Object value for org/graphstream/graph/implementations/AbstractNode::getEdgeBetween to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE

316

1.1
Location : getEachEdge
Killed by : none
mutated return of Object value for org/graphstream/graph/implementations/AbstractNode::getEachEdge to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE

318

1.1
Location : iterator
Killed by : none
mutated return of Object value for org/graphstream/graph/implementations/AbstractNode$1::iterator to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE

329

1.1
Location : getEachEnteringEdge
Killed by : none
mutated return of Object value for org/graphstream/graph/implementations/AbstractNode::getEachEnteringEdge to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE

331

1.1
Location : iterator
Killed by : none
mutated return of Object value for org/graphstream/graph/implementations/AbstractNode$2::iterator to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE

342

1.1
Location : getEachLeavingEdge
Killed by : none
mutated return of Object value for org/graphstream/graph/implementations/AbstractNode::getEachLeavingEdge to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE

344

1.1
Location : iterator
Killed by : none
mutated return of Object value for org/graphstream/graph/implementations/AbstractNode$3::iterator to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE

358

1.1
Location : getEdgeSet
Killed by : none
mutated return of Object value for org/graphstream/graph/implementations/AbstractNode::getEdgeSet to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE

361

1.1
Location : iterator
Killed by : none
mutated return of Object value for org/graphstream/graph/implementations/AbstractNode$4::iterator to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE

366

1.1
Location : size
Killed by : none
replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE

378

1.1
Location : getEnteringEdgeSet
Killed by : none
mutated return of Object value for org/graphstream/graph/implementations/AbstractNode::getEnteringEdgeSet to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE

381

1.1
Location : iterator
Killed by : none
mutated return of Object value for org/graphstream/graph/implementations/AbstractNode$5::iterator to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE

386

1.1
Location : size
Killed by : none
replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE

398

1.1
Location : getLeavingEdgeSet
Killed by : none
mutated return of Object value for org/graphstream/graph/implementations/AbstractNode::getLeavingEdgeSet to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE

401

1.1
Location : iterator
Killed by : none
mutated return of Object value for org/graphstream/graph/implementations/AbstractNode$6::iterator to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE

406

1.1
Location : size
Killed by : none
replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE

417

1.1
Location : iterator
Killed by : none
mutated return of Object value for org/graphstream/graph/implementations/AbstractNode::iterator to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE

434

1.1
Location : getNeighborNodeIterator
Killed by : none
mutated return of Object value for org/graphstream/graph/implementations/AbstractNode::getNeighborNodeIterator to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE

439

1.1
Location :
Killed by : none
removed call to org/graphstream/graph/implementations/AbstractNode$7::gotoNext → NO_COVERAGE

443

1.1
Location : gotoNext
Killed by : none
negated conditional → NO_COVERAGE

445

1.1
Location : gotoNext
Killed by : none
negated conditional → NO_COVERAGE

454

1.1
Location : hasNext
Killed by : none
negated conditional → NO_COVERAGE

2.2
Location : hasNext
Killed by : none
replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE

3.3
Location : hasNext
Killed by : none
replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE

458

1.1
Location : next
Killed by : none
negated conditional → NO_COVERAGE

461

1.1
Location : next
Killed by : none
removed call to org/graphstream/graph/implementations/AbstractNode$7::gotoNext → NO_COVERAGE

462

1.1
Location : next
Killed by : none
mutated return of Object value for org/graphstream/graph/implementations/AbstractNode$7::next to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE

499

1.1
Location : getBreadthFirstIterator
Killed by : none
mutated return of Object value for org/graphstream/graph/implementations/AbstractNode::getBreadthFirstIterator to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE

511

1.1
Location : getBreadthFirstIterator
Killed by : none
mutated return of Object value for org/graphstream/graph/implementations/AbstractNode::getBreadthFirstIterator to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE

523

1.1
Location : getDepthFirstIterator
Killed by : none
mutated return of Object value for org/graphstream/graph/implementations/AbstractNode::getDepthFirstIterator to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE

535

1.1
Location : getDepthFirstIterator
Killed by : none
mutated return of Object value for org/graphstream/graph/implementations/AbstractNode::getDepthFirstIterator to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE

575

1.1
Location : isEnteringEdge
Killed by : none
negated conditional → NO_COVERAGE

2.2
Location : isEnteringEdge
Killed by : none
replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE

3.3
Location : isEnteringEdge
Killed by : none
replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE

576

1.1
Location : isEnteringEdge
Killed by : none
negated conditional → NO_COVERAGE

2.2
Location : isEnteringEdge
Killed by : none
negated conditional → NO_COVERAGE

588

1.1
Location : isLeavingEdge
Killed by : none
negated conditional → NO_COVERAGE

2.2
Location : isLeavingEdge
Killed by : none
replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE

3.3
Location : isLeavingEdge
Killed by : none
replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE

589

1.1
Location : isLeavingEdge
Killed by : none
negated conditional → NO_COVERAGE

2.2
Location : isLeavingEdge
Killed by : none
negated conditional → NO_COVERAGE

601

1.1
Location : isIncidentEdge
Killed by : none
negated conditional → NO_COVERAGE

2.2
Location : isIncidentEdge
Killed by : none
negated conditional → NO_COVERAGE

3.3
Location : isIncidentEdge
Killed by : none
replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE

4.4
Location : isIncidentEdge
Killed by : none
replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT 0.33