$darkmode
DENOPTIM
GraphConversionToolTest.java
Go to the documentation of this file.
1package denoptim.utils;
2
3/*
4 * DENOPTIM
5 * Copyright (C) 2019 Vishwesh Venkatraman <vishwesh.venkatraman@ntnu.no>
6 * and Marco Foscato <marco.foscato@uib.no>
7 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU Affero General Public License as published
10 * by the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Affero General Public License for more details.
17 *
18 * You should have received a copy of the GNU Affero General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22import static org.junit.jupiter.api.Assertions.assertEquals;
23
24import org.jgrapht.graph.DefaultUndirectedGraph;
25import org.junit.jupiter.api.Test;
26
27import denoptim.ga.PopulationTest;
28import denoptim.graph.DGraph;
29import denoptim.graph.Template;
30import denoptim.graph.simplified.Node;
31import denoptim.graph.simplified.NodeConnection;
32
40{
41
42//------------------------------------------------------------------------------
43
44 @Test
45 public void testGetJGraphKernelFromGraph() throws Exception
46 {
49 DGraph gA = pair[0];
50 DGraph gB = pair[1];
52 .getInnerGraph();
54 .getInnerGraph();
55
56 DefaultUndirectedGraph<Node, NodeConnection> gkA =
58 assertEquals(5,gkA.vertexSet().size());
59 assertEquals(4,gkA.edgeSet().size());
60
61 DefaultUndirectedGraph<Node, NodeConnection> gkB =
63 assertEquals(4,gkB.vertexSet().size());
64 assertEquals(3,gkB.edgeSet().size());
65
66 DefaultUndirectedGraph<Node, NodeConnection> gkC =
68 assertEquals(8,gkC.vertexSet().size());
69 assertEquals(8,gkC.edgeSet().size());
70
71 DefaultUndirectedGraph<Node, NodeConnection> gkD =
73 assertEquals(8,gkD.vertexSet().size());
74 assertEquals(7,gkD.edgeSet().size());
75
76 }
77
78//------------------------------------------------------------------------------
79
80}
static GAParameters prepare()
static DGraph[] getPairOfTestGraphsB()
Builds a pair of graphs that contain templates with ContractLevel#FREE contract.
Container for the list of vertices and the edges that connect them.
Definition: DGraph.java:102
Vertex getVertexAtPosition(int pos)
Returns the vertex that is in the given position of the list of vertices belonging to this graph.
Definition: DGraph.java:2514
Tool to convert string into graphs and into molecular representation.
static DefaultUndirectedGraph< Node, NodeConnection > getJGraphKernelFromGraph(DGraph dg)
Converts a DGraph into a simplified JGraphT DefaultUndirectedGraph.
Unit test for GraphConversionTool.