SingleGraph.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 org.graphstream.graph.Graph;
35
import org.graphstream.graph.NodeFactory;
36
37
/**
38
 * An implementation of graph that supports only one edge between two nodes.
39
 */
40
public class SingleGraph extends AdjacencyListGraph {
41
42
	/**
43
	 * Creates an empty graph.
44
	 * 
45
	 * @param id
46
	 *            Unique identifier of the graph.
47
	 * @param strictChecking
48
	 *            If true any non-fatal error throws an exception.
49
	 * @param autoCreate
50
	 *            If true (and strict checking is false), nodes are
51
	 *            automatically created when referenced when creating a edge,
52
	 *            even if not yet inserted in the graph.
53
	 * @param initialNodeCapacity
54
	 *            Initial capacity of the node storage data structures. Use this
55
	 *            if you know the approximate maximum number of nodes of the
56
	 *            graph. The graph can grow beyond this limit, but storage
57
	 *            reallocation is expensive operation.
58
	 * @param initialEdgeCapacity
59
	 *            Initial capacity of the edge storage data structures. Use this
60
	 *            if you know the approximate maximum number of edges of the
61
	 *            graph. The graph can grow beyond this limit, but storage
62
	 *            reallocation is expensive operation.
63
	 */
64
	public SingleGraph(String id, boolean strictChecking, boolean autoCreate,
65
			int initialNodeCapacity, int initialEdgeCapacity) {
66
		super(id, strictChecking, autoCreate, initialNodeCapacity,
67
				initialEdgeCapacity);
68
		// All we need to do is to change the node factory
69 1 1. : removed call to org/graphstream/graph/implementations/SingleGraph::setNodeFactory → KILLED
		setNodeFactory(new NodeFactory<SingleNode>() {
70
			public SingleNode newInstance(String id, Graph graph) {
71 1 1. newInstance : mutated return of Object value for org/graphstream/graph/implementations/SingleGraph$1::newInstance to ( if (x != null) null else throw new RuntimeException ) → KILLED
				return new SingleNode((AbstractGraph) graph, id);
72
			}
73
		});
74
	}
75
76
	/**
77
	 * Creates an empty graph with default edge and node capacity.
78
	 * 
79
	 * @param id
80
	 *            Unique identifier of the graph.
81
	 * @param strictChecking
82
	 *            If true any non-fatal error throws an exception.
83
	 * @param autoCreate
84
	 *            If true (and strict checking is false), nodes are
85
	 *            automatically created when referenced when creating a edge,
86
	 *            even if not yet inserted in the graph.
87
	 */
88
	public SingleGraph(String id, boolean strictChecking, boolean autoCreate) {
89
		this(id, strictChecking, autoCreate, DEFAULT_NODE_CAPACITY,
90
				DEFAULT_EDGE_CAPACITY);
91
	}
92
93
	/**
94
	 * Creates an empty graph with strict checking and without auto-creation.
95
	 * 
96
	 * @param id
97
	 *            Unique identifier of the graph.
98
	 */
99
	public SingleGraph(String id) {
100
		this(id, true, false);
101
	}
102
103
}

Mutations

69

1.1
Location :
Killed by : org.graphstream.graph.implementations.AbstractGraphTest.nodeFactoryTest(org.graphstream.graph.implementations.AbstractGraphTest)
removed call to org/graphstream/graph/implementations/SingleGraph::setNodeFactory → KILLED

71

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

Active mutators

Tests examined


Report generated by PIT 0.33