MyraMath
vcut2


Source: tests/multifrontal/symbolic/vcut.cpp

1 // ========================================================================= //
2 // This file is part of MyraMath, copyright (c) 2014-2019 by Ryan A Chilton //
3 // and distributed by MyraCore, LLC. See LICENSE.txt for license terms. //
4 // ========================================================================= //
5 
11 // Containers.
14 #include <myramath/multifrontal/symbolic/detail/Graph.h>
15 #include <myramath/multifrontal/symbolic/detail/VertexCut.h>
16 
17 // Algorithms.
19 #include <myramath/multifrontal/symbolic/detail/vcut.h>
20 
21 // Reporting.
22 #include <tests/myratest.h>
23 
24 using namespace myra;
25 
26 // Tests vcut() for a Graph containing one Vertex.
27 ADD_TEST("vcut1","[symbolic]")
28  {
29  Graph graph;
30  graph.push_vertex( Graph::Vertex(0,1) );
31  graph.open_edges(0);
32  graph.close_edges(0);
33  graph.verify();
34 
35  VertexCut cut = vcut(graph);
36  verify(cut,graph);
37  REQUIRE(cut.group[0]==2);
38  }
39 
40 // Tests vcut() for a Graph containing two Vertex's.
41 ADD_TEST("vcut2","[symbolic]")
42  {
43  Graph graph;
44  graph.push_vertex( Graph::Vertex(0,2) );
45  graph.push_vertex( Graph::Vertex(1,1) );
46  graph.open_edges(0);
47  graph.push_edge( Graph::Edge(0,1) );
48  graph.close_edges(0);
49  graph.open_edges(1);
50  graph.push_edge( Graph::Edge(1,0) );
51  graph.close_edges(1);
52  graph.verify();
53 
54  VertexCut cut = vcut(graph);
55  verify(cut,graph);
56  REQUIRE(cut.group[0]!=2);
57  REQUIRE(cut.group[1]==2);
58  }
59 
60 // Tests vcut() for a Graph containing three Vertex's.
61 ADD_TEST("vcut3","[symbolic]")
62  {
63  Graph graph;
64  graph.push_vertex( Graph::Vertex(0,1) );
65  graph.push_vertex( Graph::Vertex(1,1) );
66  graph.push_vertex( Graph::Vertex(2,1) );
67  graph.open_edges(0);
68  graph.push_edge( Graph::Edge(0,1) );
69  graph.close_edges(0);
70  graph.open_edges(1);
71  graph.push_edge( Graph::Edge(1,0) );
72  graph.push_edge( Graph::Edge(1,2) );
73  graph.close_edges(1);
74  graph.open_edges(2);
75  graph.push_edge( Graph::Edge(2,1) );
76  graph.close_edges(2);
77  graph.verify();
78 
79  VertexCut cut = vcut(graph);
80  verify(cut,graph);
81  REQUIRE(cut.group[0]!=2);
82  REQUIRE(cut.group[1]==2);
83  REQUIRE(cut.group[2]!=2);
84  REQUIRE(cut.group[0]!=cut.group[2]);
85  }
86 
87 // Tests vcut() for a structured Graph with known minimum separator size.
88 ADD_TEST("vcut_structured","[symbolic][.]")
89  {
90  Pattern P = stencil2(40,10);
91  Graph graph = make_Graph(P);
92  graph.verify();
93  VertexCut cut = vcut(graph);
94  verify(cut,graph);
95  myra::out() << "cut.weight[0|2|1] = " << cut.weight[0] << "|" << cut.weight[2] << "|" << cut.weight[1] << std::endl;
96  REQUIRE(cut.weight[2] < cut.weight[0]);
97  REQUIRE(cut.weight[2] < cut.weight[1]);
98  }
Definition: syntax.dox:1
Range/Iterator types associated with Pattern.
Holds the nonzero pattern of a sparse matrix.
Definition: Pattern.h:55
Container class for a sparse nonzero pattern, used in reordering/symbolic analysis.
Helper routines for reordering/filling 2D structured grids. Used by many unit tests.


Results: [PASS]


Go back to Summary of /test programs.