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.io.IOException; | |
35 | import java.util.AbstractCollection; | |
36 | import java.util.Collection; | |
37 | import java.util.Iterator; | |
38 | ||
39 | import org.graphstream.graph.Edge; | |
40 | import org.graphstream.graph.EdgeFactory; | |
41 | import org.graphstream.graph.EdgeRejectedException; | |
42 | import org.graphstream.graph.ElementNotFoundException; | |
43 | import org.graphstream.graph.Graph; | |
44 | import org.graphstream.graph.IdAlreadyInUseException; | |
45 | import org.graphstream.graph.Node; | |
46 | import org.graphstream.graph.NodeFactory; | |
47 | import org.graphstream.stream.AttributeSink; | |
48 | import org.graphstream.stream.ElementSink; | |
49 | import org.graphstream.stream.GraphParseException; | |
50 | import org.graphstream.stream.Pipe; | |
51 | import org.graphstream.stream.Replayable; | |
52 | import org.graphstream.stream.Sink; | |
53 | import org.graphstream.stream.SourceBase; | |
54 | import org.graphstream.stream.file.FileSink; | |
55 | import org.graphstream.stream.file.FileSinkFactory; | |
56 | import org.graphstream.stream.file.FileSource; | |
57 | import org.graphstream.stream.file.FileSourceFactory; | |
58 | import org.graphstream.stream.sync.SinkTime; | |
59 | ||
60 | /** | |
61 | * <p> | |
62 | * This class provides a basic implementation of | |
63 | * {@link org.graphstream.graph.Graph} interface, to minimize the effort | |
64 | * required to implement this interface. It provides event management | |
65 | * implementing all the methods of {@link org.graphstream.stream.Pipe}. It also | |
66 | * manages strict checking and auto-creation policies, as well as other services | |
67 | * as displaying, reading and writing. | |
68 | * </p> | |
69 | * | |
70 | * <p> | |
71 | * Subclasses have to maintain data structures allowing to efficiently access | |
72 | * graph elements by their id or index and iterating on them. They also have to | |
73 | * maintain coherent indices of the graph elements. When AbstractGraph decides | |
74 | * to add or remove elements, it calls one of the "callbacks" | |
75 | * {@link #addNodeCallback(AbstractNode)}, | |
76 | * {@link #addEdgeCallback(AbstractEdge)}, | |
77 | * {@link #removeNodeCallback(AbstractNode)}, | |
78 | * {@link #removeEdgeCallback(AbstractEdge)}, {@link #clearCallback()}. The role | |
79 | * of these callbacks is to update the data structures and to re-index elements | |
80 | * if necessary. | |
81 | * </p> | |
82 | */ | |
83 | public abstract class AbstractGraph extends AbstractElement implements Graph, | |
84 | Replayable { | |
85 | // *** Fields *** | |
86 | ||
87 | private boolean strictChecking; | |
88 | private boolean autoCreate; | |
89 | GraphListeners listeners; | |
90 | private NodeFactory<? extends AbstractNode> nodeFactory; | |
91 | private EdgeFactory<? extends AbstractEdge> edgeFactory; | |
92 | ||
93 | private double step = 0; | |
94 | ||
95 | private boolean nullAttributesAreErrors; | |
96 | ||
97 | private long replayId = 0; | |
98 | ||
99 | // *** Constructors *** | |
100 | ||
101 | /** | |
102 | * The same as {@code AbstractGraph(id, true, false)} | |
103 | * | |
104 | * @param id | |
105 | * Identifier of the graph | |
106 | * @see #AbstractGraph(String, boolean, boolean) | |
107 | */ | |
108 | public AbstractGraph(String id) { | |
109 | this(id, true, false); | |
110 | } | |
111 | ||
112 | /** | |
113 | * Creates a new graph. Subclasses must create their node and edge factories | |
114 | * and initialize their data structures in their constructors. | |
115 | * | |
116 | * @param id | |
117 | * @param strictChecking | |
118 | * @param autoCreate | |
119 | */ | |
120 | public AbstractGraph(String id, boolean strictChecking, boolean autoCreate) { | |
121 | super(id); | |
122 | this.strictChecking = strictChecking; | |
123 | this.autoCreate = autoCreate; | |
124 | listeners = new GraphListeners(); | |
125 | } | |
126 | ||
127 | // *** Inherited from abstract element | |
128 | ||
129 | @Override | |
130 | protected void attributeChanged(String sourceId, long timeId, | |
131 | String attribute, AttributeChangeEvent event, Object oldValue, | |
132 | Object newValue) { | |
133 |
1
1. attributeChanged : removed call to org/graphstream/graph/implementations/AbstractGraph$GraphListeners::sendAttributeChangedEvent → SURVIVED |
listeners.sendAttributeChangedEvent(sourceId, timeId, id, |
134 | SourceBase.ElementType.GRAPH, attribute, event, oldValue, | |
135 | newValue); | |
136 | } | |
137 | ||
138 | @Override | |
139 | protected String myGraphId() { | |
140 |
1
1. myGraphId : mutated return of Object value for org/graphstream/graph/implementations/AbstractGraph::myGraphId to ( if (x != null) null else throw new RuntimeException ) → SURVIVED |
return getId(); |
141 | } | |
142 | ||
143 | @Override | |
144 | protected long newEvent() { | |
145 |
1
1. newEvent : replaced return of long value with value + 1 for org/graphstream/graph/implementations/AbstractGraph::newEvent → SURVIVED |
return listeners.newEvent(); |
146 | } | |
147 | ||
148 | @Override | |
149 | public boolean nullAttributesAreErrors() { | |
150 |
1
1. nullAttributesAreErrors : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED |
return nullAttributesAreErrors; |
151 | } | |
152 | ||
153 | // *** Inherited from graph *** | |
154 | ||
155 | // some helpers | |
156 | ||
157 | // get node / edge by its id/index | |
158 | ||
159 | public abstract <T extends Node> T getNode(String id); | |
160 | ||
161 | public abstract <T extends Node> T getNode(int index); | |
162 | ||
163 | public abstract <T extends Edge> T getEdge(String id); | |
164 | ||
165 | public abstract <T extends Edge> T getEdge(int index); | |
166 | ||
167 | // node and edge count, iterators and views | |
168 | ||
169 | public abstract int getNodeCount(); | |
170 | ||
171 | public abstract int getEdgeCount(); | |
172 | ||
173 | public abstract <T extends Node> Iterator<T> getNodeIterator(); | |
174 | ||
175 | public abstract <T extends Edge> Iterator<T> getEdgeIterator(); | |
176 | ||
177 | /** | |
178 | * This implementation uses {@link #getNodeIterator()} | |
179 | * | |
180 | * @see org.graphstream.graph.Graph#getEachNode() | |
181 | */ | |
182 | public <T extends Node> Iterable<? extends T> getEachNode() { | |
183 |
1
1. getEachNode : mutated return of Object value for org/graphstream/graph/implementations/AbstractGraph::getEachNode to ( if (x != null) null else throw new RuntimeException ) → KILLED |
return new Iterable<T>() { |
184 | public Iterator<T> iterator() { | |
185 |
1
1. iterator : mutated return of Object value for org/graphstream/graph/implementations/AbstractGraph$1::iterator to ( if (x != null) null else throw new RuntimeException ) → KILLED |
return getNodeIterator(); |
186 | } | |
187 | }; | |
188 | } | |
189 | ||
190 | /** | |
191 | * This implementation uses {@link #getEdgeIterator()} | |
192 | * | |
193 | * @see org.graphstream.graph.Graph#getEachEdge() | |
194 | */ | |
195 | public <T extends Edge> Iterable<? extends T> getEachEdge() { | |
196 |
1
1. getEachEdge : mutated return of Object value for org/graphstream/graph/implementations/AbstractGraph::getEachEdge to ( if (x != null) null else throw new RuntimeException ) → KILLED |
return new Iterable<T>() { |
197 | public Iterator<T> iterator() { | |
198 |
1
1. iterator : mutated return of Object value for org/graphstream/graph/implementations/AbstractGraph$2::iterator to ( if (x != null) null else throw new RuntimeException ) → KILLED |
return getEdgeIterator(); |
199 | } | |
200 | }; | |
201 | } | |
202 | ||
203 | /** | |
204 | * This implementation uses {@link #getNodeIterator()} and | |
205 | * {@link #getNodeCount()} | |
206 | * | |
207 | * @see org.graphstream.graph.Graph#getNodeSet() | |
208 | */ | |
209 | public <T extends Node> Collection<T> getNodeSet() { | |
210 |
1
1. getNodeSet : mutated return of Object value for org/graphstream/graph/implementations/AbstractGraph::getNodeSet to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return new AbstractCollection<T>() { |
211 | public Iterator<T> iterator() { | |
212 |
1
1. iterator : mutated return of Object value for org/graphstream/graph/implementations/AbstractGraph$3::iterator to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return getNodeIterator(); |
213 | } | |
214 | ||
215 | public int size() { | |
216 |
1
1. size : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return getNodeCount(); |
217 | } | |
218 | }; | |
219 | } | |
220 | ||
221 | /** | |
222 | * This implementation uses {@link #getEdgeIterator()} and | |
223 | * {@link #getEdgeCount()} | |
224 | * | |
225 | * @see org.graphstream.graph.Graph#getNodeSet() | |
226 | */ | |
227 | public <T extends Edge> Collection<T> getEdgeSet() { | |
228 |
1
1. getEdgeSet : mutated return of Object value for org/graphstream/graph/implementations/AbstractGraph::getEdgeSet to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return new AbstractCollection<T>() { |
229 | public Iterator<T> iterator() { | |
230 |
1
1. iterator : mutated return of Object value for org/graphstream/graph/implementations/AbstractGraph$4::iterator to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return getEdgeIterator(); |
231 | } | |
232 | ||
233 | public int size() { | |
234 |
1
1. size : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return getEdgeCount(); |
235 | } | |
236 | }; | |
237 | } | |
238 | ||
239 | /** | |
240 | * This implementation returns {@link #getNodeIterator()} | |
241 | * | |
242 | * @see java.lang.Iterable#iterator() | |
243 | */ | |
244 | public Iterator<Node> iterator() { | |
245 |
1
1. iterator : mutated return of Object value for org/graphstream/graph/implementations/AbstractGraph::iterator to ( if (x != null) null else throw new RuntimeException ) → KILLED |
return getNodeIterator(); |
246 | } | |
247 | ||
248 | // Factories | |
249 | ||
250 | public NodeFactory<? extends Node> nodeFactory() { | |
251 |
1
1. nodeFactory : mutated return of Object value for org/graphstream/graph/implementations/AbstractGraph::nodeFactory to ( if (x != null) null else throw new RuntimeException ) → KILLED |
return nodeFactory; |
252 | } | |
253 | ||
254 | public EdgeFactory<? extends Edge> edgeFactory() { | |
255 |
1
1. edgeFactory : mutated return of Object value for org/graphstream/graph/implementations/AbstractGraph::edgeFactory to ( if (x != null) null else throw new RuntimeException ) → KILLED |
return edgeFactory; |
256 | } | |
257 | ||
258 | @SuppressWarnings("unchecked") | |
259 | public void setNodeFactory(NodeFactory<? extends Node> nf) { | |
260 | nodeFactory = (NodeFactory<? extends AbstractNode>) nf; | |
261 | } | |
262 | ||
263 | @SuppressWarnings("unchecked") | |
264 | public void setEdgeFactory(EdgeFactory<? extends Edge> ef) { | |
265 | edgeFactory = (EdgeFactory<? extends AbstractEdge>) ef; | |
266 | } | |
267 | ||
268 | // strict checking, autocreation, etc | |
269 | ||
270 | public boolean isStrict() { | |
271 |
1
1. isStrict : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED |
return strictChecking; |
272 | } | |
273 | ||
274 | public boolean isAutoCreationEnabled() { | |
275 |
1
1. isAutoCreationEnabled : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED |
return autoCreate; |
276 | } | |
277 | ||
278 | public double getStep() { | |
279 |
1
1. getStep : replaced return of double value with -(x + 1) for org/graphstream/graph/implementations/AbstractGraph::getStep → KILLED |
return step; |
280 | } | |
281 | ||
282 | public void setNullAttributesAreErrors(boolean on) { | |
283 | nullAttributesAreErrors = on; | |
284 | } | |
285 | ||
286 | public void setStrict(boolean on) { | |
287 | strictChecking = on; | |
288 | } | |
289 | ||
290 | public void setAutoCreate(boolean on) { | |
291 | autoCreate = on; | |
292 | } | |
293 | ||
294 | public void stepBegins(double time) { | |
295 |
1
1. stepBegins : removed call to org/graphstream/graph/implementations/AbstractGraph::stepBegins_ → SURVIVED |
stepBegins_(getId(), -1, time); |
296 | } | |
297 | ||
298 | // adding and removing elements | |
299 | ||
300 | public void clear() { | |
301 |
1
1. clear : removed call to org/graphstream/graph/implementations/AbstractGraph::clear_ → NO_COVERAGE |
clear_(getId(), -1); |
302 | } | |
303 | ||
304 | public <T extends Node> T addNode(String id) { | |
305 |
1
1. addNode : mutated return of Object value for org/graphstream/graph/implementations/AbstractGraph::addNode to ( if (x != null) null else throw new RuntimeException ) → KILLED |
return addNode_(getId(), -1, id); |
306 | } | |
307 | ||
308 | public <T extends Edge> T addEdge(String id, String node1, String node2) { | |
309 |
1
1. addEdge : mutated return of Object value for org/graphstream/graph/implementations/AbstractGraph::addEdge to ( if (x != null) null else throw new RuntimeException ) → KILLED |
return addEdge(id, node1, node2, false); |
310 | } | |
311 | ||
312 | public <T extends Edge> T addEdge(String id, String from, String to, | |
313 | boolean directed) { | |
314 |
1
1. addEdge : mutated return of Object value for org/graphstream/graph/implementations/AbstractGraph::addEdge to ( if (x != null) null else throw new RuntimeException ) → KILLED |
return addEdge_(getId(), -1, id, (AbstractNode) getNode(from), from, |
315 | (AbstractNode) getNode(to), to, directed); | |
316 | } | |
317 | ||
318 | public <T extends Edge> T addEdge(String id, int index1, int index2) { | |
319 |
1
1. addEdge : mutated return of Object value for org/graphstream/graph/implementations/AbstractGraph::addEdge to ( if (x != null) null else throw new RuntimeException ) → KILLED |
return addEdge(id, index1, index2, false); |
320 | } | |
321 | ||
322 | public <T extends Edge> T addEdge(String id, int fromIndex, int toIndex, | |
323 | boolean directed) { | |
324 |
1
1. addEdge : mutated return of Object value for org/graphstream/graph/implementations/AbstractGraph::addEdge to ( if (x != null) null else throw new RuntimeException ) → KILLED |
return addEdge(id, getNode(fromIndex), getNode(toIndex), directed); |
325 | } | |
326 | ||
327 | public <T extends Edge> T addEdge(String id, Node node1, Node node2) { | |
328 |
1
1. addEdge : mutated return of Object value for org/graphstream/graph/implementations/AbstractGraph::addEdge to ( if (x != null) null else throw new RuntimeException ) → KILLED |
return addEdge(id, node1, node2, false); |
329 | } | |
330 | ||
331 | public <T extends Edge> T addEdge(String id, Node from, Node to, | |
332 | boolean directed) { | |
333 |
1
1. addEdge : mutated return of Object value for org/graphstream/graph/implementations/AbstractGraph::addEdge to ( if (x != null) null else throw new RuntimeException ) → KILLED |
return addEdge_(getId(), -1, id, (AbstractNode) from, from.getId(), |
334 | (AbstractNode) to, to.getId(), directed); | |
335 | } | |
336 | ||
337 | public <T extends Node> T removeNode(String id) { | |
338 |
1
1. removeNode : mutated return of Object value for org/graphstream/graph/implementations/AbstractGraph::removeNode to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return removeNode_(getId(), -1, (AbstractNode) getNode(id), id, true); |
339 | } | |
340 | ||
341 | public <T extends Node> T removeNode(int index) { | |
342 | Node node = getNode(index); | |
343 |
1
1. removeNode : mutated return of Object value for org/graphstream/graph/implementations/AbstractGraph::removeNode to ( if (x != null) null else throw new RuntimeException ) → KILLED |
return removeNode(node); |
344 | } | |
345 | ||
346 | public <T extends Node> T removeNode(Node node) { | |
347 |
1
1. removeNode : mutated return of Object value for org/graphstream/graph/implementations/AbstractGraph::removeNode to ( if (x != null) null else throw new RuntimeException ) → KILLED |
return removeNode_(getId(), -1, (AbstractNode) node, |
348 |
1
1. removeNode : negated conditional → KILLED |
node == null ? null : node.getId(), true); |
349 | } | |
350 | ||
351 | public <T extends Edge> T removeEdge(String id) { | |
352 |
1
1. removeEdge : mutated return of Object value for org/graphstream/graph/implementations/AbstractGraph::removeEdge to ( if (x != null) null else throw new RuntimeException ) → KILLED |
return removeEdge_(getId(), -1, (AbstractEdge) getEdge(id), id, true, |
353 | true, true); | |
354 | } | |
355 | ||
356 | public <T extends Edge> T removeEdge(int index) { | |
357 | Edge edge = getEdge(index); | |
358 |
1
1. removeEdge : mutated return of Object value for org/graphstream/graph/implementations/AbstractGraph::removeEdge to ( if (x != null) null else throw new RuntimeException ) → SURVIVED |
return removeEdge(edge); |
359 | } | |
360 | ||
361 | public <T extends Edge> T removeEdge(Edge edge) { | |
362 |
1
1. removeEdge : mutated return of Object value for org/graphstream/graph/implementations/AbstractGraph::removeEdge to ( if (x != null) null else throw new RuntimeException ) → KILLED |
return removeEdge_(getId(), -1, (AbstractEdge) edge, |
363 |
1
1. removeEdge : negated conditional → KILLED |
edge == null ? null : edge.getId(), true, true, true); |
364 | } | |
365 | ||
366 | public <T extends Edge> T removeEdge(String from, String to) { | |
367 | Node fromNode = getNode(from); | |
368 | Node toNode = getNode(to); | |
369 | ||
370 |
1
1. removeEdge : negated conditional → KILLED |
if (fromNode == null ) { |
371 |
1
1. removeEdge : negated conditional → KILLED |
if (strictChecking) |
372 | throw new ElementNotFoundException( | |
373 | "Cannot remove the edge. The node \"%s\" does not exist", | |
374 |
1
1. removeEdge : negated conditional → SURVIVED |
fromNode == null ? from : to); |
375 |
1
1. removeEdge : mutated return of Object value for org/graphstream/graph/implementations/AbstractGraph::removeEdge to ( if (x != null) null else throw new RuntimeException ) → KILLED |
return null; |
376 | } | |
377 | ||
378 |
1
1. removeEdge : mutated return of Object value for org/graphstream/graph/implementations/AbstractGraph::removeEdge to ( if (x != null) null else throw new RuntimeException ) → SURVIVED |
return removeEdge(fromNode, toNode); |
379 | } | |
380 | ||
381 | public <T extends Edge> T removeEdge(int fromIndex, int toIndex) { | |
382 | Node fromNode = getNode(fromIndex); | |
383 | Node toNode = getNode(toIndex); | |
384 | | |
385 |
1
1. removeEdge : mutated return of Object value for org/graphstream/graph/implementations/AbstractGraph::removeEdge to ( if (x != null) null else throw new RuntimeException ) → SURVIVED |
return removeEdge(fromNode, toNode); |
386 | } | |
387 | ||
388 | public <T extends Edge> T removeEdge(Node node1, Node node2) { | |
389 | AbstractEdge edge = node1.getEdgeToward(node2); | |
390 | ||
391 |
1
1. removeEdge : negated conditional → KILLED |
if (edge == null) { |
392 |
1
1. removeEdge : negated conditional → KILLED |
if (strictChecking) |
393 | throw new ElementNotFoundException( | |
394 | "There is no edge from \"%s\" to \"%s\". Cannot remove it.", | |
395 | node1.getId(), node2.getId()); | |
396 |
1
1. removeEdge : mutated return of Object value for org/graphstream/graph/implementations/AbstractGraph::removeEdge to ( if (x != null) null else throw new RuntimeException ) → KILLED |
return null; |
397 | } | |
398 | ||
399 |
1
1. removeEdge : mutated return of Object value for org/graphstream/graph/implementations/AbstractGraph::removeEdge to ( if (x != null) null else throw new RuntimeException ) → SURVIVED |
return removeEdge_(id, -1, edge, edge.getId(), true, true, true); |
400 | } | |
401 | ||
402 | // *** Sinks, sources etc. *** | |
403 | ||
404 | public Iterable<AttributeSink> attributeSinks() { | |
405 |
1
1. attributeSinks : mutated return of Object value for org/graphstream/graph/implementations/AbstractGraph::attributeSinks to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return listeners.attributeSinks(); |
406 | } | |
407 | ||
408 | public Iterable<ElementSink> elementSinks() { | |
409 |
1
1. elementSinks : mutated return of Object value for org/graphstream/graph/implementations/AbstractGraph::elementSinks to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return listeners.elementSinks(); |
410 | } | |
411 | ||
412 | public void addAttributeSink(AttributeSink sink) { | |
413 |
1
1. addAttributeSink : removed call to org/graphstream/graph/implementations/AbstractGraph$GraphListeners::addAttributeSink → NO_COVERAGE |
listeners.addAttributeSink(sink); |
414 | } | |
415 | ||
416 | public void addElementSink(ElementSink sink) { | |
417 |
1
1. addElementSink : removed call to org/graphstream/graph/implementations/AbstractGraph$GraphListeners::addElementSink → NO_COVERAGE |
listeners.addElementSink(sink); |
418 | } | |
419 | ||
420 | public void addSink(Sink sink) { | |
421 |
1
1. addSink : removed call to org/graphstream/graph/implementations/AbstractGraph$GraphListeners::addSink → KILLED |
listeners.addSink(sink); |
422 | } | |
423 | ||
424 | public void clearAttributeSinks() { | |
425 |
1
1. clearAttributeSinks : removed call to org/graphstream/graph/implementations/AbstractGraph$GraphListeners::clearAttributeSinks → NO_COVERAGE |
listeners.clearAttributeSinks(); |
426 | } | |
427 | ||
428 | public void clearElementSinks() { | |
429 |
1
1. clearElementSinks : removed call to org/graphstream/graph/implementations/AbstractGraph$GraphListeners::clearElementSinks → NO_COVERAGE |
listeners.clearElementSinks(); |
430 | } | |
431 | ||
432 | public void clearSinks() { | |
433 |
1
1. clearSinks : removed call to org/graphstream/graph/implementations/AbstractGraph$GraphListeners::clearSinks → NO_COVERAGE |
listeners.clearSinks(); |
434 | } | |
435 | ||
436 | public void removeAttributeSink(AttributeSink sink) { | |
437 |
1
1. removeAttributeSink : removed call to org/graphstream/graph/implementations/AbstractGraph$GraphListeners::removeAttributeSink → NO_COVERAGE |
listeners.removeAttributeSink(sink); |
438 | } | |
439 | ||
440 | public void removeElementSink(ElementSink sink) { | |
441 |
1
1. removeElementSink : removed call to org/graphstream/graph/implementations/AbstractGraph$GraphListeners::removeElementSink → NO_COVERAGE |
listeners.removeElementSink(sink); |
442 | } | |
443 | ||
444 | public void removeSink(Sink sink) { | |
445 |
1
1. removeSink : removed call to org/graphstream/graph/implementations/AbstractGraph$GraphListeners::removeSink → NO_COVERAGE |
listeners.removeSink(sink); |
446 | } | |
447 | ||
448 | public void edgeAttributeAdded(String sourceId, long timeId, String edgeId, | |
449 | String attribute, Object value) { | |
450 | listeners | |
451 |
1
1. edgeAttributeAdded : removed call to org/graphstream/graph/implementations/AbstractGraph$GraphListeners::edgeAttributeAdded → KILLED |
.edgeAttributeAdded(sourceId, timeId, edgeId, attribute, value); |
452 | } | |
453 | ||
454 | public void edgeAttributeChanged(String sourceId, long timeId, | |
455 | String edgeId, String attribute, Object oldValue, Object newValue) { | |
456 |
1
1. edgeAttributeChanged : removed call to org/graphstream/graph/implementations/AbstractGraph$GraphListeners::edgeAttributeChanged → KILLED |
listeners.edgeAttributeChanged(sourceId, timeId, edgeId, attribute, |
457 | oldValue, newValue); | |
458 | } | |
459 | ||
460 | public void edgeAttributeRemoved(String sourceId, long timeId, | |
461 | String edgeId, String attribute) { | |
462 |
1
1. edgeAttributeRemoved : removed call to org/graphstream/graph/implementations/AbstractGraph$GraphListeners::edgeAttributeRemoved → SURVIVED |
listeners.edgeAttributeRemoved(sourceId, timeId, edgeId, attribute); |
463 | } | |
464 | ||
465 | public void graphAttributeAdded(String sourceId, long timeId, | |
466 | String attribute, Object value) { | |
467 |
1
1. graphAttributeAdded : removed call to org/graphstream/graph/implementations/AbstractGraph$GraphListeners::graphAttributeAdded → KILLED |
listeners.graphAttributeAdded(sourceId, timeId, attribute, value); |
468 | } | |
469 | ||
470 | public void graphAttributeChanged(String sourceId, long timeId, | |
471 | String attribute, Object oldValue, Object newValue) { | |
472 |
1
1. graphAttributeChanged : removed call to org/graphstream/graph/implementations/AbstractGraph$GraphListeners::graphAttributeChanged → KILLED |
listeners.graphAttributeChanged(sourceId, timeId, attribute, oldValue, |
473 | newValue); | |
474 | } | |
475 | ||
476 | public void graphAttributeRemoved(String sourceId, long timeId, | |
477 | String attribute) { | |
478 |
1
1. graphAttributeRemoved : removed call to org/graphstream/graph/implementations/AbstractGraph$GraphListeners::graphAttributeRemoved → KILLED |
listeners.graphAttributeRemoved(sourceId, timeId, attribute); |
479 | } | |
480 | ||
481 | public void nodeAttributeAdded(String sourceId, long timeId, String nodeId, | |
482 | String attribute, Object value) { | |
483 | listeners | |
484 |
1
1. nodeAttributeAdded : removed call to org/graphstream/graph/implementations/AbstractGraph$GraphListeners::nodeAttributeAdded → KILLED |
.nodeAttributeAdded(sourceId, timeId, nodeId, attribute, value); |
485 | } | |
486 | ||
487 | public void nodeAttributeChanged(String sourceId, long timeId, | |
488 | String nodeId, String attribute, Object oldValue, Object newValue) { | |
489 |
1
1. nodeAttributeChanged : removed call to org/graphstream/graph/implementations/AbstractGraph$GraphListeners::nodeAttributeChanged → KILLED |
listeners.nodeAttributeChanged(sourceId, timeId, nodeId, attribute, |
490 | oldValue, newValue); | |
491 | } | |
492 | ||
493 | public void nodeAttributeRemoved(String sourceId, long timeId, | |
494 | String nodeId, String attribute) { | |
495 |
1
1. nodeAttributeRemoved : removed call to org/graphstream/graph/implementations/AbstractGraph$GraphListeners::nodeAttributeRemoved → KILLED |
listeners.nodeAttributeRemoved(sourceId, timeId, nodeId, attribute); |
496 | } | |
497 | ||
498 | public void edgeAdded(String sourceId, long timeId, String edgeId, | |
499 | String fromNodeId, String toNodeId, boolean directed) { | |
500 |
1
1. edgeAdded : removed call to org/graphstream/graph/implementations/AbstractGraph$GraphListeners::edgeAdded → KILLED |
listeners.edgeAdded(sourceId, timeId, edgeId, fromNodeId, toNodeId, |
501 | directed); | |
502 | } | |
503 | ||
504 | public void edgeRemoved(String sourceId, long timeId, String edgeId) { | |
505 |
1
1. edgeRemoved : removed call to org/graphstream/graph/implementations/AbstractGraph$GraphListeners::edgeRemoved → KILLED |
listeners.edgeRemoved(sourceId, timeId, edgeId); |
506 | } | |
507 | ||
508 | public void graphCleared(String sourceId, long timeId) { | |
509 |
1
1. graphCleared : removed call to org/graphstream/graph/implementations/AbstractGraph$GraphListeners::graphCleared → KILLED |
listeners.graphCleared(sourceId, timeId); |
510 | } | |
511 | ||
512 | public void nodeAdded(String sourceId, long timeId, String nodeId) { | |
513 |
1
1. nodeAdded : removed call to org/graphstream/graph/implementations/AbstractGraph$GraphListeners::nodeAdded → KILLED |
listeners.nodeAdded(sourceId, timeId, nodeId); |
514 | } | |
515 | ||
516 | public void nodeRemoved(String sourceId, long timeId, String nodeId) { | |
517 |
1
1. nodeRemoved : removed call to org/graphstream/graph/implementations/AbstractGraph$GraphListeners::nodeRemoved → KILLED |
listeners.nodeRemoved(sourceId, timeId, nodeId); |
518 | } | |
519 | ||
520 | public void stepBegins(String sourceId, long timeId, double step) { | |
521 |
1
1. stepBegins : removed call to org/graphstream/graph/implementations/AbstractGraph$GraphListeners::stepBegins → SURVIVED |
listeners.stepBegins(sourceId, timeId, step); |
522 | } | |
523 | ||
524 | public void read(FileSource input, String filename) throws IOException, | |
525 | GraphParseException { | |
526 |
1
1. read : removed call to org/graphstream/stream/file/FileSource::readAll → NO_COVERAGE |
input.readAll(filename); |
527 | } | |
528 | ||
529 | public void read(String filename) throws IOException, GraphParseException, | |
530 | ElementNotFoundException { | |
531 | FileSource input = FileSourceFactory.sourceFor(filename); | |
532 |
1
1. read : negated conditional → NO_COVERAGE |
if (input != null) { |
533 |
1
1. read : removed call to org/graphstream/stream/file/FileSource::addSink → NO_COVERAGE |
input.addSink(this); |
534 |
1
1. read : removed call to org/graphstream/graph/implementations/AbstractGraph::read → NO_COVERAGE |
read(input, filename); |
535 |
1
1. read : removed call to org/graphstream/stream/file/FileSource::removeSink → NO_COVERAGE |
input.removeSink(this); |
536 | } else { | |
537 | throw new IOException("No source reader for " + filename); | |
538 | } | |
539 | } | |
540 | ||
541 | public void write(FileSink output, String filename) throws IOException { | |
542 |
1
1. write : removed call to org/graphstream/stream/file/FileSink::writeAll → NO_COVERAGE |
output.writeAll(this, filename); |
543 | } | |
544 | ||
545 | public void write(String filename) throws IOException { | |
546 | FileSink output = FileSinkFactory.sinkFor(filename); | |
547 |
1
1. write : negated conditional → NO_COVERAGE |
if (output != null) { |
548 |
1
1. write : removed call to org/graphstream/graph/implementations/AbstractGraph::write → NO_COVERAGE |
write(output, filename); |
549 | } else { | |
550 | throw new IOException("No sink writer for " + filename); | |
551 | } | |
552 | } | |
553 | ||
554 | /* | |
555 | * (non-Javadoc) | |
556 | * | |
557 | * @see org.graphstream.stream.Replayable#getReplayController() | |
558 | */ | |
559 | public Replayable.Controller getReplayController() { | |
560 |
1
1. getReplayController : mutated return of Object value for org/graphstream/graph/implementations/AbstractGraph::getReplayController to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return new GraphReplayController(); |
561 | } | |
562 | ||
563 | // *** callbacks maintaining user's data structure | |
564 | ||
565 | /** | |
566 | * This method is automatically called when a new node is created. | |
567 | * Subclasses must add the new node to their data structure and to set its | |
568 | * index correctly. | |
569 | * | |
570 | * @param node | |
571 | * the node to be added | |
572 | */ | |
573 | protected abstract void addNodeCallback(AbstractNode node); | |
574 | ||
575 | /** | |
576 | * This method is automatically called when a new edge is created. | |
577 | * Subclasses must add the new edge to their data structure and to set its | |
578 | * index correctly. | |
579 | * | |
580 | * @param edge | |
581 | * the edge to be added | |
582 | */ | |
583 | protected abstract void addEdgeCallback(AbstractEdge edge); | |
584 | ||
585 | /** | |
586 | * This method is automatically called when a node is removed. Subclasses | |
587 | * must remove the node from their data structures and to re-index other | |
588 | * node(s) so that node indices remain coherent. | |
589 | * | |
590 | * @param node | |
591 | * the node to be removed | |
592 | */ | |
593 | protected abstract void removeNodeCallback(AbstractNode node); | |
594 | ||
595 | /** | |
596 | * This method is automatically called when an edge is removed. Subclasses | |
597 | * must remove the edge from their data structures and re-index other | |
598 | * edge(s) so that edge indices remain coherent. | |
599 | * | |
600 | * @param edge | |
601 | * the edge to be removed | |
602 | */ | |
603 | protected abstract void removeEdgeCallback(AbstractEdge edge); | |
604 | ||
605 | /** | |
606 | * This method is automatically called when the graph is cleared. Subclasses | |
607 | * must remove all the nodes and all the edges from their data structures. | |
608 | */ | |
609 | protected abstract void clearCallback(); | |
610 | ||
611 | // *** _ methods *** | |
612 | ||
613 | @SuppressWarnings("unchecked") | |
614 | protected <T extends Node> T addNode_(String sourceId, long timeId, | |
615 | String nodeId) { | |
616 | AbstractNode node = getNode(nodeId); | |
617 |
1
1. addNode_ : negated conditional → KILLED |
if (node != null) { |
618 |
1
1. addNode_ : negated conditional → KILLED |
if (strictChecking) |
619 | throw new IdAlreadyInUseException("id \"" + nodeId | |
620 | + "\" already in use. Cannot create a node."); | |
621 |
1
1. addNode_ : mutated return of Object value for org/graphstream/graph/implementations/AbstractGraph::addNode_ to ( if (x != null) null else throw new RuntimeException ) → KILLED |
return (T) node; |
622 | } | |
623 | node = nodeFactory.newInstance(nodeId, this); | |
624 |
1
1. addNode_ : removed call to org/graphstream/graph/implementations/AbstractGraph::addNodeCallback → KILLED |
addNodeCallback(node); |
625 | // If the event comes from the graph itself, create timeId | |
626 |
1
1. addNode_ : negated conditional → SURVIVED |
if (timeId == -1) |
627 | timeId = newEvent(); | |
628 |
1
1. addNode_ : removed call to org/graphstream/graph/implementations/AbstractGraph$GraphListeners::sendNodeAdded → SURVIVED |
listeners.sendNodeAdded(sourceId, timeId, nodeId); |
629 |
1
1. addNode_ : mutated return of Object value for org/graphstream/graph/implementations/AbstractGraph::addNode_ to ( if (x != null) null else throw new RuntimeException ) → KILLED |
return (T) node; |
630 | } | |
631 | ||
632 | // Why do we pass both the ids and the references of the endpoints here? | |
633 | // When the caller knows the references it's stupid to call getNode(id) | |
634 | // here. If the node does not exist the reference will be null. | |
635 | // And if autoCreate is on, we need also the id. Sad but true! | |
636 | @SuppressWarnings("unchecked") | |
637 | protected <T extends Edge> T addEdge_(String sourceId, long timeId, | |
638 | String edgeId, AbstractNode src, String srcId, AbstractNode dst, | |
639 | String dstId, boolean directed) { | |
640 | AbstractEdge edge = getEdge(edgeId); | |
641 |
1
1. addEdge_ : negated conditional → KILLED |
if (edge != null) { |
642 |
1
1. addEdge_ : negated conditional → KILLED |
if (strictChecking) |
643 | throw new IdAlreadyInUseException("id \"" + edgeId | |
644 | + "\" already in use. Cannot create an edge."); | |
645 |
2
1. addEdge_ : negated conditional → KILLED 2. addEdge_ : negated conditional → KILLED |
if ((edge.getSourceNode() == src && edge.getTargetNode() == dst) |
646 |
2
1. addEdge_ : negated conditional → KILLED 2. addEdge_ : negated conditional → KILLED |
|| (!directed && edge.getTargetNode() == src && edge |
647 |
1
1. addEdge_ : negated conditional → KILLED |
.getSourceNode() == dst)) |
648 |
1
1. addEdge_ : mutated return of Object value for org/graphstream/graph/implementations/AbstractGraph::addEdge_ to ( if (x != null) null else throw new RuntimeException ) → KILLED |
return (T) edge; |
649 |
1
1. addEdge_ : mutated return of Object value for org/graphstream/graph/implementations/AbstractGraph::addEdge_ to ( if (x != null) null else throw new RuntimeException ) → KILLED |
return null; |
650 | } | |
651 | ||
652 |
2
1. addEdge_ : negated conditional → KILLED 2. addEdge_ : negated conditional → KILLED |
if (src == null || dst == null) { |
653 |
1
1. addEdge_ : negated conditional → KILLED |
if (strictChecking) |
654 | throw new ElementNotFoundException( | |
655 | String.format( | |
656 | "Cannot create edge %s[%s-%s%s]. Node '%s' does not exist.", | |
657 |
1
1. addEdge_ : negated conditional → SURVIVED |
edgeId, srcId, directed ? ">" : "-", dstId, |
658 |
1
1. addEdge_ : negated conditional → SURVIVED |
src == null ? srcId : dstId)); |
659 |
1
1. addEdge_ : negated conditional → KILLED |
if (!autoCreate) |
660 |
1
1. addEdge_ : mutated return of Object value for org/graphstream/graph/implementations/AbstractGraph::addEdge_ to ( if (x != null) null else throw new RuntimeException ) → KILLED |
return null; |
661 |
1
1. addEdge_ : negated conditional → KILLED |
if (src == null) |
662 | src = addNode(srcId); | |
663 |
1
1. addEdge_ : negated conditional → KILLED |
if (dst == null) |
664 | dst = addNode(dstId); | |
665 | } | |
666 | // at this point edgeId is not in use and both src and dst are not null | |
667 | edge = edgeFactory.newInstance(edgeId, src, dst, directed); | |
668 | // see if the endpoints accept the edge | |
669 |
1
1. addEdge_ : negated conditional → KILLED |
if (!src.addEdgeCallback(edge)) { |
670 |
1
1. addEdge_ : negated conditional → KILLED |
if (strictChecking) |
671 | throw new EdgeRejectedException("Edge " + edge | |
672 | + " was rejected by node " + src); | |
673 |
1
1. addEdge_ : mutated return of Object value for org/graphstream/graph/implementations/AbstractGraph::addEdge_ to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return null; |
674 | } | |
675 | // note that for loop edges the callback is called only once | |
676 |
2
1. addEdge_ : negated conditional → KILLED 2. addEdge_ : negated conditional → KILLED |
if (src != dst && !dst.addEdgeCallback(edge)) { |
677 | // the edge is accepted by src but rejected by dst | |
678 | // so we have to remove it from src | |
679 |
1
1. addEdge_ : removed call to org/graphstream/graph/implementations/AbstractNode::removeEdgeCallback → NO_COVERAGE |
src.removeEdgeCallback(edge); |
680 |
1
1. addEdge_ : negated conditional → NO_COVERAGE |
if (strictChecking) |
681 | throw new EdgeRejectedException("Edge " + edge | |
682 | + " was rejected by node " + dst); | |
683 |
1
1. addEdge_ : mutated return of Object value for org/graphstream/graph/implementations/AbstractGraph::addEdge_ to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return null; |
684 | } | |
685 | // now we can finally add it | |
686 |
1
1. addEdge_ : removed call to org/graphstream/graph/implementations/AbstractGraph::addEdgeCallback → KILLED |
addEdgeCallback(edge); |
687 | // If the event comes from the graph itself, create timeId | |
688 |
1
1. addEdge_ : negated conditional → SURVIVED |
if (timeId == -1) |
689 | timeId = newEvent(); | |
690 |
1
1. addEdge_ : removed call to org/graphstream/graph/implementations/AbstractGraph$GraphListeners::sendEdgeAdded → SURVIVED |
listeners.sendEdgeAdded(sourceId, timeId, edgeId, srcId, dstId, |
691 | directed); | |
692 |
1
1. addEdge_ : mutated return of Object value for org/graphstream/graph/implementations/AbstractGraph::addEdge_ to ( if (x != null) null else throw new RuntimeException ) → KILLED |
return (T) edge; |
693 | } | |
694 | ||
695 | @SuppressWarnings("unchecked") | |
696 | protected <T extends Node> T removeNode_(String sourceId, long timeId, | |
697 | AbstractNode node, String nodeId, boolean graphCallback) { | |
698 | ||
699 |
1
1. removeNode_ : negated conditional → KILLED |
if (node == null) { |
700 |
1
1. removeNode_ : negated conditional → KILLED |
if (strictChecking) |
701 | throw new ElementNotFoundException("Node \"" + nodeId | |
702 | + "\" not found. Cannot remove it."); | |
703 |
1
1. removeNode_ : mutated return of Object value for org/graphstream/graph/implementations/AbstractGraph::removeNode_ to ( if (x != null) null else throw new RuntimeException ) → KILLED |
return null; |
704 | } | |
705 | ||
706 |
1
1. removeNode_ : removed call to org/graphstream/graph/implementations/AbstractGraph::removeAllEdges → SURVIVED |
removeAllEdges(node); |
707 | ||
708 | // If the event comes from the graph itself, create timeId | |
709 |
1
1. removeNode_ : negated conditional → SURVIVED |
if (timeId == -1) |
710 | timeId = newEvent(); | |
711 |
1
1. removeNode_ : removed call to org/graphstream/graph/implementations/AbstractGraph$GraphListeners::sendNodeRemoved → SURVIVED |
listeners.sendNodeRemoved(sourceId, timeId, nodeId); |
712 | ||
713 |
1
1. removeNode_ : negated conditional → KILLED |
if (graphCallback) |
714 |
1
1. removeNode_ : removed call to org/graphstream/graph/implementations/AbstractGraph::removeNodeCallback → KILLED |
removeNodeCallback(node); |
715 | ||
716 |
1
1. removeNode_ : mutated return of Object value for org/graphstream/graph/implementations/AbstractGraph::removeNode_ to ( if (x != null) null else throw new RuntimeException ) → SURVIVED |
return (T) node; |
717 | } | |
718 | ||
719 | @SuppressWarnings("unchecked") | |
720 | protected <T extends Edge> T removeEdge_(String sourceId, long timeId, | |
721 | AbstractEdge edge, String edgeId, boolean graphCallback, | |
722 | boolean srcCallback, boolean dstCallback) { | |
723 |
1
1. removeEdge_ : negated conditional → KILLED |
if (edge == null) { |
724 |
1
1. removeEdge_ : negated conditional → KILLED |
if (strictChecking) |
725 | throw new ElementNotFoundException("Edge \"" + edgeId | |
726 | + "\" not found. Cannot remove it."); | |
727 |
1
1. removeEdge_ : mutated return of Object value for org/graphstream/graph/implementations/AbstractGraph::removeEdge_ to ( if (x != null) null else throw new RuntimeException ) → KILLED |
return null; |
728 | } | |
729 | ||
730 | AbstractNode src = edge.getSourceNode(); | |
731 | AbstractNode dst = edge.getTargetNode(); | |
732 | ||
733 | // If the event comes from the graph itself, create timeId | |
734 |
1
1. removeEdge_ : negated conditional → SURVIVED |
if (timeId == -1) |
735 | timeId = newEvent(); | |
736 |
1
1. removeEdge_ : removed call to org/graphstream/graph/implementations/AbstractGraph$GraphListeners::sendEdgeRemoved → SURVIVED |
listeners.sendEdgeRemoved(sourceId, timeId, edgeId); |
737 | ||
738 |
1
1. removeEdge_ : negated conditional → KILLED |
if (srcCallback) |
739 |
1
1. removeEdge_ : removed call to org/graphstream/graph/implementations/AbstractNode::removeEdgeCallback → SURVIVED |
src.removeEdgeCallback(edge); |
740 | // note that the callback is called only once for loop edges | |
741 |
2
1. removeEdge_ : negated conditional → SURVIVED 2. removeEdge_ : negated conditional → SURVIVED |
if (src != dst && dstCallback) |
742 |
1
1. removeEdge_ : removed call to org/graphstream/graph/implementations/AbstractNode::removeEdgeCallback → SURVIVED |
dst.removeEdgeCallback(edge); |
743 |
1
1. removeEdge_ : negated conditional → KILLED |
if (graphCallback) |
744 |
1
1. removeEdge_ : removed call to org/graphstream/graph/implementations/AbstractGraph::removeEdgeCallback → KILLED |
removeEdgeCallback(edge); |
745 | ||
746 |
1
1. removeEdge_ : mutated return of Object value for org/graphstream/graph/implementations/AbstractGraph::removeEdge_ to ( if (x != null) null else throw new RuntimeException ) → SURVIVED |
return (T) edge; |
747 | } | |
748 | ||
749 | protected void clear_(String sourceId, long timeId) { | |
750 | Iterator<AbstractNode> it = getNodeIterator(); | |
751 |
1
1. clear_ : negated conditional → SURVIVED |
while (it.hasNext()) |
752 |
1
1. clear_ : removed call to org/graphstream/graph/implementations/AbstractNode::clearCallback → SURVIVED |
it.next().clearCallback(); |
753 |
1
1. clear_ : removed call to org/graphstream/graph/implementations/AbstractGraph::clearCallback → KILLED |
clearCallback(); |
754 |
1
1. clear_ : removed call to org/graphstream/graph/implementations/AbstractGraph::clearAttributes → SURVIVED |
clearAttributes(); |
755 | // If the event comes from the graph itself, create timeId | |
756 |
1
1. clear_ : negated conditional → SURVIVED |
if (timeId == -1) |
757 | timeId = newEvent(); | |
758 |
1
1. clear_ : removed call to org/graphstream/graph/implementations/AbstractGraph$GraphListeners::sendGraphCleared → SURVIVED |
listeners.sendGraphCleared(sourceId, timeId); |
759 | } | |
760 | ||
761 | protected void stepBegins_(String sourceId, long timeId, double step) { | |
762 | this.step = step; | |
763 | // If the event comes from the graph itself, create timeId | |
764 |
1
1. stepBegins_ : negated conditional → SURVIVED |
if (timeId == -1) |
765 | timeId = newEvent(); | |
766 |
1
1. stepBegins_ : removed call to org/graphstream/graph/implementations/AbstractGraph$GraphListeners::sendStepBegins → SURVIVED |
listeners.sendStepBegins(sourceId, timeId, step); |
767 | } | |
768 | ||
769 | // helper for removeNode_ | |
770 | private void removeAllEdges(AbstractNode node) { | |
771 | // first check if the EdgeIterator of node supports remove | |
772 | // if this is the case, we will use it, generally it will be much more | |
773 | // efficient | |
774 | Iterator<AbstractEdge> edgeIt = node.getEdgeIterator(); | |
775 | boolean supportsRemove = true; | |
776 | try { | |
777 | edgeIt.next(); | |
778 |
1
1. removeAllEdges : removed call to java/util/Iterator::remove → SURVIVED |
edgeIt.remove(); |
779 | } catch (UnsupportedOperationException e) { | |
780 | supportsRemove = false; | |
781 | } | |
782 |
1
1. removeAllEdges : negated conditional → SURVIVED |
if (supportsRemove) |
783 |
1
1. removeAllEdges : negated conditional → KILLED |
while (edgeIt.hasNext()) { |
784 | edgeIt.next(); | |
785 |
1
1. removeAllEdges : removed call to java/util/Iterator::remove → NO_COVERAGE |
edgeIt.remove(); |
786 | } | |
787 | else | |
788 |
2
1. removeAllEdges : changed conditional boundary → NO_COVERAGE 2. removeAllEdges : negated conditional → NO_COVERAGE |
while (node.getDegree() > 0) |
789 | removeEdge(node.getEdge(0)); | |
790 | } | |
791 | ||
792 | // *** Methods for iterators *** | |
793 | ||
794 | /** | |
795 | * This method is similar to {@link #removeNode(Node)} but allows to control | |
796 | * if {@link #removeNodeCallback(AbstractNode)} is called or not. It is | |
797 | * useful for iterators supporting {@link java.util.Iterator#remove()} who | |
798 | * want to update the data structures by their owns. | |
799 | * | |
800 | * @param node | |
801 | * the node to be removed | |
802 | * @param graphCallback | |
803 | * if {@code false}, {@code removeNodeCallback(node)} is not | |
804 | * called | |
805 | */ | |
806 | protected void removeNode(AbstractNode node, boolean graphCallback) { | |
807 | removeNode_(id, -1, node, node.getId(), graphCallback); | |
808 | } | |
809 | ||
810 | /** | |
811 | * This method is similar to {@link #removeEdge(Edge)} but allows to control | |
812 | * if different callbacks are called or not. It is useful for iterators | |
813 | * supporting {@link java.util.Iterator#remove()} who want to update the | |
814 | * data structures by their owns. | |
815 | * | |
816 | * @param edge | |
817 | * the edge to be removed | |
818 | * @param graphCallback | |
819 | * if {@code false}, {@link #removeEdgeCallback(AbstractEdge)} of | |
820 | * the graph is not called | |
821 | * @param sourceCallback | |
822 | * if {@code false}, | |
823 | * {@link AbstractNode#removeEdgeCallback(AbstractEdge)} is not | |
824 | * called for the source node of the edge | |
825 | * @param targetCallback | |
826 | * if {@code false}, | |
827 | * {@link AbstractNode#removeEdgeCallback(AbstractEdge)} is not | |
828 | * called for the target node of the edge | |
829 | */ | |
830 | protected void removeEdge(AbstractEdge edge, boolean graphCallback, | |
831 | boolean sourceCallback, boolean targetCallback) { | |
832 | removeEdge_(id, -1, edge, edge.getId(), graphCallback, sourceCallback, | |
833 | targetCallback); | |
834 | } | |
835 | ||
836 | class GraphReplayController extends SourceBase implements | |
837 | Replayable.Controller { | |
838 | GraphReplayController() { | |
839 | super(AbstractGraph.this.id + "replay"); | |
840 | } | |
841 | ||
842 | /* | |
843 | * (non-Javadoc) | |
844 | * | |
845 | * @see org.graphstream.stream.Replayable.Controller#replay() | |
846 | */ | |
847 | public void replay() { | |
848 |
2
1. replay : Replaced long addition with subtraction → NO_COVERAGE 2. replay : removed call to org/graphstream/graph/implementations/AbstractGraph::access$1 → NO_COVERAGE |
String sourceId = String.format("%s-replay-%x", id, replayId++); |
849 |
1
1. replay : removed call to org/graphstream/graph/implementations/AbstractGraph$GraphReplayController::replay → NO_COVERAGE |
replay(sourceId); |
850 | } | |
851 | ||
852 | /* | |
853 | * (non-Javadoc) | |
854 | * | |
855 | * @see | |
856 | * org.graphstream.stream.Replayable.Controller#replay(java.lang.String) | |
857 | */ | |
858 | public void replay(String sourceId) { | |
859 |
1
1. replay : negated conditional → NO_COVERAGE |
for (String key : getAttributeKeySet()) |
860 |
1
1. replay : removed call to org/graphstream/graph/implementations/AbstractGraph$GraphReplayController::sendGraphAttributeAdded → NO_COVERAGE |
sendGraphAttributeAdded(sourceId, key, getAttribute(key)); |
861 | ||
862 |
3
1. replay : changed conditional boundary → NO_COVERAGE 2. replay : Changed increment from 1 to -1 → NO_COVERAGE 3. replay : negated conditional → NO_COVERAGE |
for (int i = 0; i < getNodeCount(); i++) { |
863 | Node node = getNode(i); | |
864 | String nodeId = node.getId(); | |
865 | ||
866 |
1
1. replay : removed call to org/graphstream/graph/implementations/AbstractGraph$GraphReplayController::sendNodeAdded → NO_COVERAGE |
sendNodeAdded(sourceId, nodeId); |
867 | ||
868 |
2
1. replay : changed conditional boundary → NO_COVERAGE 2. replay : negated conditional → NO_COVERAGE |
if (node.getAttributeCount() > 0) |
869 |
1
1. replay : negated conditional → NO_COVERAGE |
for (String key : node.getAttributeKeySet()) |
870 |
1
1. replay : removed call to org/graphstream/graph/implementations/AbstractGraph$GraphReplayController::sendNodeAttributeAdded → NO_COVERAGE |
sendNodeAttributeAdded(sourceId, nodeId, key, |
871 | node.getAttribute(key)); | |
872 | } | |
873 | ||
874 |
3
1. replay : changed conditional boundary → NO_COVERAGE 2. replay : Changed increment from 1 to -1 → NO_COVERAGE 3. replay : negated conditional → NO_COVERAGE |
for (int i = 0; i < getEdgeCount(); i++) { |
875 | Edge edge = getEdge(i); | |
876 | String edgeId = edge.getId(); | |
877 | ||
878 |
1
1. replay : removed call to org/graphstream/graph/implementations/AbstractGraph$GraphReplayController::sendEdgeAdded → NO_COVERAGE |
sendEdgeAdded(sourceId, edgeId, edge.getNode0().getId(), edge |
879 | .getNode1().getId(), edge.isDirected()); | |
880 | ||
881 |
2
1. replay : changed conditional boundary → NO_COVERAGE 2. replay : negated conditional → NO_COVERAGE |
if (edge.getAttributeCount() > 0) |
882 |
1
1. replay : negated conditional → NO_COVERAGE |
for (String key : edge.getAttributeKeySet()) |
883 |
1
1. replay : removed call to org/graphstream/graph/implementations/AbstractGraph$GraphReplayController::sendEdgeAttributeAdded → NO_COVERAGE |
sendEdgeAttributeAdded(sourceId, edgeId, key, |
884 | edge.getAttribute(key)); | |
885 | } | |
886 | } | |
887 | } | |
888 | ||
889 | // *** Listeners *** | |
890 | ||
891 | // Handling the listeners -- We use the IO2 InputBase for this. | |
892 | ||
893 | class GraphListeners extends SourceBase implements Pipe { | |
894 | SinkTime sinkTime; | |
895 | ||
896 | public GraphListeners() { | |
897 | super(getId()); | |
898 | ||
899 | sinkTime = new SinkTime(); | |
900 |
1
1. |
sourceTime.setSinkTime(sinkTime); |
901 | } | |
902 | ||
903 | public long newEvent() { | |
904 |
1
1. newEvent : replaced return of long value with value + 1 for org/graphstream/graph/implementations/AbstractGraph$GraphListeners::newEvent → SURVIVED |
return sourceTime.newEvent(); |
905 | } | |
906 | ||
907 | public void edgeAttributeAdded(String sourceId, long timeId, | |
908 | String edgeId, String attribute, Object value) { | |
909 |
1
1. edgeAttributeAdded : negated conditional → KILLED |
if (sinkTime.isNewEvent(sourceId, timeId)) { |
910 | AbstractEdge edge = getEdge(edgeId); | |
911 |
1
1. edgeAttributeAdded : negated conditional → KILLED |
if (edge != null) |
912 |
1
1. edgeAttributeAdded : removed call to org/graphstream/graph/implementations/AbstractEdge::addAttribute_ → KILLED |
edge.addAttribute_(sourceId, timeId, attribute, value); |
913 | } | |
914 | } | |
915 | ||
916 | public void edgeAttributeChanged(String sourceId, long timeId, | |
917 | String edgeId, String attribute, Object oldValue, | |
918 | Object newValue) { | |
919 |
1
1. edgeAttributeChanged : negated conditional → KILLED |
if (sinkTime.isNewEvent(sourceId, timeId)) { |
920 | AbstractEdge edge = getEdge(edgeId); | |
921 |
1
1. edgeAttributeChanged : negated conditional → KILLED |
if (edge != null) |
922 |
1
1. edgeAttributeChanged : removed call to org/graphstream/graph/implementations/AbstractEdge::changeAttribute_ → KILLED |
edge.changeAttribute_(sourceId, timeId, attribute, newValue); |
923 | } | |
924 | } | |
925 | ||
926 | public void edgeAttributeRemoved(String sourceId, long timeId, | |
927 | String edgeId, String attribute) { | |
928 |
1
1. edgeAttributeRemoved : negated conditional → SURVIVED |
if (sinkTime.isNewEvent(sourceId, timeId)) { |
929 | AbstractEdge edge = getEdge(edgeId); | |
930 |
1
1. edgeAttributeRemoved : negated conditional → SURVIVED |
if (edge != null) |
931 |
1
1. edgeAttributeRemoved : removed call to org/graphstream/graph/implementations/AbstractEdge::removeAttribute_ → SURVIVED |
edge.removeAttribute_(sourceId, timeId, attribute); |
932 | } | |
933 | } | |
934 | ||
935 | public void graphAttributeAdded(String sourceId, long timeId, | |
936 | String attribute, Object value) { | |
937 |
1
1. graphAttributeAdded : negated conditional → KILLED |
if (sinkTime.isNewEvent(sourceId, timeId)) { |
938 |
1
1. graphAttributeAdded : removed call to org/graphstream/graph/implementations/AbstractGraph::addAttribute_ → KILLED |
addAttribute_(sourceId, timeId, attribute, value); |
939 | } | |
940 | } | |
941 | ||
942 | public void graphAttributeChanged(String sourceId, long timeId, | |
943 | String attribute, Object oldValue, Object newValue) { | |
944 |
1
1. graphAttributeChanged : negated conditional → KILLED |
if (sinkTime.isNewEvent(sourceId, timeId)) { |
945 |
1
1. graphAttributeChanged : removed call to org/graphstream/graph/implementations/AbstractGraph::changeAttribute_ → KILLED |
changeAttribute_(sourceId, timeId, attribute, newValue); |
946 | } | |
947 | } | |
948 | ||
949 | public void graphAttributeRemoved(String sourceId, long timeId, | |
950 | String attribute) { | |
951 |
1
1. graphAttributeRemoved : negated conditional → KILLED |
if (sinkTime.isNewEvent(sourceId, timeId)) { |
952 |
1
1. graphAttributeRemoved : removed call to org/graphstream/graph/implementations/AbstractGraph::removeAttribute_ → KILLED |
removeAttribute_(sourceId, timeId, attribute); |
953 | } | |
954 | } | |
955 | ||
956 | public void nodeAttributeAdded(String sourceId, long timeId, | |
957 | String nodeId, String attribute, Object value) { | |
958 |
1
1. nodeAttributeAdded : negated conditional → KILLED |
if (sinkTime.isNewEvent(sourceId, timeId)) { |
959 | AbstractNode node = getNode(nodeId); | |
960 |
1
1. nodeAttributeAdded : negated conditional → KILLED |
if (node != null) |
961 |
1
1. nodeAttributeAdded : removed call to org/graphstream/graph/implementations/AbstractNode::addAttribute_ → KILLED |
node.addAttribute_(sourceId, timeId, attribute, value); |
962 | } | |
963 | } | |
964 | ||
965 | public void nodeAttributeChanged(String sourceId, long timeId, | |
966 | String nodeId, String attribute, Object oldValue, | |
967 | Object newValue) { | |
968 |
1
1. nodeAttributeChanged : negated conditional → KILLED |
if (sinkTime.isNewEvent(sourceId, timeId)) { |
969 | AbstractNode node = getNode(nodeId); | |
970 |
1
1. nodeAttributeChanged : negated conditional → KILLED |
if (node != null) |
971 |
1
1. nodeAttributeChanged : removed call to org/graphstream/graph/implementations/AbstractNode::changeAttribute_ → KILLED |
node.changeAttribute_(sourceId, timeId, attribute, newValue); |
972 | } | |
973 | } | |
974 | ||
975 | public void nodeAttributeRemoved(String sourceId, long timeId, | |
976 | String nodeId, String attribute) { | |
977 |
1
1. nodeAttributeRemoved : negated conditional → KILLED |
if (sinkTime.isNewEvent(sourceId, timeId)) { |
978 | AbstractNode node = getNode(nodeId); | |
979 |
1
1. nodeAttributeRemoved : negated conditional → KILLED |
if (node != null) |
980 |
1
1. nodeAttributeRemoved : removed call to org/graphstream/graph/implementations/AbstractNode::removeAttribute_ → KILLED |
node.removeAttribute_(sourceId, timeId, attribute); |
981 | } | |
982 | } | |
983 | ||
984 | public void edgeAdded(String sourceId, long timeId, String edgeId, | |
985 | String fromNodeId, String toNodeId, boolean directed) { | |
986 |
1
1. edgeAdded : negated conditional → KILLED |
if (sinkTime.isNewEvent(sourceId, timeId)) { |
987 | AbstractNode from = getNode(fromNodeId); | |
988 | AbstractNode to = getNode(toNodeId); | |
989 | addEdge_(sourceId, timeId, edgeId, from, fromNodeId, to, | |
990 | toNodeId, directed); | |
991 | } | |
992 | } | |
993 | ||
994 | public void edgeRemoved(String sourceId, long timeId, String edgeId) { | |
995 |
1
1. edgeRemoved : negated conditional → KILLED |
if (sinkTime.isNewEvent(sourceId, timeId)) { |
996 | AbstractEdge edge = getEdge(edgeId); | |
997 | removeEdge_(sourceId, timeId, edge, edgeId, true, true, true); | |
998 | } | |
999 | } | |
1000 | ||
1001 | public void graphCleared(String sourceId, long timeId) { | |
1002 |
1
1. graphCleared : negated conditional → KILLED |
if (sinkTime.isNewEvent(sourceId, timeId)) { |
1003 |
1
1. graphCleared : removed call to org/graphstream/graph/implementations/AbstractGraph::clear_ → KILLED |
clear_(sourceId, timeId); |
1004 | } | |
1005 | } | |
1006 | ||
1007 | public void nodeAdded(String sourceId, long timeId, String nodeId) { | |
1008 |
1
1. nodeAdded : negated conditional → KILLED |
if (sinkTime.isNewEvent(sourceId, timeId)) { |
1009 | addNode_(sourceId, timeId, nodeId); | |
1010 | } | |
1011 | } | |
1012 | ||
1013 | public void nodeRemoved(String sourceId, long timeId, String nodeId) { | |
1014 |
1
1. nodeRemoved : negated conditional → KILLED |
if (sinkTime.isNewEvent(sourceId, timeId)) { |
1015 | AbstractNode node = getNode(nodeId); | |
1016 | removeNode_(sourceId, timeId, node, nodeId, true); | |
1017 | } | |
1018 | } | |
1019 | ||
1020 | public void stepBegins(String sourceId, long timeId, double step) { | |
1021 |
1
1. stepBegins : negated conditional → SURVIVED |
if (sinkTime.isNewEvent(sourceId, timeId)) { |
1022 |
1
1. stepBegins : removed call to org/graphstream/graph/implementations/AbstractGraph::stepBegins_ → SURVIVED |
stepBegins_(sourceId, timeId, step); |
1023 | } | |
1024 | } | |
1025 | } | |
1026 | } | |
Mutations | ||
133 |
1.1 |
|
140 |
1.1 |
|
145 |
1.1 |
|
150 |
1.1 |
|
183 |
1.1 |
|
185 |
1.1 |
|
196 |
1.1 |
|
198 |
1.1 |
|
210 |
1.1 |
|
212 |
1.1 |
|
216 |
1.1 |
|
228 |
1.1 |
|
230 |
1.1 |
|
234 |
1.1 |
|
245 |
1.1 |
|
251 |
1.1 |
|
255 |
1.1 |
|
271 |
1.1 |
|
275 |
1.1 |
|
279 |
1.1 |
|
295 |
1.1 |
|
301 |
1.1 |
|
305 |
1.1 |
|
309 |
1.1 |
|
314 |
1.1 |
|
319 |
1.1 |
|
324 |
1.1 |
|
328 |
1.1 |
|
333 |
1.1 |
|
338 |
1.1 |
|
343 |
1.1 |
|
347 |
1.1 |
|
348 |
1.1 |
|
352 |
1.1 |
|
358 |
1.1 |
|
362 |
1.1 |
|
363 |
1.1 |
|
370 |
1.1 |
|
371 |
1.1 |
|
374 |
1.1 |
|
375 |
1.1 |
|
378 |
1.1 |
|
385 |
1.1 |
|
391 |
1.1 |
|
392 |
1.1 |
|
396 |
1.1 |
|
399 |
1.1 |
|
405 |
1.1 |
|
409 |
1.1 |
|
413 |
1.1 |
|
417 |
1.1 |
|
421 |
1.1 |
|
425 |
1.1 |
|
429 |
1.1 |
|
433 |
1.1 |
|
437 |
1.1 |
|
441 |
1.1 |
|
445 |
1.1 |
|
451 |
1.1 |
|
456 |
1.1 |
|
462 |
1.1 |
|
467 |
1.1 |
|
472 |
1.1 |
|
478 |
1.1 |
|
484 |
1.1 |
|
489 |
1.1 |
|
495 |
1.1 |
|
500 |
1.1 |
|
505 |
1.1 |
|
509 |
1.1 |
|
513 |
1.1 |
|
517 |
1.1 |
|
521 |
1.1 |
|
526 |
1.1 |
|
532 |
1.1 |
|
533 |
1.1 |
|
534 |
1.1 |
|
535 |
1.1 |
|
542 |
1.1 |
|
547 |
1.1 |
|
548 |
1.1 |
|
560 |
1.1 |
|
617 |
1.1 |
|
618 |
1.1 |
|
621 |
1.1 |
|
624 |
1.1 |
|
626 |
1.1 |
|
628 |
1.1 |
|
629 |
1.1 |
|
641 |
1.1 |
|
642 |
1.1 |
|
645 |
1.1 2.2 |
|
646 |
1.1 2.2 |
|
647 |
1.1 |
|
648 |
1.1 |
|
649 |
1.1 |
|
652 |
1.1 2.2 |
|
653 |
1.1 |
|
657 |
1.1 |
|
658 |
1.1 |
|
659 |
1.1 |
|
660 |
1.1 |
|
661 |
1.1 |
|
663 |
1.1 |
|
669 |
1.1 |
|
670 |
1.1 |
|
673 |
1.1 |
|
676 |
1.1 2.2 |
|
679 |
1.1 |
|
680 |
1.1 |
|
683 |
1.1 |
|
686 |
1.1 |
|
688 |
1.1 |
|
690 |
1.1 |
|
692 |
1.1 |
|
699 |
1.1 |
|
700 |
1.1 |
|
703 |
1.1 |
|
706 |
1.1 |
|
709 |
1.1 |
|
711 |
1.1 |
|
713 |
1.1 |
|
714 |
1.1 |
|
716 |
1.1 |
|
723 |
1.1 |
|
724 |
1.1 |
|
727 |
1.1 |
|
734 |
1.1 |
|
736 |
1.1 |
|
738 |
1.1 |
|
739 |
1.1 |
|
741 |
1.1 2.2 |
|
742 |
1.1 |
|
743 |
1.1 |
|
744 |
1.1 |
|
746 |
1.1 |
|
751 |
1.1 |
|
752 |
1.1 |
|
753 |
1.1 |
|
754 |
1.1 |
|
756 |
1.1 |
|
758 |
1.1 |
|
764 |
1.1 |
|
766 |
1.1 |
|
778 |
1.1 |
|
782 |
1.1 |
|
783 |
1.1 |
|
785 |
1.1 |
|
788 |
1.1 2.2 |
|
848 |
1.1 2.2 |
|
849 |
1.1 |
|
859 |
1.1 |
|
860 |
1.1 |
|
862 |
1.1 2.2 3.3 |
|
866 |
1.1 |
|
868 |
1.1 2.2 |
|
869 |
1.1 |
|
870 |
1.1 |
|
874 |
1.1 2.2 3.3 |
|
878 |
1.1 |
|
881 |
1.1 2.2 |
|
882 |
1.1 |
|
883 |
1.1 |
|
900 |
1.1 |
|
904 |
1.1 |
|
909 |
1.1 |
|
911 |
1.1 |
|
912 |
1.1 |
|
919 |
1.1 |
|
921 |
1.1 |
|
922 |
1.1 |
|
928 |
1.1 |
|
930 |
1.1 |
|
931 |
1.1 |
|
937 |
1.1 |
|
938 |
1.1 |
|
944 |
1.1 |
|
945 |
1.1 |
|
951 |
1.1 |
|
952 |
1.1 |
|
958 |
1.1 |
|
960 |
1.1 |
|
961 |
1.1 |
|
968 |
1.1 |
|
970 |
1.1 |
|
971 |
1.1 |
|
977 |
1.1 |
|
979 |
1.1 |
|
980 |
1.1 |
|
986 |
1.1 |
|
995 |
1.1 |
|
1002 |
1.1 |
|
1003 |
1.1 |
|
1008 |
1.1 |
|
1014 |
1.1 |
|
1021 |
1.1 |
|
1022 |
1.1 |