MultiNode.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.Collection;
35
import java.util.Collections;
36
import java.util.HashMap;
37
import java.util.Iterator;
38
import java.util.LinkedList;
39
import java.util.List;
40
41
import org.graphstream.graph.Edge;
42
import org.graphstream.graph.Node;
43
44
/**
45
 * Nodes used with {@link MultiGraph}
46
 *
47
 */
48
public class MultiNode extends AdjacencyListNode {
49
	protected HashMap<AbstractNode, List<AbstractEdge>> neighborMap;
50
51
	// *** Constructor ***
52
53
	public MultiNode(AbstractGraph graph, String id) {
54
		super(graph, id);
55
		neighborMap = new HashMap<AbstractNode, List<AbstractEdge>>(
56 3 1. : Replaced integer multiplication with division → NO_COVERAGE
2. : Replaced integer division with multiplication → NO_COVERAGE
3. : Replaced integer addition with subtraction → NO_COVERAGE
				4 * INITIAL_EDGE_CAPACITY / 3 + 1);
57
	}
58
59
	// *** Helpers ***
60
61
	@SuppressWarnings("unchecked")
62
	@Override
63
	protected <T extends Edge> T locateEdge(Node opposite, char type) {
64
		List<AbstractEdge> l = neighborMap.get(opposite);
65 1 1. locateEdge : negated conditional → NO_COVERAGE
		if (l == null)
66 1 1. locateEdge : mutated return of Object value for org/graphstream/graph/implementations/MultiNode::locateEdge to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
			return null;
67
68 1 1. locateEdge : negated conditional → NO_COVERAGE
		for (AbstractEdge e : l) {
69
			char etype = edgeType(e);
70 2 1. locateEdge : negated conditional → NO_COVERAGE
2. locateEdge : negated conditional → NO_COVERAGE
			if ((type != I_EDGE || etype != O_EDGE)
71 2 1. locateEdge : negated conditional → NO_COVERAGE
2. locateEdge : negated conditional → NO_COVERAGE
					|| (type != O_EDGE || etype != I_EDGE))
72 1 1. locateEdge : mutated return of Object value for org/graphstream/graph/implementations/MultiNode::locateEdge to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
				return (T) e;
73
		}
74 1 1. locateEdge : mutated return of Object value for org/graphstream/graph/implementations/MultiNode::locateEdge to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
		return null;
75
	}
76
77
	@Override
78
	protected void removeEdge(int i) {
79
		AbstractNode opposite = edges[i].getOpposite(this);
80
		List<AbstractEdge> l = neighborMap.get(opposite);
81
		l.remove(edges[i]);
82 1 1. removeEdge : negated conditional → NO_COVERAGE
		if (l.isEmpty())
83
			neighborMap.remove(opposite);
84 1 1. removeEdge : removed call to org/graphstream/graph/implementations/AdjacencyListNode::removeEdge → NO_COVERAGE
		super.removeEdge(i);
85
	}
86
87
	// *** Callbacks ***
88
89
	@Override
90
	protected boolean addEdgeCallback(AbstractEdge edge) {
91
		AbstractNode opposite = edge.getOpposite(this);
92
		List<AbstractEdge> l = neighborMap.get(opposite);
93 1 1. addEdgeCallback : negated conditional → NO_COVERAGE
		if (l == null) {
94
			l = new LinkedList<AbstractEdge>();
95
			neighborMap.put(opposite, l);
96
		}
97
		l.add(edge);
98 1 1. addEdgeCallback : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE
		return super.addEdgeCallback(edge);
99
	}
100
101
	@Override
102
	protected void clearCallback() {
103 1 1. clearCallback : removed call to java/util/HashMap::clear → NO_COVERAGE
		neighborMap.clear();
104 1 1. clearCallback : removed call to org/graphstream/graph/implementations/AdjacencyListNode::clearCallback → NO_COVERAGE
		super.clearCallback();
105
	}
106
107
	// *** Others ***
108
109
	@SuppressWarnings("unchecked")
110
	@Override
111
	public <T extends Node> Iterator<T> getNeighborNodeIterator() {
112 1 1. getNeighborNodeIterator : mutated return of Object value for org/graphstream/graph/implementations/MultiNode::getNeighborNodeIterator to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
		return (Iterator<T>) Collections.unmodifiableSet(neighborMap.keySet())
113
				.iterator();
114
	}
115
116
	@SuppressWarnings("unchecked")
117
	public <T extends Edge> Collection<T> getEdgeSetBetween(Node node) {
118
		List<AbstractEdge> l = neighborMap.get(node);
119 1 1. getEdgeSetBetween : negated conditional → NO_COVERAGE
		if (l == null)
120 1 1. getEdgeSetBetween : mutated return of Object value for org/graphstream/graph/implementations/MultiNode::getEdgeSetBetween to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
			return Collections.emptyList();
121 1 1. getEdgeSetBetween : mutated return of Object value for org/graphstream/graph/implementations/MultiNode::getEdgeSetBetween to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
		return (Collection<T>) Collections.unmodifiableList(l);
122
	}
123
124
	public <T extends Edge> Collection<T> getEdgeSetBetween(String id) {
125 1 1. getEdgeSetBetween : mutated return of Object value for org/graphstream/graph/implementations/MultiNode::getEdgeSetBetween to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
		return getEdgeSetBetween(graph.getNode(id));
126
	}
127
128
	public <T extends Edge> Collection<T> getEdgeSetBetween(int index) {
129 1 1. getEdgeSetBetween : mutated return of Object value for org/graphstream/graph/implementations/MultiNode::getEdgeSetBetween to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
		return getEdgeSetBetween(graph.getNode(index));
130
	}
131
}

Mutations

56

1.1
Location :
Killed by : none
Replaced integer multiplication with division → NO_COVERAGE

2.2
Location :
Killed by : none
Replaced integer division with multiplication → NO_COVERAGE

3.3
Location :
Killed by : none
Replaced integer addition with subtraction → NO_COVERAGE

65

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

66

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

68

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

70

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

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

71

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

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

72

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

74

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

82

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

84

1.1
Location : removeEdge
Killed by : none
removed call to org/graphstream/graph/implementations/AdjacencyListNode::removeEdge → NO_COVERAGE

93

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

98

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

103

1.1
Location : clearCallback
Killed by : none
removed call to java/util/HashMap::clear → NO_COVERAGE

104

1.1
Location : clearCallback
Killed by : none
removed call to org/graphstream/graph/implementations/AdjacencyListNode::clearCallback → NO_COVERAGE

112

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

119

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

120

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

121

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

125

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

129

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

Active mutators

Tests examined


Report generated by PIT 0.33