GraphReplay.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.stream;
33
34
import org.graphstream.graph.Edge;
35
import org.graphstream.graph.Graph;
36
import org.graphstream.graph.Node;
37
38
/**
39
 * A simple source of graph events that takes an existing graph and creates a
40
 * flow of events by enumerating all nodes, edges and attributes of the graph.
41
 * 
42
 * <p>
43
 * The only method of this class is {@link #replay(Graph)} that takes a graph as
44
 * argument and :
45
 * <ul>
46
 * <li>First exports all graph attributes as attribute-addition events.</li>
47
 * <li>Then exports all nodes as node-creation events.
48
 * <ul>
49
 * <li>For each node exports all the node attributes as attribute-addition
50
 * events.</li>
51
 * </ul>
52
 * </li>
53
 * <li>Then exports all edges ad edge-creation events.
54
 * <ul>
55
 * <li>For each edge exports all the edge attribute as attribute-addition
56
 * events.</li>
57
 * </ul>
58
 * </li>
59
 * </ul>
60
 * In this order.
61
 * </p>
62
 * 
63
 * <p>
64
 * Note that this is a source, not a pipe. This means that it has its own
65
 * identifier and is a producer of "new" events. Also note that is does not
66
 * export the dynamics of the graph, only its structure at the present time (the
67
 * evolution of the graph is not stored in the graph, to produce a dynamic flow
68
 * of events of the evolution of a graph you have to register the sinks in the
69
 * graph itself just after its creation).
70
 * </p>
71
 */
72
public class GraphReplay extends SourceBase implements Source {
73
	public GraphReplay(String id) {
74
		super(id);
75
	}
76
77
	/**
78
	 * Echo each element and attribute of the graph to the registered sinks.
79
	 * 
80
	 * @param graph
81
	 *            The graph to export.
82
	 */
83
	public void replay(Graph graph) {
84 1 1. replay : negated conditional → NO_COVERAGE
		for (String key : graph.getAttributeKeySet())
85 1 1. replay : removed call to org/graphstream/stream/GraphReplay::sendGraphAttributeAdded → NO_COVERAGE
			sendGraphAttributeAdded(sourceId, key, graph.getAttribute(key));
86
87 1 1. replay : negated conditional → NO_COVERAGE
		for (Node node : graph) {
88
			String nodeId = node.getId();
89 1 1. replay : removed call to org/graphstream/stream/GraphReplay::sendNodeAdded → NO_COVERAGE
			sendNodeAdded(sourceId, nodeId);
90
91 2 1. replay : changed conditional boundary → NO_COVERAGE
2. replay : negated conditional → NO_COVERAGE
			if (node.getAttributeCount() > 0)
92 1 1. replay : negated conditional → NO_COVERAGE
				for (String key : node.getAttributeKeySet())
93 1 1. replay : removed call to org/graphstream/stream/GraphReplay::sendNodeAttributeAdded → NO_COVERAGE
					sendNodeAttributeAdded(sourceId, nodeId, key,
94
							node.getAttribute(key));
95
		}
96
97 1 1. replay : negated conditional → NO_COVERAGE
		for (Edge edge : graph.getEachEdge()) {
98
			String edgeId = edge.getId();
99 1 1. replay : removed call to org/graphstream/stream/GraphReplay::sendEdgeAdded → NO_COVERAGE
			sendEdgeAdded(sourceId, edgeId, edge.getNode0().getId(), edge
100
					.getNode1().getId(), edge.isDirected());
101
102 2 1. replay : changed conditional boundary → NO_COVERAGE
2. replay : negated conditional → NO_COVERAGE
			if (edge.getAttributeCount() > 0)
103 1 1. replay : negated conditional → NO_COVERAGE
				for (String key : edge.getAttributeKeySet())
104 1 1. replay : removed call to org/graphstream/stream/GraphReplay::sendEdgeAttributeAdded → NO_COVERAGE
					sendEdgeAttributeAdded(sourceId, edgeId, key,
105
							edge.getAttribute(key));
106
		}
107
	}
108
}

Mutations

84

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

85

1.1
Location : replay
Killed by : none
removed call to org/graphstream/stream/GraphReplay::sendGraphAttributeAdded → NO_COVERAGE

87

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

89

1.1
Location : replay
Killed by : none
removed call to org/graphstream/stream/GraphReplay::sendNodeAdded → NO_COVERAGE

91

1.1
Location : replay
Killed by : none
changed conditional boundary → NO_COVERAGE

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

92

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

93

1.1
Location : replay
Killed by : none
removed call to org/graphstream/stream/GraphReplay::sendNodeAttributeAdded → NO_COVERAGE

97

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

99

1.1
Location : replay
Killed by : none
removed call to org/graphstream/stream/GraphReplay::sendEdgeAdded → NO_COVERAGE

102

1.1
Location : replay
Killed by : none
changed conditional boundary → NO_COVERAGE

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

103

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

104

1.1
Location : replay
Killed by : none
removed call to org/graphstream/stream/GraphReplay::sendEdgeAttributeAdded → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT 0.33